Skip to content

Commit

Permalink
feat: update computeplan status (#401)
Browse files Browse the repository at this point in the history
Signed-off-by: Guilhem Barthés <[email protected]>
  • Loading branch information
guilhem-barthes authored Mar 5, 2024
1 parent 42a5851 commit 9edd757
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Compute task status `DOING` is renamed `EXECUTING` ([#401](https://github.com/Substra/substra/pull/401))
- Compute plan statuses `EMPTY`, `WAITING` ansd `TODO` are merged into new status `CREATED` ([#401](https://github.com/Substra/substra/pull/401))

## [0.50.0](https://github.com/Substra/substra/releases/tag/0.50.0) - 2024-02-26

### Changed
Expand Down
2 changes: 1 addition & 1 deletion references/sdk_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ComputePlan
- building_count: <class 'int'>
- waiting_parent_tasks_count: <class 'int'>
- waiting_executor_slot_count: <class 'int'>
- doing_count: <class 'int'>
- executing_count: <class 'int'>
- canceled_count: <class 'int'>
- failed_count: <class 'int'>
- done_count: <class 'int'>
Expand Down
8 changes: 4 additions & 4 deletions substra/sdk/backends/local/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def __add_compute_plan(
key=key,
creation_date=self.__now(),
start_date=self.__now(),
status=models.ComputePlanStatus.waiting,
status=models.ComputePlanStatus.created,
tag="",
name=key,
task_count=task_count,
Expand Down Expand Up @@ -244,7 +244,7 @@ def __create_compute_plan_from_task(self, spec, in_tasks):
# Add to the compute plan
compute_plan.task_count += 1
compute_plan.waiting_executor_slot_count += 1
compute_plan.status = models.ComputePlanStatus.waiting
compute_plan.status = models.ComputePlanStatus.created

elif not spec.compute_plan_key and (spec.rank == 0 or spec.rank is None):
# Create a compute plan
Expand Down Expand Up @@ -388,14 +388,14 @@ def _add_compute_plan(self, spec: schemas.ComputePlanSpec, spec_options: dict =
start_date=self.__now(),
tag=spec.tag or "",
name=spec.name,
status=models.ComputePlanStatus.empty,
status=models.ComputePlanStatus.created,
metadata=spec.metadata or dict(),
task_count=0,
waiting_builder_slot_count=0,
building_count=0,
waiting_parent_tasks_count=0,
waiting_executor_slot_count=0,
doing_count=0,
executing_count=0,
canceled_count=0,
failed_count=0,
done_count=0,
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.ComputeTaskStatus.doing
task.status = models.ComputeTaskStatus.executing
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
8 changes: 3 additions & 5 deletions substra/sdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ComputeTaskStatus(str, enum.Enum):

unknown = "STATUS_UNKNOWN"
building = "STATUS_BUILDING"
doing = "STATUS_DOING"
executing = "STATUS_EXECUTING"
done = "STATUS_DONE"
failed = "STATUS_FAILED"
waiting_for_executor_slot = "STATUS_WAITING_FOR_EXECUTOR_SLOT"
Expand All @@ -51,10 +51,8 @@ class ComputePlanStatus(str, enum.Enum):
doing = "PLAN_STATUS_DOING"
done = "PLAN_STATUS_DONE"
failed = "PLAN_STATUS_FAILED"
todo = "PLAN_STATUS_TODO"
waiting = "PLAN_STATUS_WAITING"
created = "PLAN_STATUS_CREATED"
canceled = "PLAN_STATUS_CANCELED"
empty = "PLAN_STATUS_EMPTY"


class FunctionStatus(str, enum.Enum):
Expand Down Expand Up @@ -323,7 +321,7 @@ class ComputePlan(_Model):
building_count: int = 0
waiting_parent_tasks_count: int = 0
waiting_executor_slot_count: int = 0
doing_count: int = 0
executing_count: int = 0
canceled_count: int = 0
failed_count: int = 0
done_count: int = 0
Expand Down
4 changes: 2 additions & 2 deletions tests/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@
"creation_date": "2021-08-24T13:36:07.393646367Z",
"compute_plan_key": "ed74db2f-b302-4a9d-b3d3-336eb8dcc3ff",
"metadata": {},
"status": "STATUS_DOING",
"status": "STATUS_EXECUTING",
"worker": "MyOrg2MSP",
"rank": 0,
"tag": "",
Expand Down Expand Up @@ -596,7 +596,7 @@
"building_count": 0,
"waiting_parent_tasks_count": 1,
"waiting_executor_slot_count": 2,
"doing_count": 3,
"executing_count": 3,
"canceled_count": 4,
"failed_count": 5,
"done_count": 6,
Expand Down
2 changes: 1 addition & 1 deletion tests/sdk/local/test_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_compute_plan_add_update_tasks(self, asset_factory, clients):
)
)

assert compute_plan.status == models.ComputePlanStatus.empty
assert compute_plan.status == models.ComputePlanStatus.created

dataset_query = asset_factory.create_dataset()
dataset_key = client.add_dataset(dataset_query)
Expand Down
2 changes: 1 addition & 1 deletion tests/sdk/test_wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_wait_task_failed(client, mocker):
(datastore.TRAINTASK, "wait_task", ComputeTaskStatus.waiting_for_parent_tasks),
(datastore.TRAINTASK, "wait_task", ComputeTaskStatus.waiting_for_builder_slot),
(datastore.TRAINTASK, "wait_task", ComputeTaskStatus.waiting_for_executor_slot),
(datastore.COMPUTE_PLAN, "wait_compute_plan", ComputePlanStatus.todo),
(datastore.COMPUTE_PLAN, "wait_compute_plan", ComputePlanStatus.created),
],
ids=_param_name_maker,
)
Expand Down

0 comments on commit 9edd757

Please sign in to comment.