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

[AG-1041] Adds timestamp logging for processing runs #71

Merged
merged 9 commits into from
May 5, 2023

Conversation

BWMac
Copy link
Contributor

@BWMac BWMac commented May 2, 2023

This PR adds a new module to agoradatatools: logs.py. The new module contains the log_time decorator function along with a couple of helper functions. log_time` works by decorating a function like so:

@log_time(func_name="process_dataset", logger=logger)
def process_dataset():
     ...

It takes the name of the function (for configuring the logging output) and the logger instance for the module that it is being used in as arguments. At the moment, log_time has configurations for process_dataset and process_all_files, so that we can time and timestamp the processing of each dataset and data processing as a whole.

In practice, when you run adt test_config.yaml, you should see an output like this for each dataset:

INFO | 2023-05-04 16:05:00 | Now processing genes_biodomains dataset

##################################################
 Uploading file to Synapse storage 
##################################################

INFO | 2023-05-04 16:05:12 | 
##################################################
 Uploading file to Synapse storage 
##################################################

 / INFO | 2023-05-04 16:05:13 | Processing complete for genes_biodomains dataset
INFO | 2023-05-04 16:05:13 | Elapsed time: 00:00:13 for genes_biodomains dataset

And like this for the whole process:

INFO | 2023-05-04 16:04:47 | Agora Data Tools processing has started
...
...
...
...
INFO | 2023-05-04 16:07:12 | Elapsed time: 00:02:11 for all data processing

@BWMac BWMac changed the title [ORCA-1041] Adds timestamp logging for CI runs [AG-1041] Adds timestamp logging for CI runs May 3, 2023
@BWMac BWMac changed the title [AG-1041] Adds timestamp logging for CI runs [AG-1041] Adds timestamp logging for processing runs May 3, 2023
Copy link
Member

@thomasyu888 thomasyu888 May 3, 2023

Choose a reason for hiding this comment

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

So I've been thinking about this more, and configuring logging has always been a tiny bit confusing. BUT... I think initializing the logging can potentially be done in __init__.py. For example:

In __init__.py

logging.basicConfig(
    stream=sys.stdout, level=logging.INFO, format="INFO: %(message)s"
)

Basically, you may not need to initialize the logger everytime.

@BWMac BWMac marked this pull request as ready for review May 4, 2023 23:04
Copy link
Member

@thomasyu888 thomasyu888 left a comment

Choose a reason for hiding this comment

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

🎉 LGTM! Nice addition of logging!

@BWMac BWMac requested review from jaclynbeck-sage and JessterB May 5, 2023 00:57
Copy link
Contributor

@JessterB JessterB left a comment

Choose a reason for hiding this comment

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

This looks good to me, and including the processing times in addition to the timestamps is a nice bonus!

I am curious why we are logging the "Uploading file to synapse storage" block twice per dataset (once without, and then again with, the timestamp), but ultimately that's harmless...

@BWMac
Copy link
Contributor Author

BWMac commented May 5, 2023

@JessterB Yeah I was wondering about that myself, but that has to do with the syn.load() functionality rather than anything in this repo. I tried to silence the Synapse logging, but it caused issues with our new logging functionality. This is likely a Synapse client bug, Tom and I discussed that in this resolved comment thread.

Copy link
Contributor

@jaclynbeck-sage jaclynbeck-sage left a comment

Choose a reason for hiding this comment

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

This looks great!

@BWMac BWMac merged commit 170f0d4 into dev May 5, 2023
@BWMac BWMac deleted the bwmac/AG-1041/add_timestamp_logging branch May 5, 2023 20:36
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.

4 participants