-
Notifications
You must be signed in to change notification settings - Fork 34
feat: Adding settings, utils, write to S3, and writer close #67
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
Open
malteos
wants to merge
7
commits into
main
Choose a base branch
from
feat/add-settings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f2e11c3
feat: Adding settings, utils, and writer close
malteos 94cc51b
Adding S3 writer integration
malteos 5793f1b
fix bad merge
malteos ed3061f
Adding unit test for s3 reads
malteos 4e660a3
Adding boto3 dependency
malteos e2a142b
adding more unit tests
malteos b9f01d4
Making test cross-platform compatible
malteos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import os | ||
|
|
||
| MAX_ERRORS = int(os.environ.get('CDXT_MAX_ERRORS', 100)) | ||
| WARNING_AFTER_N_ERRORS = int(os.environ.get('CDXT_WARNING_AFTER_N_ERRORS', 10)) | ||
|
|
||
| DEFAULT_MIN_RETRY_INTERVAL = float(os.environ.get('CDXT_DEFAULT_MIN_RETRY_INTERVAL', 3.0)) | ||
| CC_INDEX_MIN_RETRY_INTERVAL = float(os.environ.get('CDXT_CC_INDEX_MIN_RETRY_INTERVAL', 1.0)) | ||
| CC_DATA_MIN_RETRY_INTERVAL = float(os.environ.get('CDXT_CC_DATA_MIN_RETRY_INTERVAL', 0.55)) | ||
| IA_MIN_RETRY_INTERVAL = float(os.environ.get('CDXT_IA_MIN_RETRY_INTERVAL', 6.0)) | ||
|
|
||
|
|
||
| def get_mock_time(): | ||
| """Get the mock time from environment variable, evaluated dynamically""" | ||
| mock_time = os.environ.get('CDXT_MOCK_TIME') | ||
| return float(mock_time) if mock_time else None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import cdx_toolkit | ||
| from cdx_toolkit.commoncrawl import normalize_crawl | ||
|
|
||
| import logging | ||
|
|
||
| LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def get_version(): | ||
| return cdx_toolkit.__version__ | ||
|
|
||
|
|
||
| def setup(cmd): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we give this function a more descriptive name? what's it setting up exactly? is there a suitable type hint for 'cmd' (is it from argparse?) |
||
| kwargs = {} | ||
| kwargs['source'] = 'cc' if cmd.crawl else cmd.cc or cmd.ia or cmd.source or None | ||
| if kwargs['source'] is None: | ||
| raise ValueError('must specify --cc, --ia, or a --source') | ||
| if cmd.wb: | ||
| kwargs['wb'] = cmd.wb | ||
| if cmd.cc_mirror: | ||
| kwargs['cc_mirror'] = cmd.cc_mirror | ||
| if cmd.crawl: | ||
| kwargs['crawl'] = normalize_crawl([cmd.crawl]) # currently a string, not a list | ||
| if getattr(cmd, 'warc_download_prefix', None) is not None: | ||
| kwargs['warc_download_prefix'] = cmd.warc_download_prefix | ||
|
|
||
| cdx = cdx_toolkit.CDXFetcher(**kwargs) | ||
|
|
||
| kwargs = {} | ||
| if cmd.limit: | ||
| kwargs['limit'] = cmd.limit | ||
| if 'from' in vars(cmd) and vars(cmd)['from']: # python, uh, from is a reserved word | ||
| kwargs['from_ts'] = vars(cmd)['from'] | ||
| if cmd.to: | ||
| kwargs['to'] = cmd.to | ||
| if cmd.closest: | ||
| if not cmd.get: # pragma: no cover | ||
| LOGGER.info('note: --closest works best with --get') | ||
| kwargs['closest'] = cmd.closest | ||
| if cmd.filter: | ||
| kwargs['filter'] = cmd.filter | ||
|
|
||
| if cmd.cmd == 'warc' and cmd.size: | ||
| kwargs['size'] = cmd.size | ||
|
|
||
| if cmd.cmd == 'size' and cmd.details: | ||
| kwargs['details'] = cmd.details | ||
|
|
||
| return cdx, kwargs | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
knee-jerk reaction: can this be a
with ...:context manager sorta deal?