Skip to content

Commit

Permalink
feat!: update task status
Browse files Browse the repository at this point in the history
Signed-off-by: SdgJlbl <sarah.diot-girard@owkin.com>
  • Loading branch information
SdgJlbl committed Feb 13, 2024
1 parent d16042f commit 42e9cdb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- BREAKING: Renamed `function` field of the Function pydantic model to `archive`([#393](https://github.com/Substra/substra/pull/393))
- BREAKING: Renamed ComputeTask status ([#397](https://github.com/Substra/substra/pull/397))

### Added

Expand Down
3 changes: 2 additions & 1 deletion substra/sdk/backends/local/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ def _add_task(self, key, spec, spec_options=None):
inputs=_schemas_list_to_models_list(spec.inputs, models.InputRef),
outputs=_output_from_spec(spec.outputs),
tag=spec.tag or "",
status=models.Status.waiting,
# TODO: the waiting status should be more granular now
status=models.Status.waiting_for_builder_slot,
metadata=spec.metadata if spec.metadata else dict(),
)

Expand Down
2 changes: 1 addition & 1 deletion substra/sdk/backends/local/compute/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def schedule_task(self, task: models.Task):
task: Task to execute
"""
with self._context(task.key) as task_dir:
task.status = models.Status.doing
task.status = models.Status.building
task.start_date = datetime.datetime.now()
function = self._db.get_with_files(schemas.Type.Function, task.function.key)
input_multiplicity = {i.identifier: i.multiple for i in function.inputs}
Expand Down
7 changes: 4 additions & 3 deletions substra/sdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ class Status(str, enum.Enum):
"""Status of the task"""

unknown = "STATUS_UNKNOWN"
doing = "STATUS_DOING"
building = "STATUS_BUILDING"
done = "STATUS_DONE"
failed = "STATUS_FAILED"
todo = "STATUS_TODO"
waiting = "STATUS_WAITING"
waiting_for_executor_slot = "STATUS_WAITING_FOR_EXECUTOR_SLOT"
waiting_for_parent_tasks = "STATUS_WAITING_FOR_PARENT_TASKS"
waiting_for_builder_slot = "STATUS_WAITING_FOR_BUILDER_SLOT"
canceled = "STATUS_CANCELED"


Expand Down
4 changes: 3 additions & 1 deletion tests/sdk/test_wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def test_wait_task_failed(client, mocker):
@pytest.mark.parametrize(
("asset_dict", "function_name", "status"),
[
(datastore.TRAINTASK, "wait_task", Status.todo),
(datastore.TRAINTASK, "wait_task", Status.waiting_for_parent_tasks),
(datastore.TRAINTASK, "wait_task", Status.waiting_for_builder_slot),
(datastore.TRAINTASK, "wait_task", Status.waiting_for_executor_slot),
(datastore.COMPUTE_PLAN, "wait_compute_plan", ComputePlanStatus.todo),
],
ids=_param_name_maker,
Expand Down

0 comments on commit 42e9cdb

Please sign in to comment.