diff --git a/api.yml b/api.yml index 97c25fca..1f9b3f93 100644 --- a/api.yml +++ b/api.yml @@ -43,10 +43,8 @@ paths: # /v1.0/workflows/0 /workflows/{workflow_id}: - - # api.workflows.get(workflow_id) get: - operationId: api.workflows_tasks.get + operationId: api.workflows_tasks.start summary: Status info for a specific workflow instance tags: - workflows @@ -54,17 +52,17 @@ paths: - name: workflow_id in: path required: true - description: The id of the workflow to retrieve + description: The id of the workflow to start schema: type: integer format: int32 responses: '200': - description: Expected response to a valid request + description: First task in the workflow content: application/json: schema: - $ref: "#/components/schemas/Workflows" + $ref: "#/components/schemas/Task" default: description: unexpected error content: @@ -72,9 +70,8 @@ paths: schema: $ref: "#/components/schemas/Error" - # /v1.0/workflows/0/task/0 + # /v1.0/workflows/0/tasks/0 /workflows/{workflow_id}/tasks/{task_id}: - get: operationId: api.workflows_tasks.get summary: Get status of specific task in specific workflow instance diff --git a/api/__init__.py b/api/__init__.py index 1e4e542e..c041bd1c 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -1 +1,2 @@ import api.workflows +import api.workflows_tasks diff --git a/api/workflows.py b/api/workflows.py index 652f00d3..b19cb3ba 100644 --- a/api/workflows.py +++ b/api/workflows.py @@ -18,7 +18,7 @@ def list_all(limit=100): return list(workflows.values())[0:limit] -def get(workflow_id: int) -> Union[Tuple[Any, int], Dict[str, Union[int, str, datetime]]]: +def get(workflow_id): id_ = int(workflow_id) if workflows.get(id_) is None: return NoContent, 404 diff --git a/api/workflow_tasks.py b/api/workflows_tasks.py similarity index 82% rename from api/workflow_tasks.py rename to api/workflows_tasks.py index e1cd9141..cf63554c 100644 --- a/api/workflow_tasks.py +++ b/api/workflows_tasks.py @@ -35,13 +35,24 @@ workflow_tasks = [ }, ] + def start(workflow_id): - spec = TrainingWorkflowSpec() - wf = Workflow(spec) - workflow_tasks[len(workflow_tasks)] = wf + # spec = TrainingWorkflowSpec() + # wf = Workflow(spec) + id_ = len(workflow_tasks) + workflow_tasks.append({ + 'id': id_, + 'workflow_id': workflow_id, + 'task_id': 1, + 'last_updated': datetime.datetime.now(), + 'status': 'Incomplete', + }) + return workflow_tasks[id_] + def get(workflow_id, task_id): i = _get_workflow_task_index(workflow_id, task_id) + print(i) return workflow_tasks[i] if i is not None else NoContent, 404 @@ -70,7 +81,7 @@ def delete(workflow_id, task_id): def _get_workflow_task_index(workflow_id, task_id): workflow_id = int(workflow_id) task_id = int(task_id) - for (wt, i) in enumerate(workflow_tasks): + for i, wt in enumerate(workflow_tasks): if wt['workflow_id'] == workflow_id and wt['task_id'] == task_id: return i return None