Skip to content

Commit

Permalink
chore: change error code back (#10042)
Browse files Browse the repository at this point in the history
  • Loading branch information
amandavialva01 authored and stoksc committed Oct 15, 2024
1 parent 5a39ecb commit 63f2f7f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion master/internal/api_experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
24 changes: 24 additions & 0 deletions master/internal/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
27 changes: 1 addition & 26 deletions master/internal/experiment_job_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ package internal

import (
"context"
"database/sql"
"fmt"
"strconv"

"github.com/pkg/errors"
"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"
)

Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 63f2f7f

Please sign in to comment.