Skip to content

Commit

Permalink
[sub]fix(app/orchestrator/resources): FunctionStatus.FUNCTION_STATUS_…
Browse files Browse the repository at this point in the history
…CREATED -> FunctionStatus.FUNCTION_STATUS_WAITING (#742)

# Issue

Backend FunctionStatus are not aligned with [orchestrator
definitions](https://github.com/Substra/orchestrator/blob/poc-decoupled-builder/lib/asset/function.proto#L29-L36).
In particular, `FunctionStatus.FUNCTION_STATUS_CREATED` leading to the
following error:

```txt
ValueError: 'FUNCTION_STATUS_WAITING' is not a valid FunctionStatus
```

## Description

FunctionStatus.FUNCTION_STATUS_CREATED ->
FunctionStatus.FUNCTION_STATUS_WAITING

## How has this been tested?

Running Camelyon benchmark on
[poc-builder-flpc](https://substra.org-1.poc-builder-flpc.cg.owkin.tech/compute_plans/a420306f-5719-412b-ab9c-688b7bed9c70/tasks?page=1&ordering=-rank)
environment.

## Checklist

- [ ] [changelog](../CHANGELOG.md) was updated with notable changes
- [ ] documentation was updated

---------

Signed-off-by: Thibault Camalon <[email protected]>
  • Loading branch information
thbcmlowk authored and SdgJlbl committed Oct 20, 2023
1 parent 7c63502 commit 3bf9779
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
5 changes: 4 additions & 1 deletion backend/api/events/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,10 @@ def _on_create_failure_report(event: dict) -> None:

if asset_type == failure_report_pb2.FAILED_ASSET_FUNCTION:
# Needed as this field is only in ComputeTask
compute_task_keys = ComputeTask.objects.values_list("key", flat=True).filter(function_id=asset_key, status__in=[ComputeTask.Status.STATUS_TODO.value, ComputeTask.Status.STATUS_DOING.value])
compute_task_keys = ComputeTask.objects.values_list("key", flat=True).filter(
function_id=asset_key,
status__in=[ComputeTask.Status.STATUS_TODO.value, ComputeTask.Status.STATUS_DOING.value],
)

for task_key in compute_task_keys:
_update_computetask(key=str(task_key), failure_report={"error_type": failure_report.get("error_type")})
Expand Down
28 changes: 28 additions & 0 deletions backend/api/migrations/0054_alter_function_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.3 on 2023-09-27 16:09

from django.db import migrations
from django.db import models


class Migration(migrations.Migration):
dependencies = [
("api", "0053_function_status"),
]

operations = [
migrations.AlterField(
model_name="function",
name="status",
field=models.CharField(
choices=[
("FUNCTION_STATUS_UNKNOWN", "Function Status Unknown"),
("FUNCTION_STATUS_WAITING", "Function Status Waiting"),
("FUNCTION_STATUS_BUILDING", "Function Status Building"),
("FUNCTION_STATUS_READY", "Function Status Ready"),
("FUNCTION_STATUS_CANCELED", "Function Status Canceled"),
("FUNCTION_STATUS_FAILED", "Function Status Failed"),
],
max_length=64,
),
),
]
2 changes: 1 addition & 1 deletion backend/api/tests/asset_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def create_function(
creation_date=timezone.now(),
owner=owner,
channel=channel,
status=Function.Status.FUNCTION_STATUS_CREATED,
status=Function.Status.FUNCTION_STATUS_WAITING,
**get_permissions(owner, public),
)

Expand Down
12 changes: 6 additions & 6 deletions backend/api/tests/views/test_views_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def setUp(self):
"outputs": {
"model": {"kind": "ASSET_MODEL", "multiple": False},
},
"status": "FUNCTION_STATUS_CREATED",
"status": "FUNCTION_STATUS_WAITING",
},
{
"key": str(aggregate_function.key),
Expand Down Expand Up @@ -136,7 +136,7 @@ def setUp(self):
"outputs": {
"model": {"kind": "ASSET_MODEL", "multiple": False},
},
"status": "FUNCTION_STATUS_CREATED",
"status": "FUNCTION_STATUS_WAITING",
},
{
"key": str(composite_function.key),
Expand Down Expand Up @@ -172,7 +172,7 @@ def setUp(self):
"local": {"kind": "ASSET_MODEL", "multiple": False},
"shared": {"kind": "ASSET_MODEL", "multiple": False},
},
"status": "FUNCTION_STATUS_CREATED",
"status": "FUNCTION_STATUS_WAITING",
},
{
"key": str(predict_function.key),
Expand Down Expand Up @@ -207,7 +207,7 @@ def setUp(self):
"outputs": {
"predictions": {"kind": "ASSET_MODEL", "multiple": False},
},
"status": "FUNCTION_STATUS_CREATED",
"status": "FUNCTION_STATUS_WAITING",
},
{
"key": str(metric_function.key),
Expand Down Expand Up @@ -241,7 +241,7 @@ def setUp(self):
"outputs": {
"performance": {"kind": "ASSET_PERFORMANCE", "multiple": False},
},
"status": "FUNCTION_STATUS_CREATED",
"status": "FUNCTION_STATUS_WAITING",
},
]

Expand Down Expand Up @@ -453,7 +453,7 @@ def mock_orc_response(data):
"function": data["function"],
"inputs": data["inputs"],
"outputs": data["outputs"],
"status": Function.Status.FUNCTION_STATUS_CREATED,
"status": Function.Status.FUNCTION_STATUS_WAITING,
}

function_path = os.path.join(FIXTURE_PATH, filename)
Expand Down
2 changes: 1 addition & 1 deletion backend/orchestrator/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Meta:
function_address = factory.SubFactory(AddressFactory)
inputs = {}
outputs = {}
status = FunctionStatus.FUNCTION_STATUS_CREATED
status = FunctionStatus.FUNCTION_STATUS_WAITING


class ComputePlanFactory(factory.Factory):
Expand Down
2 changes: 1 addition & 1 deletion backend/orchestrator/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def from_grpc(cls, o: function_pb2.FunctionOutput) -> FunctionOutput:

class FunctionStatus(AutoNameEnum):
FUNCTION_STATUS_UNKNOWN = enum.auto()
FUNCTION_STATUS_CREATED = enum.auto()
FUNCTION_STATUS_WAITING = enum.auto()
FUNCTION_STATUS_BUILDING = enum.auto()
FUNCTION_STATUS_READY = enum.auto()
FUNCTION_STATUS_CANCELED = enum.auto()
Expand Down

0 comments on commit 3bf9779

Please sign in to comment.