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

add debug logging for logging that takes up a lot of space #190

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Thomas-Lemoine
Copy link
Collaborator

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.

@@ -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}")
Copy link
Collaborator

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

Copy link
Collaborator Author

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())
Copy link
Collaborator

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

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