Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More friendly WARC prefix inside WACZ based on Org slug + Crawl Name / First Seed URL. #1537

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

ikreymer
Copy link
Member

Supports setting WARC prefix for WARCs inside WACZ to <org slug>-<slug [crawl name | first seed host]>.

  • Prefix set via WARC_PREFIX env var, supported in browsertrix-crawler 1.0.0-beta.4 or higher
    If crawl name is provided, uses crawl name, other hostname of first seed. The name is 'sluggified', using lowercase alphanum characters separated by dashes.

Ex: in an organization called Default Org, a crawl of https://specs.webrecorder.net/ and no name will have WARCs named:
default-org-specs-webrecorder-net-....warc.gz
If the crawl is given the name SPECS, the WARCs will be named default-org-specs-manual-....warc.gz

Fixes #412 in a default way.

- supports setting 'WARC_PREFIX' env var in browsertrix crawler (requires crawler 1.0.0-beta.4 or higher)
- prefix set to <org slug>-<slug [crawl name | first seed host]>
- using either crawl name, if provided, or host name of first seed. both are converted to slug (lowercase alphanum, seperate by dashes)
- fixes #412
)
print("Scheduled Crawl Created: " + crawl_id)

crawl_id, crawljob = self.new_crawl_job_yaml(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just moved from above so that warc_prefix would already be computed.

Copy link
Member

@tw4l tw4l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could maybe use an end-to-end test to verify that the WARCs are getting named as we expect, otherwise just have one comment

@tw4l
Copy link
Member

tw4l commented Feb 22, 2024

Other thought: we might want to try to cap filename sizes < 255 characters to avoid problems on local filesystems when unzipping the WACZ. Since we have a common suffix length (63 characters from preceding dash before crawl id to file suffix), we could enforce the prefix not being longer than an arbitrary amount of characters - I think maybe 100 would be reasonable? But might get exceeded if there's a long org slug and a long first URL currently.

@ikreymer
Copy link
Member Author

Other thought: we might want to try to cap filename sizes < 255 characters to avoid problems on local filesystems when unzipping the WACZ. Since we have a common suffix length (63 characters from preceding dash before crawl id to file suffix), we could enforce the prefix not being longer than an arbitrary amount of characters - I think maybe 100 would be reasonable? But might get exceeded if there's a long org slug and a long first URL currently.

It does just use the hostname, not the full URL, and hopefully the name will be fairly short. I'm inclined to wait and see if this becomes an issue at all.
Actually, what might be worth testing also is Unicode URLs and how that affects the default filename.

@ikreymer ikreymer merged commit 2a633c6 into 1.9.2-work Feb 22, 2024
2 of 4 checks passed
@ikreymer ikreymer deleted the warc-prefix-support branch February 22, 2024 22:00
ikreymer added a commit that referenced this pull request Feb 23, 2024
…/ First Seed URL. (#1537)

Supports setting WARC prefix for WARCs inside WACZ to `<org slug>-<slug
[crawl name | first seed host]>`.
- Prefix set via WARC_PREFIX env var, supported in browsertrix-crawler
1.0.0-beta.4 or higher
If crawl name is provided, uses crawl name, other hostname of first
seed. The name is 'sluggified', using lowercase alphanum characters
separated by dashes.

Ex: in an organization called `Default Org`, a crawl of
`https://specs.webrecorder.net/` and no name will have WARCs named:
`default-org-specs-webrecorder-net-....warc.gz`
If the crawl is given the name `SPECS`, the WARCs will be named
`default-org-specs-manual-....warc.gz`

Fixes #412 in a default way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants