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

DM-26780: Add --presets for command line bulk overrides via file #377

Merged
merged 2 commits into from Sep 21, 2020

Conversation

timj
Copy link
Member

@timj timj commented Sep 18, 2020

No description provided.

The value of the parameter.
"""
ctx.default_map = ctx.default_map or {}
cmd_name = ctx.info_name
Copy link
Contributor

Choose a reason for hiding this comment

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

Context.info_name is weird: when used with a command that is in a Group, as our subcommands are, then it contains the name of the subcommand, and so this works. But if you were to use this callback with the top level command (butler or pipetask) then it would contain the name of the script, including any extension (.py). Currently this would be ok for our commands because the butler script is called butler (not butler.py), and similar for pipetask. But it might pop up with other scripts if they don't omit the extension. Maybe it's worth stripping .py off the end here if it exists, or warning if .py is found? Or at least it's something to be aware of, someone may hit it someday.

Copy link
Member Author

Choose a reason for hiding this comment

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

This effectively becomes the key to use in the dict read from the yaml file. Things are all fine so long as this cmd_name is itself mentioned in the yaml file. Given that we are only using this for subcommands I'm inclined to leave it as is at the moment and let things break.

@@ -103,3 +103,12 @@ def makeCollectionType(context, param, value):
verbose_option = MWOptionDecorator("-v", "--verbose",
help="Increase verbosity.",
is_flag=True)


file_override_options = MWOptionDecorator("--options-file", "-@",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the name should be options_file_option; basically _option indicates that it's an option (as opposed to an argument) and options_file_ matches the name of the flag.

Copy link
Contributor

@n8pease n8pease left a comment

Choose a reason for hiding this comment

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

Please change the option name as noted or let's discuss, otherwise it looks goo d.

@timj
Copy link
Member Author

timj commented Sep 18, 2020

I changed the option name. It was wrong before.

@@ -103,3 +103,12 @@ def makeCollectionType(context, param, value):
verbose_option = MWOptionDecorator("-v", "--verbose",
help="Increase verbosity.",
is_flag=True)


options_file_option = MWOptionDecorator("--options-file", "-@",
Copy link
Contributor

Choose a reason for hiding this comment

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

of course this adds the -@ short flag for butler as well. I don't mind either way, but I think it will work if you want to add it only in pipetask, where you use the options_file_option you can pass it there:

@click.command()
@options_file_option("-@")
def build(**kwargs):
    ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I want the short flag available everywhere. I realize that butler is not going to be a problem because the options are small but I didn't think it caused harm by having it be consistent.

@timj timj merged commit 9e0bb4b into master Sep 21, 2020
@timj timj deleted the tickets/DM-26780 branch September 21, 2020 17:42
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.

None yet

2 participants