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

fix: properly interpret flag values #8326

Merged
merged 1 commit into from
Nov 7, 2023
Merged

Conversation

wes-turner
Copy link
Contributor

@wes-turner wes-turner commented Nov 3, 2023

Both --preemptible and --preemption-enabled cast values with the built-in bool, which casts to True any possible value but "0". Even "false" and "False". This is almost certainly not what users expect.

Using string_to_bool, "0" is still supported. But now all the strings that should evaluate to False do, too.

Description

Test Plan

ROI on testing this might not be high, but:

Deploy a cluster to GCP with det deploy gcp up with different values for --preemptible and --preemption-enabled.

Commentary (optional)

Checklist

  • Changes have been manually QA'd
  • User-facing API changes need the "User-facing API Change" label.
  • Release notes should be added as a separate file under docs/release-notes/.
    See Release Note for details.
  • Licenses should be included for new code which was copied and/or modified from any external code.

Ticket

Both `--preemptible` and `--preemption-enabled` cast values with the
built-in `bool`, which casts to True any possible value but "0". Even
"false" and "False". This is almost certainly not what users expect.

Using `string_to_bool`, "0" is still supported. But now all the strings
that should evaluate to False do, too.
@cla-bot cla-bot bot added the cla-signed label Nov 3, 2023
Copy link

netlify bot commented Nov 3, 2023

Deploy Preview for determined-ui ready!

Name Link
🔨 Latest commit a4f4cce
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/65454776a9f24b00089c5a68
😎 Deploy Preview https://deploy-preview-8326--determined-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@wes-turner wes-turner marked this pull request as ready for review November 3, 2023 19:33
@wes-turner wes-turner requested a review from a team as a code owner November 3, 2023 19:33
@@ -427,7 +427,7 @@ def parse(s: str) -> Tuple[str, str]:
),
Arg(
"--preemptible",
type=bool,
type=string_to_bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this string_to_bool and not BoolOptArg?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right.

Reasoning was that despite its name, BoolOptArg args aren't really optional, and aren't appropriate when the system doesn't want defaults. But this is one of those cases where having defaults is appropriate. I'll fix.

Copy link
Contributor Author

@wes-turner wes-turner Nov 6, 2023

Choose a reason for hiding this comment

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

Well, maybe not. 2 reasons:

  1. (minor reason) Switching to BoolOptArg changes the interface from --preemptible=true|false to --preemptible|--no-preemptible, and this is more likely to have user impact.
  2. (major reason) Each of these args is a part of an ArgGroup, which contains a list of Args. BoolOptArgs are not Args and do not look like Args and at this point I think refactoring BoolOptArgs or shimming an interface is not worth this PR. I could just make each ArgGroup's child_args list contain a union of Args and BoolOptArgs, but this feels like asking for trouble in the future if I don't unify the interface. I'm not convinced that it's worth spending a lot of time on declarative_argparse's lesser-used features because I'm not sure what the future of declarative_argparse will be.

@wes-turner wes-turner merged commit ea50987 into main Nov 7, 2023
75 of 85 checks passed
@wes-turner wes-turner deleted the wes/deploy-gcp-bool-flags branch November 7, 2023 17:25
@dannysauer dannysauer added this to the 0.26.4 milestone Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants