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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions harness/determined/deploy/gcp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import determined.deploy
from determined.cli.errors import CliError
from determined.common.declarative_argparse import Arg, ArgGroup, Cmd, Group
from determined.common.declarative_argparse import Arg, ArgGroup, Cmd, Group, string_to_bool
from determined.deploy.errors import MasterTimeoutExpired
from determined.deploy.gcp import constants, gcp

Expand Down Expand Up @@ -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.

default=False,
help="whether to use preemptible instances for dynamic agents",
),
Expand Down Expand Up @@ -535,7 +535,7 @@ def parse(s: str) -> Tuple[str, str]:
),
Arg(
"--preemption-enabled",
type=bool,
type=string_to_bool,
default=constants.defaults.PREEMPTION_ENABLED,
help="whether task preemption is supported in the scheduler "
"(only configurable for priority scheduler).",
Expand Down