Fixes some typos and syntax errors

This commit is contained in:
Aaron Louie 2019-11-19 16:13:07 -05:00
parent 983ffb4309
commit 0e7a632fb2
4 changed files with 22 additions and 13 deletions

13
api.yml
View File

@ -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

View File

@ -1 +1,2 @@
import api.workflows
import api.workflows_tasks

View File

@ -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

View File

@ -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