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

code cleanup #66

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

code cleanup #66

wants to merge 3 commits into from

Conversation

mishaschwartz
Copy link
Contributor

  • fix incorrect example in README
  • move argument parsing for logging options to the implementation code
  • fix bug where logging options were being set incorrectly
  • rename files to avoid potential naming conflicts with other packages (logging and requests)

Resolves #62

Comment on lines +135 to +136
ns.populator = "CMIP6_UofT"
return cli.run(ns)
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I gave it a try, and no error on my end (beside the unrelated schema validation of course).

{BE7604F5-C019-4211-A68C-3435813DA442}

Copy link
Contributor Author

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

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)

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.

Problems running the populator
3 participants