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

feat: add CLI commands for config policies [CM-423] #9911

Merged
merged 3 commits into from
Oct 1, 2024

Conversation

salonig23
Copy link
Contributor

@salonig23 salonig23 commented Sep 10, 2024

Ticket

CM-423

Description

Add CLI commands and e2e tests for config policies.

Test Plan

Automated tests added.

Checklist

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

@cla-bot cla-bot bot added the cla-signed label Sep 10, 2024
Copy link

netlify bot commented Sep 10, 2024

Deploy Preview for determined-ui ready!

Name Link
🔨 Latest commit e075ff1
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/66fc3be20470350008c002cb
😎 Deploy Preview https://deploy-preview-9911--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.

@salonig23 salonig23 changed the title feat: add CLI commands for config policies feat: add CLI commands for config policies [CM-423] Sep 10, 2024
@salonig23 salonig23 marked this pull request as ready for review September 10, 2024 19:09
@salonig23 salonig23 requested review from a team as code owners September 10, 2024 19:09
Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 23.68421% with 29 lines in your changes missing coverage. Please review.

Project coverage is 54.57%. Comparing base (7f88390) to head (e075ff1).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
harness/determined/cli/config_policies.py 23.68% 29 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9911      +/-   ##
==========================================
- Coverage   54.57%   54.57%   -0.01%     
==========================================
  Files        1258     1259       +1     
  Lines      157138   157176      +38     
  Branches     3617     3618       +1     
==========================================
+ Hits        85764    85775      +11     
- Misses      71241    71268      +27     
  Partials      133      133              
Flag Coverage Δ
backend 45.31% <ø> (+<0.01%) ⬆️
harness 72.68% <23.68%> (-0.07%) ⬇️
web 54.34% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
harness/determined/cli/cli.py 45.13% <ø> (ø)
harness/determined/cli/config_policies.py 23.68% <23.68%> (ø)

... and 4 files with indirect coverage changes

@@ -163,6 +164,7 @@ def render_sequence(sequence: List[str]) -> str:
+ sso.args_description
+ oauth.args_description
+ dev.args_description
+ config_policies.args_description
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 we don't want to display help info for config policies until we're ready to release the feature, to prevent customers from accidentally discovering it. Is that possible?

Copy link
Contributor Author

@salonig23 salonig23 Sep 11, 2024

Choose a reason for hiding this comment

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

Do we want the command to still work even if it not displayed under help?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to Saloni's question! I was under the impression that these commands wouldn't work 🙈
@azhou-determined do you know if there's a way to "stub" out CLI commands without breaking the python linter?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry i'm confused lol, what's going on? i'm sure i'm missing something, but if the commands won't work without other changes, shouldn't this just land in a feature branch?

Copy link
Contributor

Choose a reason for hiding this comment

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

The commands will work to varying degree. The APIs are all stubbed at the moment, so the commands will function but not in a customer-ready way.

My thought was that, if we added the CLI commands in a non-discoverable way that we could use them to enable testing while we continue to develop features. @salonig23 a feature branch is also ok; I was trying to enable us to merge to main as much as possible for convenience / developer velocity.

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 will wait to merge this PR after RC cut for the next release - most of the API functions should be implemented by then and I can also work on switching the tests to unit tests intermittently

Copy link
Contributor

@kkunapuli kkunapuli left a comment

Choose a reason for hiding this comment

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

LGTM, great work!

harness/determined/cli/config_policies.py Outdated Show resolved Hide resolved
"--workspace-name",
type=str,
required=True, # change to false when adding --global
help="config policies for the given workspace",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
help="config policies for the given workspace",
help="the workspace whose config policies are being deleted ",

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually prefer config policies for the given workspace but I think either is fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the argument's help description correspond to what it is though?

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'd say since there is a separate help string for the command itself, we don't have to customize the help strings based on which command it is in. But maybe @azhou-determined can weigh in

"--workload-type",
type=str,
required=True,
help="config policies for a given workload, options: Experiment and NTSC",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
help="config policies for a given workload, options: Experiment and NTSC",
help="the type (Experiment or NTSC ) of config policies to set",

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 don't think we necessarily have to include the command in the description for these arguments, because there is a separate help string for the command. For example, all the workload-type help strings can be the same: "the type (Experiment or NTSC ) of config policies" Wdyt?

Copy link
Contributor

@amandavialva01 amandavialva01 left a comment

Choose a reason for hiding this comment

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

Looks awesome!
Left a few comments on some small refactoring, help message descriptions, and potential test case additions!

Copy link
Contributor

Choose a reason for hiding this comment

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

probably a bit too late for this since you already wrote them, but we've been trying to get CLIs out of e2e tests and into unit tests. generally speaking, our e2e tests are expensive to run and maintain, and usually more trouble than they're worth. we haven't always been thoughtful about what kinds of tests we consider "e2e" tests, and we pay the price when we try and change existing features/write new code in the future.

ideally, we'd have unit tests for these cases (see /harness/tests/cli/) that just mock the bindings call and verify that the correct values are passed in/gotten out. most CLI commands are simply argument parsing + calling bindings and shouldn't warrant a full on integration test.

it'd be great if we could turn these into unit tests, but it's not a big enough deal that i'd consider it a blocker. i like how you structured them and which cases to test, and i can tell you put a lot of work into these! if you need to land this quickly, i understand. i'll figure out a better way to communicate this kind of stuff across teams in the future, before PR time 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, I will be changing the tests to unit tests. Thanks for the thorough feedback!

@@ -163,6 +164,7 @@ def render_sequence(sequence: List[str]) -> str:
+ sso.args_description
+ oauth.args_description
+ dev.args_description
+ config_policies.args_description
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry i'm confused lol, what's going on? i'm sure i'm missing something, but if the commands won't work without other changes, shouldn't this just land in a feature branch?

harness/determined/cli/config_policies.py Outdated Show resolved Hide resolved

args_description: cli.ArgsDescription = [
cli.Cmd(
"config-policies",
Copy link
Contributor

Choose a reason for hiding this comment

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

how about just calling this "policies"? i'd imagined that "policies" would basically mean "constraint configs", and "config-policies" is a lot to type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kkunapuli @maxrussell what do you think about just policies? I remember deciding on config-policies to make it more discoverable and clear but I am open to either

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 we should use "task config policies" in documentation as much as possible, but I'm fine with using just policies for the CLI command.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have two concerns with just "policy":

  • I'm concerned that we'll have more than one kind of policy in our system and this will be convenient shorthand for now and then become confusing and ambiguous later.
  • I'm also concerned that without a noun or verb to attach to "policy," users won't know what it's for and we'll have the discoverability problem Saloni mentioned. Log retention policy? Garbage collection policy? etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's fair.

i was thinking about "policies" as a feature that would grow into something generic enough to encompass all sorts of system policies, or at least be the main "policy" feature that we support that it wouldn't be ambiguous.

if all policies are attached to a config, in the future there might exist some parallel between existing CLI commands and their policies, like det e set log-retention 1 and det e policies set log-retention 1. though the abstraction might not be as clean as i'm imagining.

i agree thought that right now just "policies" is kind of vague.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a cool idea! Interesting to have it be kind of a subtree of the CLI that mirrors others.

harness/determined/cli/config_policies.py Outdated Show resolved Hide resolved
harness/determined/cli/config_policies.py Outdated Show resolved Hide resolved
harness/determined/cli/config_policies.py Outdated Show resolved Hide resolved
Copy link
Contributor

@azhou-determined azhou-determined left a comment

Choose a reason for hiding this comment

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

nice work!

@kkunapuli kkunapuli merged commit 0083d7e into main Oct 1, 2024
94 of 117 checks passed
@kkunapuli kkunapuli deleted the add-constraints-CLI branch October 1, 2024 18:49
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.

5 participants