diff --git a/master/internal/api_experiment.go b/master/internal/api_experiment.go index 9a831d67767e..fa742a1779b2 100644 --- a/master/internal/api_experiment.go +++ b/master/internal/api_experiment.go @@ -1465,7 +1465,7 @@ func (a *apiServer) parseAndMergeContinueConfig(expID int, overrideConfig string } mergedConfig := schemas.Merge(providedConfig, activeConfig) if overrideName := mergedConfig.Searcher().AsLegacy().Name; isSingle && overrideName != "single" { - return nil, false, status.Errorf(codes.Internal, + return nil, false, status.Errorf(codes.InvalidArgument, fmt.Sprintf("override config must have single searcher type got '%s' instead", overrideName)) } diff --git a/master/internal/experiment.go b/master/internal/experiment.go index e05abc25bfc7..c980ccdb1e52 100644 --- a/master/internal/experiment.go +++ b/master/internal/experiment.go @@ -19,6 +19,7 @@ import ( "github.com/determined-ai/determined/master/internal/api" "github.com/determined-ai/determined/master/internal/checkpoints" "github.com/determined-ai/determined/master/internal/config" + "github.com/determined-ai/determined/master/internal/configpolicy" internaldb "github.com/determined-ai/determined/master/internal/db" "github.com/determined-ai/determined/master/internal/experiment" "github.com/determined-ai/determined/master/internal/job/jobservice" @@ -1033,6 +1034,29 @@ func (e *internalExperiment) setPriority(priority *int, forward bool) (err error if priority == nil { return nil } + + workspaceModel, err := workspace.WorkspaceByProjectID(context.TODO(), e.ProjectID) + if err != nil && errors.Cause(err) != sql.ErrNoRows { + return err + } + wkspID := resolveWorkspaceID(workspaceModel) + + // Returns an error if RM does not implement priority. + if smallerHigher, err := e.rm.SmallerValueIsHigherPriority(); err == nil { + ok, err := configpolicy.PriorityUpdateAllowed( + wkspID, + model.ExperimentType, + *priority, + smallerHigher, + ) + if err != nil { + return err + } + if !ok { + return fmt.Errorf("priority exceeds task config policy's priority_limit") + } + } + oldPriority := config.DefaultSchedulingPriority var oldPriorityPtr *int resources := e.activeConfig.Resources() diff --git a/master/internal/experiment_job_service.go b/master/internal/experiment_job_service.go index dc5b80a611f3..070d7e8a1a95 100644 --- a/master/internal/experiment_job_service.go +++ b/master/internal/experiment_job_service.go @@ -2,7 +2,6 @@ package internal import ( "context" - "database/sql" "fmt" "strconv" @@ -10,9 +9,7 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" "github.com/determined-ai/determined/master/internal/config" - "github.com/determined-ai/determined/master/internal/configpolicy" "github.com/determined-ai/determined/master/internal/workspace" - "github.com/determined-ai/determined/master/pkg/model" "github.com/determined-ai/determined/proto/pkg/jobv1" ) @@ -57,29 +54,7 @@ func (e *internalExperiment) SetJobPriority(priority int) error { return fmt.Errorf("priority must be between 1 and 99") } - workspaceModel, err := workspace.WorkspaceByProjectID(context.TODO(), e.ProjectID) - if err != nil && errors.Cause(err) != sql.ErrNoRows { - return err - } - wkspID := resolveWorkspaceID(workspaceModel) - - // Returns an error if RM does not implement priority. - if smallerHigher, err := e.rm.SmallerValueIsHigherPriority(); err == nil { - ok, err := configpolicy.PriorityUpdateAllowed( - wkspID, - model.ExperimentType, - priority, - smallerHigher, - ) - if err != nil { - return err - } - if !ok { - return fmt.Errorf("priority exceeds task config policy's priority_limit") - } - } - - err = e.setPriority(&priority, true) + err := e.setPriority(&priority, true) if err != nil { e.syslog.WithError(err).Info("setting experiment job priority") }