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

chore: populate exp config priority with enforced priority before opting to rm default #10109

Closed
wants to merge 7 commits into from

Conversation

amandavialva01
Copy link
Contributor

@amandavialva01 amandavialva01 commented Oct 23, 2024

Ticket

CM-586

Description

Populate experiment config priority with the enforced priority specified in workspace or global invariant config or constraints policies.
If priority is not enforced by config policies within the experiment's scope, populate with the experiment config default priority specified by the rm.

Test Plan

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

@amandavialva01 amandavialva01 requested a review from a team as a code owner October 23, 2024 17:59
@cla-bot cla-bot bot added the cla-signed label Oct 23, 2024
Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 75.86207% with 7 lines in your changes missing coverage. Please review.

Project coverage is 54.47%. Comparing base (22ad457) to head (0da7a09).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
master/internal/configpolicy/task_config_policy.go 72.22% 5 Missing ⚠️
master/internal/core_experiment.go 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10109      +/-   ##
==========================================
- Coverage   54.49%   54.47%   -0.02%     
==========================================
  Files        1267     1267              
  Lines      159437   159449      +12     
  Branches     3637     3636       -1     
==========================================
- Hits        86885    86866      -19     
- Misses      72419    72450      +31     
  Partials      133      133              
Flag Coverage Δ
backend 45.68% <75.86%> (-0.05%) ⬇️
harness 72.55% <ø> (ø)
web 54.02% <ø> (ø)

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

Files with missing lines Coverage Δ
master/internal/core_experiment.go 62.90% <81.81%> (+0.56%) ⬆️
master/internal/configpolicy/task_config_policy.go 87.41% <72.22%> (+0.25%) ⬆️

... and 10 files with indirect coverage changes

Copy link

netlify bot commented Oct 23, 2024

Deploy Preview for determined-ui canceled.

Name Link
🔨 Latest commit 0da7a09
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/671a72a3ded5b9000889a21c

prio := masterConfig.DefaultPriorityForPool(poolName.String())
config.RawResources.RawPriority = &prio
// Returns an error if RM does not implement priority.
enforcedPriority, _, err := configpolicy.FindAllowedPriority(
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm confused why an unset priority becomes the constraints.priority_limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Really good catch, this should be enforcedPriority != nil, rather than enforcedPriority == nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wait, actually I think it's good as is!
This is basically saying that if no priority is enforced with config policies, then we use the default priority specified by the rm.
Otherwise, we use the enforced priority specified in the invariant config or constraints

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you're talking about in the FindAllowedPriority function, I am not entirely sure where you mean 🙈

Copy link
Contributor

Choose a reason for hiding this comment

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

what I'm saying is we want to constrain by the constraint not enforce it, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

cool. an aside: FindAllowedPriority feels strange; it's sort of leaking details about how it chose the priority. at least in this callsite I think a better API be InvariantPriority(...) (prio int, ok bool) that returns the invariant priority for a workload or (0, false) if there is none.

Copy link
Contributor

Choose a reason for hiding this comment

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

curious what you think @kkunapuli

Copy link
Contributor Author

@amandavialva01 amandavialva01 Oct 24, 2024

Choose a reason for hiding this comment

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

I think a better API be InvariantPriority(...) (prio int, ok bool) that returns the invariant priority for a workload or (0, false) if there is none.

+1 to this! I think we should separate out the logic for getting the invariant config and the constraints when finding different fields. FindAllowedPriority is really well commented so it's possible to read the comments and understand the logic behind the return values, but I kinda feel like it's a bit too much logic packed into one func, particularly with the second output boolean.

For what it's worth, I have a branch right now that uses generics to get a given config field and can potentially be used to shorten/refactor FindAllowedPriority to get the invariant configs in one foul swoop!

Copy link
Contributor

Choose a reason for hiding this comment

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

@stoksc I agree that the function could use a refactor.

@amandavialva01 - the refactor should not impact functionality. With that in mind, please finish all other in-progress work before starting a refactor. Also, I would be more comfortable if we merge it after the release cutoff at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool! I implemented the generics function for PATCH experiment changes, not with the intention of refactoring FindAllowedPriority. I'll avoid making any refactor changes to that func!

@amandavialva01
Copy link
Contributor Author

Closing this as this is not a bug

@amandavialva01 amandavialva01 deleted the amanda/CM586 branch November 14, 2024 21:24
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