Skip to content

Commit

Permalink
chore: rename ComputeTask DOING to EXECUTING
Browse files Browse the repository at this point in the history
Signed-off-by: Guilhem Barthés <guilhem.barthes@owkin.com>
  • Loading branch information
guilhem-barthes committed Feb 16, 2024
1 parent a12a40d commit 68517c7
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 56 deletions.
10 changes: 5 additions & 5 deletions docs/assets/schemas/computetask.state.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ stateDiagram-v2
building: BUILDING
waitingParent: WAITING_FOR_PARENT_TASKS
waitingExecutor: WAITING_FOR_EXECUTOR_SLOT
doing: DOING
executing: EXECUTING
canceled: CANCELED
failed: FAILED
done: DONE
Expand All @@ -19,18 +19,18 @@ stateDiagram-v2
waitingBuilding --> building
building --> waitingParent
waitingParent --> waitingExecutor
waitingExecutor --> doing
doing --> done
waitingExecutor --> executing
executing --> done
done --> [*]


building --> failed
doing --> failed
executing --> failed
failed --> [*]

waitingBuilding --> canceled
building --> canceled
waitingParent --> canceled
waitingExecutor --> canceled
doing --> canceled
executing --> canceled
canceled --> [*]
2 changes: 1 addition & 1 deletion e2e/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (c *TestClient) FailableRegisterTasks(optList ...Taskable) (*asset.Register
}

func (c *TestClient) StartTask(keyRef string) {
c.applyTaskTransition(keyRef, asset.ComputeTaskAction_TASK_ACTION_DOING)
c.applyTaskTransition(keyRef, asset.ComputeTaskAction_TASK_ACTION_EXECUTING)
}

func (c *TestClient) CancelTask(keyRef string) {
Expand Down
4 changes: 2 additions & 2 deletions lib/asset/computetask.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum ComputeTaskStatus {
STATUS_UNKNOWN = 0;
STATUS_WAITING_FOR_PARENT_TASKS = 1;
STATUS_WAITING_FOR_EXECUTOR_SLOT = 2;
STATUS_DOING = 3;
STATUS_EXECUTING = 3;
STATUS_DONE = 4;
STATUS_CANCELED = 5;
STATUS_FAILED = 6;
Expand Down Expand Up @@ -114,7 +114,7 @@ message GetTaskParam {

enum ComputeTaskAction {
TASK_ACTION_UNKNOWN = 0;
TASK_ACTION_DOING = 1;
TASK_ACTION_EXECUTING = 1;
TASK_ACTION_CANCELED = 2;
TASK_ACTION_FAILED = 3;
TASK_ACTION_DONE = 4;
Expand Down
2 changes: 1 addition & 1 deletion lib/asset/computetask_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (p *ApplyTaskActionParam) Validate() error {
validation.Field(&p.ComputeTaskKey, validation.Required, is.UUID),
validation.Field(&p.Action, validation.Required, validation.In(
// TASK_ACTION_BUILDING, TASK_ACTION_WAITING_FOR_EXECUTION are managed internally based on function status
ComputeTaskAction_TASK_ACTION_DOING,
ComputeTaskAction_TASK_ACTION_EXECUTING,
ComputeTaskAction_TASK_ACTION_FAILED,
ComputeTaskAction_TASK_ACTION_CANCELED,
ComputeTaskAction_TASK_ACTION_DONE,
Expand Down
4 changes: 2 additions & 2 deletions lib/asset/computetask_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ func TestApplyTaskActionParam(t *testing.T) {
empty := &ApplyTaskActionParam{}
valid := &ApplyTaskActionParam{
ComputeTaskKey: "972bef4c-1b42-4743-bbe9-cc3f4a69952f",
Action: ComputeTaskAction_TASK_ACTION_DOING,
Action: ComputeTaskAction_TASK_ACTION_EXECUTING,
}
missingKey := &ApplyTaskActionParam{
Action: ComputeTaskAction_TASK_ACTION_DOING,
Action: ComputeTaskAction_TASK_ACTION_EXECUTING,
}
missingAction := &ApplyTaskActionParam{
ComputeTaskKey: "972bef4c-1b42-4743-bbe9-cc3f4a69952f",
Expand Down
2 changes: 1 addition & 1 deletion lib/asset/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestPermissionValue(t *testing.T) {
}

func TestComputeTaskStatusValue(t *testing.T) {
s := ComputeTaskStatus_STATUS_DOING
s := ComputeTaskStatus_STATUS_EXECUTING
status := &s

value, err := status.Value()
Expand Down
2 changes: 1 addition & 1 deletion lib/service/computetask.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

// Task statuses in which the inputs are defined
var inputDefinedStatus = []asset.ComputeTaskStatus{
asset.ComputeTaskStatus_STATUS_DOING,
asset.ComputeTaskStatus_STATUS_EXECUTING,
asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT,
asset.ComputeTaskStatus_STATUS_FAILED,
}
Expand Down
10 changes: 5 additions & 5 deletions lib/service/computetask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestQueryTasks(t *testing.T) {

pagination := common.NewPagination("", 2)
filter := &asset.TaskQueryFilter{
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
}

returnedTasks := []*asset.ComputeTask{{}, {}}
Expand Down Expand Up @@ -333,7 +333,7 @@ func TestRegisterCompositeTaskWithCompositeParents(t *testing.T) {
parent1 := &asset.ComputeTask{
Key: "aaaaaaaa-cccc-bbbb-eeee-111111111111",
ComputePlanKey: "867852b4-8419-4d52-8862-d5db823095be",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
FunctionKey: functionParent1.Key,
Outputs: map[string]*asset.ComputeTaskOutput{
"shared": {Permissions: sharedPerms},
Expand All @@ -343,7 +343,7 @@ func TestRegisterCompositeTaskWithCompositeParents(t *testing.T) {
parent2 := &asset.ComputeTask{
Key: "aaaaaaaa-cccc-bbbb-eeee-222222222222",
ComputePlanKey: "867852b4-8419-4d52-8862-d5db823095be",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
FunctionKey: functionParent2.Key,
Outputs: map[string]*asset.ComputeTaskOutput{
"shared": {Permissions: sharedPerms},
Expand Down Expand Up @@ -1196,7 +1196,7 @@ func TestDisableOutputs(t *testing.T) {
})
t.Run("task not in terminal state", func(t *testing.T) {
task := &asset.ComputeTask{
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "myorg",
}

Expand Down Expand Up @@ -1312,7 +1312,7 @@ func TestDisableOutputs(t *testing.T) {
}

child := &asset.ComputeTask{
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
}

outputAsset := &asset.ComputeTaskOutputAsset{AssetKind: asset.AssetKind_ASSET_MODEL}
Expand Down
18 changes: 9 additions & 9 deletions lib/service/computetaskstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
transitionDone taskTransition = "transitionDone"
transitionCanceled taskTransition = "transitionCanceled"
transitionFailed taskTransition = "transitionFailed"
transitionDoing taskTransition = "transitionDoing"
transitionExecuting taskTransition = "transitionExecuting"
)

// taskStateEvents is the definition of the state machine representing task states
Expand All @@ -37,7 +37,7 @@ var taskStateEvents = fsm.Events{
},
{
Name: string(transitionCanceled),
Src: []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_DOING.String()},
Src: []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_EXECUTING.String()},
Dst: asset.ComputeTaskStatus_STATUS_CANCELED.String(),
},
{
Expand All @@ -46,18 +46,18 @@ var taskStateEvents = fsm.Events{
Dst: asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(),
},
{
Name: string(transitionDoing),
Name: string(transitionExecuting),
Src: []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String()},
Dst: asset.ComputeTaskStatus_STATUS_DOING.String(),
Dst: asset.ComputeTaskStatus_STATUS_EXECUTING.String(),
},
{
Name: string(transitionDone),
Src: []string{asset.ComputeTaskStatus_STATUS_DOING.String()},
Src: []string{asset.ComputeTaskStatus_STATUS_EXECUTING.String()},
Dst: asset.ComputeTaskStatus_STATUS_DONE.String(),
},
{
Name: string(transitionFailed),
Src: []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_DOING.String()},
Src: []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_EXECUTING.String()},
Dst: asset.ComputeTaskStatus_STATUS_FAILED.String(),
},
}
Expand Down Expand Up @@ -130,8 +130,8 @@ func (s *ComputeTaskService) applyTaskAction(task *asset.ComputeTask, action ass
switch action {
case asset.ComputeTaskAction_TASK_ACTION_CANCELED:
transition = transitionCanceled
case asset.ComputeTaskAction_TASK_ACTION_DOING:
transition = transitionDoing
case asset.ComputeTaskAction_TASK_ACTION_EXECUTING:
transition = transitionExecuting
case asset.ComputeTaskAction_TASK_ACTION_FAILED:
transition = transitionFailed
case asset.ComputeTaskAction_TASK_ACTION_DONE:
Expand Down Expand Up @@ -419,7 +419,7 @@ func updateAllowed(task *asset.ComputeTask, action asset.ComputeTaskAction, requ
switch action {
case asset.ComputeTaskAction_TASK_ACTION_CANCELED, asset.ComputeTaskAction_TASK_ACTION_FAILED:
return requester == task.Owner || requester == task.Worker
case asset.ComputeTaskAction_TASK_ACTION_DOING, asset.ComputeTaskAction_TASK_ACTION_DONE:
case asset.ComputeTaskAction_TASK_ACTION_EXECUTING, asset.ComputeTaskAction_TASK_ACTION_DONE:
return requester == task.Worker
default:
return false
Expand Down
22 changes: 11 additions & 11 deletions lib/service/computetaskstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestOnStateChange(t *testing.T) {

state := newState(updater, &asset.ComputeTask{Status: asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT, Key: "uuid"})

err := state.Event(context.Background(), string(transitionDoing), &asset.ComputeTask{})
err := state.Event(context.Background(), string(transitionExecuting), &asset.ComputeTask{})

assert.NoError(t, err)
updater.AssertExpectations(t)
Expand All @@ -112,9 +112,9 @@ func TestOnStateChange(t *testing.T) {
func TestFailedStateChange(t *testing.T) {
updater := new(mockTaskStateUpdater)

state := newState(updater, &asset.ComputeTask{Status: asset.ComputeTaskStatus_STATUS_DOING, Key: "uuid"})
state := newState(updater, &asset.ComputeTask{Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Key: "uuid"})

err := state.Event(context.Background(), string(transitionDoing), &asset.ComputeTask{})
err := state.Event(context.Background(), string(transitionExecuting), &asset.ComputeTask{})
assert.IsType(t, fsm.InvalidEventError{}, err)

state = newState(updater, &asset.ComputeTask{Status: asset.ComputeTaskStatus_STATUS_DONE, Key: "uuid"})
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestDispatchOnTransition(t *testing.T) {

expectedTask := &asset.ComputeTask{
Key: "uuid",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "worker",
ComputePlanKey: "uuidcp",
}
Expand All @@ -160,7 +160,7 @@ func TestDispatchOnTransition(t *testing.T) {
}
es.On("RegisterEvents", expectedEvent).Once().Return(nil)

err := service.ApplyTaskAction("uuid", asset.ComputeTaskAction_TASK_ACTION_DOING, "", "worker")
err := service.ApplyTaskAction("uuid", asset.ComputeTaskAction_TASK_ACTION_EXECUTING, "", "worker")
assert.NoError(t, err)

es.AssertExpectations(t)
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestUpdateTaskStateDone(t *testing.T) {

dbal.On("GetComputeTask", "uuid").Return(&asset.ComputeTask{
Key: "uuid",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Owner: "owner",
Worker: "worker",
}, nil)
Expand Down Expand Up @@ -239,7 +239,7 @@ func TestCascadeStatusDone(t *testing.T) {

task := &asset.ComputeTask{
Key: "uuid",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Owner: "owner",
Worker: "worker",
}
Expand Down Expand Up @@ -301,14 +301,14 @@ func TestUpdateAllowed(t *testing.T) {
action: asset.ComputeTaskAction_TASK_ACTION_BUILD_FINISHED,
outcome: false,
},
"owner doing": {
"owner executing": {
requester: task.Owner,
action: asset.ComputeTaskAction_TASK_ACTION_DOING,
action: asset.ComputeTaskAction_TASK_ACTION_EXECUTING,
outcome: false,
},
"worker doing": {
"worker executing": {
requester: "worker",
action: asset.ComputeTaskAction_TASK_ACTION_DOING,
action: asset.ComputeTaskAction_TASK_ACTION_EXECUTING,
outcome: true,
},
"owner cancel": {
Expand Down
2 changes: 1 addition & 1 deletion lib/service/failure_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func checkTaskPermissions(task *asset.ComputeTask, requester string) error {
return errors.NewPermissionDenied(fmt.Sprintf("only %q worker can register failure report for compute task", task.Worker))
}

if task.Status != asset.ComputeTaskStatus_STATUS_DOING {
if task.Status != asset.ComputeTaskStatus_STATUS_EXECUTING {
return errors.NewBadRequest(fmt.Sprintf("cannot register failure report for task with status %q", task.Status.String()))
}

Expand Down
2 changes: 1 addition & 1 deletion lib/service/failure_report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestRegisterComputeTaskFailureReport(t *testing.T) {

taskService.On("GetTask", newFailureReport.AssetKey).Once().Return(&asset.ComputeTask{
Key: newFailureReport.AssetKey,
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "test",
}, nil)

Expand Down
2 changes: 1 addition & 1 deletion lib/service/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *ModelService) registerModel(newModel *asset.NewModel, requester string,
return nil, errors.NewPermissionDenied(fmt.Sprintf("only %q worker can register model", task.Worker))
}

if task.Status != asset.ComputeTaskStatus_STATUS_DOING {
if task.Status != asset.ComputeTaskStatus_STATUS_EXECUTING {
return nil, errors.NewBadRequest(fmt.Sprintf("cannot register model for task with status %q", task.Status.String()))
}

Expand Down
18 changes: 9 additions & 9 deletions lib/service/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func TestRegisterTrainModel(t *testing.T) {

task := &asset.ComputeTask{
Key: "08680966-97ae-4573-8b2d-6c4db2b3c532",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "test",
Outputs: map[string]*asset.ComputeTaskOutput{
"model": {
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestRegisterAggregateModel(t *testing.T) {

task := &asset.ComputeTask{
Key: "08680966-97ae-4573-8b2d-6c4db2b3c532",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "test",
Outputs: map[string]*asset.ComputeTaskOutput{
"model": {
Expand Down Expand Up @@ -383,7 +383,7 @@ func TestRegisterDuplicateModel(t *testing.T) {
persistence.ComputeTaskOutputCounter{"model": 1},
&asset.ComputeTask{
Key: "08680966-97ae-4573-8b2d-6c4db2b3c532",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "test",
Outputs: map[string]*asset.ComputeTaskOutput{
"model": {
Expand Down Expand Up @@ -441,7 +441,7 @@ func TestRegisterHeadModel(t *testing.T) {

task := &asset.ComputeTask{
Key: "08680966-97ae-4573-8b2d-6c4db2b3c532",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "test",
Outputs: map[string]*asset.ComputeTaskOutput{
"shared": {
Expand Down Expand Up @@ -562,7 +562,7 @@ func TestRegisterMultipleHeads(t *testing.T) {
persistence.ComputeTaskOutputCounter{"local": 1},
&asset.ComputeTask{
Key: "08680966-97ae-4573-8b2d-6c4db2b3c532",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "test",
Outputs: map[string]*asset.ComputeTaskOutput{
"shared": {
Expand Down Expand Up @@ -616,7 +616,7 @@ func TestRegisterInvalidOutput(t *testing.T) {

task := &asset.ComputeTask{
Key: "08680966-97ae-4573-8b2d-6c4db2b3c532",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "test",
Outputs: map[string]*asset.ComputeTaskOutput{
"model": {
Expand Down Expand Up @@ -696,7 +696,7 @@ func TestRegisterModelsTrainTask(t *testing.T) {

task := &asset.ComputeTask{
Key: "08680966-97ae-4573-8b2d-6c4db2b3c532",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "test",
Outputs: map[string]*asset.ComputeTaskOutput{
"model": {
Expand Down Expand Up @@ -804,7 +804,7 @@ func TestRegisterHeadAndTrunkModel(t *testing.T) {

task := &asset.ComputeTask{
Key: "08680966-97ae-4573-8b2d-6c4db2b3c532",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "test",
Outputs: map[string]*asset.ComputeTaskOutput{
"shared": {
Expand Down Expand Up @@ -939,7 +939,7 @@ func TestRegisterMissingOutput(t *testing.T) {

task := &asset.ComputeTask{
Key: "08680966-97ae-4573-8b2d-6c4db2b3c532",
Status: asset.ComputeTaskStatus_STATUS_DOING,
Status: asset.ComputeTaskStatus_STATUS_EXECUTING,
Worker: "test",
Outputs: map[string]*asset.ComputeTaskOutput{},
}
Expand Down
2 changes: 1 addition & 1 deletion lib/service/performance.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (s *PerformanceService) RegisterPerformance(newPerf *asset.NewPerformance,
return nil, errors.NewPermissionDenied(fmt.Sprintf("only %q worker can register performance", task.Worker))
}

if task.Status != asset.ComputeTaskStatus_STATUS_DOING {
if task.Status != asset.ComputeTaskStatus_STATUS_EXECUTING {
return nil, errors.NewBadRequest(fmt.Sprintf("cannot register performance for task with status %q", task.Status.String()))
}

Expand Down
Loading

0 comments on commit 68517c7

Please sign in to comment.