-
Notifications
You must be signed in to change notification settings - Fork 7
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
add debug logging for logging that takes up a lot of space #190
base: main
Are you sure you want to change the base?
Conversation
@@ -71,7 +71,7 @@ def extract(item): | |||
return dict(filter(None, map(extract, header.splitlines()))) | |||
|
|||
def _get_article(self, url): | |||
logger.info("Fetching {}".format(url)) | |||
logger.debug(f"Fetching {url}") |
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.
strictly speaking, when logging you should use params, like logger.debug("Fetching %s", url)
. It's fine here, but can potentially be a problem if casting url
to a string is a slow or costly operation - with fstrings it's always done, but when provided as an argument it only does it when needed (i.e. log level == 'debug'). Again - here it's fine, but it's worth bearing in mind
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.
Oh, I see, I hadn't thought of that
main.py
Outdated
@@ -74,7 +74,7 @@ def generate_jsonl_files(self, *names): | |||
assert not missing, f"{missing} are not valid dataset names" | |||
for name in names: | |||
dataset = get_dataset(name) | |||
print(dataset.to_jsonl()) | |||
logger.info(dataset.to_jsonl()) |
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.
logger.info("%s", dataset.to_jsonl())
, or logger.info(str(dataset.to_jsonl()))
. logger.info
expects a string as its first argument
avoids logger.info-ing all items in a source, and instead logs some constant amount of time per source, rather than proportional to its length, with the default logger level (info). if you're debugging you can set that to "DEBUG" for more info.