-
Notifications
You must be signed in to change notification settings - Fork 2
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
code cleanup #66
base: master
Are you sure you want to change the base?
code cleanup #66
Conversation
ns.populator = "CMIP6_UofT" | ||
return cli.run(ns) |
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 think this is potentially dangerous if we add other sub-ArgumentParser
commands than the top-level CLI run
command which might not have the populator
attribute.
Since the run
function (not to confuse with the run
subparser command) only does implementation_modules()[ns.populator].runner(ns)
, there's basically no difference from doing runner(ns)
(as before), and there's no need to inject the populator
argument anymore.
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.
This is necessary so that the logging options are applied when this file is executed directly from the command line.
I think this is potentially dangerous if we add other sub-ArgumentParser commands than the top-level CLI run command which might not have the populator attribute.
Agreed, if that happens, then we'd have to modify this code as well. The simpler and more maintainable thing to do would be to remove the option to call populator scripts directly from the command line.
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'm not sure to understand why the logging options cause this? populator
is only defined by the run
subparser. What causes populator
to become an issue if calling the script directly since run
would be bypassed entirely?
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.
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'm not sure to understand why the logging options cause this?
There's no error but the logging options are applied here
stac-populator/STACpopulator/cli.py
Line 49 in b353feb
setup_logging(ns.log_file, ns.debug or logging.INFO) |
So if you don't run it through the CLI functions then the logging options are never applied. We could have added a call to setup_logging
in every runner
function as well but that seemed like we're adding boilerplate (which we're actively trying to remove in #64)
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.
OK. But can we at least resolve the populator
name automatically rather than a hard coded value? I really dislike having different name resolution strategies by different part of the code. If the directory name is the "reference" for the populator name, then everywhere should resolve it the same way.
logging
andrequests
)Resolves #62