Skip to content

Commit

Permalink
chore: indirect import for jobs to avoid import cycle (determined-ai#…
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinaecalderon authored Oct 24, 2023
1 parent aa77386 commit 4c59393
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions master/internal/api_experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/determined-ai/determined/master/internal/db"
exputil "github.com/determined-ai/determined/master/internal/experiment"
"github.com/determined-ai/determined/master/internal/grpcutil"
"github.com/determined-ai/determined/master/internal/job"
"github.com/determined-ai/determined/master/internal/job/jobservice"
"github.com/determined-ai/determined/master/internal/prom"
"github.com/determined-ai/determined/master/internal/sproto"
"github.com/determined-ai/determined/master/internal/trials"
Expand Down Expand Up @@ -337,7 +337,7 @@ func (a *apiServer) GetExperiment(
}

jobID := model.JobID(exp.JobId)
jobSummary, err := job.DefaultService.GetJobSummary(jobID, exp.ResourcePool)
jobSummary, err := jobservice.DefaultService.GetJobSummary(jobID, exp.ResourcePool)
if err != nil {
// An error here either is real or just that the experiment was not yet terminal in the DB
// when we first queried it but was by the time it got around to handling out ask. We can't
Expand Down
7 changes: 4 additions & 3 deletions master/internal/api_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/determined-ai/determined/master/internal/api"
"github.com/determined-ai/determined/master/internal/job/jobservice"

"github.com/determined-ai/determined/master/internal/authz"
"github.com/determined-ai/determined/master/internal/grpcutil"
Expand All @@ -16,7 +17,7 @@ import (
func (a *apiServer) GetJobs(
ctx context.Context, req *apiv1.GetJobsRequest,
) (resp *apiv1.GetJobsResponse, err error) {
jobs, err := job.DefaultService.GetJobs(
jobs, err := jobservice.DefaultService.GetJobs(
req.ResourcePool,
req.OrderBy == apiv1.OrderBy_ORDER_BY_DESC,
req.States,
Expand Down Expand Up @@ -47,7 +48,7 @@ func (a *apiServer) GetJobs(
func (a *apiServer) GetJobsV2(
ctx context.Context, req *apiv1.GetJobsV2Request,
) (resp *apiv1.GetJobsV2Response, err error) {
jobs, err := job.DefaultService.GetJobs(
jobs, err := jobservice.DefaultService.GetJobs(
req.ResourcePool,
req.OrderBy == apiv1.OrderBy_ORDER_BY_DESC,
req.States,
Expand Down Expand Up @@ -118,7 +119,7 @@ func (a *apiServer) UpdateJobQueue(
if permErr != nil {
return nil, permErr
}
err = job.DefaultService.UpdateJobQueue(req.Updates)
err = jobservice.DefaultService.UpdateJobQueue(req.Updates)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions master/internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/sirupsen/logrus"

"github.com/determined-ai/determined/master/internal/db"
"github.com/determined-ai/determined/master/internal/job"
"github.com/determined-ai/determined/master/internal/job/jobservice"
"github.com/determined-ai/determined/master/internal/rm"
"github.com/determined-ai/determined/master/internal/rm/rmerrors"
"github.com/determined-ai/determined/master/internal/rm/tasklist"
Expand Down Expand Up @@ -307,7 +307,7 @@ func (c *command) Receive(ctx *actor.Context) error {
return err
}

job.DefaultService.RegisterJob(c.jobID, c)
jobservice.DefaultService.RegisterJob(c.jobID, c)

if err := c.persist(); err != nil {
ctx.Log().WithError(err).Warnf("command persist failure")
Expand All @@ -324,7 +324,7 @@ func (c *command) Receive(ctx *actor.Context) error {
ctx.Log().WithError(err).Error("marking task complete")
}
}
go job.DefaultService.UnregisterJob(c.jobID)
go jobservice.DefaultService.UnregisterJob(c.jobID)
if err := user.DeleteSessionByToken(
context.TODO(),
c.GenericCommandSpec.Base.UserSessionToken,
Expand Down
2 changes: 1 addition & 1 deletion master/internal/command/command_job_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/determined-ai/determined/proto/pkg/jobv1"
)

// job.Service methods
// jobservice.Service methods

// ToV1Job() takes a command and returns a job.
func (c *command) ToV1Job() *jobv1.Job {
Expand Down
4 changes: 2 additions & 2 deletions master/internal/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
"github.com/determined-ai/determined/master/internal/db"
"github.com/determined-ai/determined/master/internal/elastic"
"github.com/determined-ai/determined/master/internal/grpcutil"
"github.com/determined-ai/determined/master/internal/job"
"github.com/determined-ai/determined/master/internal/job/jobservice"
"github.com/determined-ai/determined/master/internal/plugin/sso"
"github.com/determined-ai/determined/master/internal/portregistry"
"github.com/determined-ai/determined/master/internal/prom"
Expand Down Expand Up @@ -1051,7 +1051,7 @@ func (m *Master) Run(ctx context.Context, gRPCLogInitDone chan struct{}) error {
},
cert,
)
job.SetDefaultService(m.rm)
jobservice.SetDefaultService(m.rm)

tasksGroup := m.echo.Group("/tasks")
tasksGroup.GET("", api.Route(m.getTasks))
Expand Down
6 changes: 3 additions & 3 deletions master/internal/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/determined-ai/determined/master/internal/api"
"github.com/determined-ai/determined/master/internal/config"
"github.com/determined-ai/determined/master/internal/db"
"github.com/determined-ai/determined/master/internal/job"
"github.com/determined-ai/determined/master/internal/job/jobservice"
"github.com/determined-ai/determined/master/internal/rm"
"github.com/determined-ai/determined/master/internal/rm/rmerrors"
"github.com/determined-ai/determined/master/internal/rm/tasklist"
Expand Down Expand Up @@ -292,7 +292,7 @@ func (e *experiment) Receive(ctx *actor.Context) error {
return err
}

job.DefaultService.RegisterJob(e.JobID, e)
jobservice.DefaultService.RegisterJob(e.JobID, e)

if e.restored {
j, err := e.db.JobByID(e.JobID)
Expand Down Expand Up @@ -445,7 +445,7 @@ func (e *experiment) Receive(ctx *actor.Context) error {
e.syslog.Error(err)
}
}
go job.DefaultService.UnregisterJob(e.JobID)
go jobservice.DefaultService.UnregisterJob(e.JobID)
state := model.StoppingToTerminalStates[e.State]
if state == "" {
state = model.ErrorState
Expand Down
2 changes: 1 addition & 1 deletion master/internal/experiment_job_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/determined-ai/determined/proto/pkg/jobv1"
)

// job.Service methods
// jobservice.Service methods

// ToV1Jobs() takes an experiment and returns a job.
func (e *experiment) ToV1Job() *jobv1.Job {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package job
package jobservice

import (
"fmt"
Expand Down

0 comments on commit 4c59393

Please sign in to comment.