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: migrate CLI from deprecated SDK methods #8282

Merged
merged 4 commits into from
Oct 31, 2023
Merged

Conversation

wes-turner
Copy link
Contributor

@wes-turner wes-turner commented Oct 31, 2023

The following dependencies were migrated

model:

  • Model.get_models -> list_models
  • Model.get_versions -> list_versions

trial:

  • Trial.select_checkpoint -> list_checkpoints

For Trial.select_checkpoint, argument validation that was in select_checkpoint has been copied into the function in the CLI that called it (trial::download), validating passed flags as flags rather than parameters in the parent.

Description

Test Plan

The changed CLI methods are:

det trial download
det model list
det model list-versions

Please try them each out, maybe playing with their flags. No deprecation warning should ever be printed.

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

@cla-bot cla-bot bot added the cla-signed label Oct 31, 2023
@netlify
Copy link

netlify bot commented Oct 31, 2023

Deploy Preview for determined-ui canceled.

Name Link
🔨 Latest commit b5bfe83
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/65413e14a9e4570008cad1f7

model:
* Model.get_models -> list_models
* Model.get_versions -> list_versions

trial:
* Trial.select_checkpoint -> list_checkpoints

For Trial.select_checkpoint, argument validation that was in
select_checkpoint has been copied into the function in the CLI that
called it (trial::download), validating passed flags as flags rather
than parameters in the parent.
smaller_is_better=args.smaller_is_better,
det = Determined(args.master, args.user)

if [args.latest, args.best, args.uuid].count(True) != 1:
Copy link
Contributor Author

@wes-turner wes-turner Oct 31, 2023

Choose a reason for hiding this comment

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

Copy link
Member

@rb-determined-ai rb-determined-ai Oct 31, 2023

Choose a reason for hiding this comment

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

too bad mypy complains about sum([args.latest, args.best, args.uuid]). But I like this .count(True) better than wrapping all the bools in int().

Copy link
Member

Choose a reason for hiding this comment

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

also, are you basically just copy/pasting the .select_checkpoint() verification logic here?

You could move the body of .select_checkpoint() into an internal ._select_checkpoint(), where .select_checkpoint() exists only to emit the deprecation warning, and _select_checkpoint() is reusable by the CLI.

I like that strategy because it sticks to DRY, and avoids any possibility of diverging code. When select_checkpoint is removed from the SDK, you can migrate _select_checkpoint() here as you've done now, because then there's only one copy of it.

I don't feel too strongly about this, so you don't need to treat this comment as blocking.

Copy link
Contributor Author

@wes-turner wes-turner Oct 31, 2023

Choose a reason for hiding this comment

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

also, are you basically just copy/pasting the .select_checkpoint() verification logic here?

Yes.

Thanks for thinking about it. This is nice. I like this strategy, too, but minus two factors:

  1. I want the stack trace to come from the CLI
  2. I prefer the CLI errors to mention flags (--smaller-is-better) instead of variables (smaller_is_better)

What I've chosen is worse from a tech-debt perspective, but I can't think of anything for (2) especially that localizes variable names to library-style or cli-style.

@wes-turner wes-turner marked this pull request as ready for review October 31, 2023 16:07
@wes-turner wes-turner requested a review from a team as a code owner October 31, 2023 16:07
from determined.common.declarative_argparse import Arg, ArgsDescription, Cmd, Group
from determined.experimental import Determined
from determined.common.declarative_argparse import Arg, ArgsDescription, Cmd, Group, string_to_bool
from determined.experimental.client import CheckpointSortBy, Determined, OrderBy
Copy link
Member

Choose a reason for hiding this comment

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

please stick to the google style guide when adding new imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ha! I like it.

Ok, brb..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's more than an hour or two to migrate the whole CLI and I want to get this fix out today, so I just made the minimum change.

Copy link
Member

Choose a reason for hiding this comment

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

sure, also arguably this fix and that migration shouldn't be in the same pr anyway

@wes-turner wes-turner merged commit d17a2cc into main Oct 31, 2023
70 of 81 checks passed
@wes-turner wes-turner deleted the wes/deprecated-cli-sdk branch October 31, 2023 18:22
@dannysauer dannysauer added this to the 0.26.3 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