-
Notifications
You must be signed in to change notification settings - Fork 36
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
[ariaDownload.py] Code refactoring and adding progress bar #446
base: dev
Are you sure you want to change the base?
Conversation
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.
LGTM! I made very minor tweak to the default start date to reflect the timing of the first NISAR beta products. Before an earlier scene was getting kicked out.
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.
I noticed a lot of changes which are not related to the addition of a progress bar.
IMO this pull request should be reduced to only the changes needed to implement the functionality and not include any style changes. I feel some of these changes make the code less explicit and more confusing. I could elaborate on specifics but I'm not sure that will be helpful.
Regarding imports:
I have removed the vast majority of from X import Y style from the rest of this code, I want to keep it this way with the full namespace used. (explicit > implicit)
Regarding logger messages:
The asf_search log level suppression should probably be moved to ARIAtools.util.log similar to other items in there. That will be executed at import time and suppress those messages for everything which imports that module.
Just as a general note to file away, best practice for logger messages is to use lazy formatting to optimize performance (won't format string unless the message will be written). So avoid f-strings and .format() calls in there but use additional arguments and %-style formatting:
https://stackoverflow.com/questions/66993387/use-lazy-formatting-in-logging-functions-pylint-error-message
https://medium.com/flowe-ita/logging-should-be-lazy-bc6ac9816906
I know this was already in there and you did not add this, but we should remove this line:
LOGGER.setLevel(logging.DEBUG if self.args.verbose else logging.INFO)
The global log level should only ever be set in the main() function and I should have deleted this before.
Is there a benefit to importing the whole module rather than the needed pieces? Importing the whole module will increase the memory usage.
Moved the line to
Switched f-string formatted logger messages to lazy formatting.
Would you like to open a separate PR for this? |
Yes, it is more explicit (zen of python) that is enough of a benefit to (nearly) always import the entire module. There will always be some exceptions where it makes sense but IMO not with basic module imports. The entire module is imported either way so there is no compute time or memory savings in using Can the util.log module treat the asf_search log level setter identically as the others (I think it can be)? Then it can be just another item in the list of module names which have the log level set to Finally, I didn't see any commits addressing or discussion of all of the unrelated changes included in the PR. |
e.g., from datetime import datetime, timedelta
)asf_search
logging level toERROR
to suppress warning messages like:Example Run Output
ariaDownload.py --bbox "34.6 34.8 -118.1 -117.9" --track 71 --output Download --start 20211214 --end 20220102