Skip to content

Commit

Permalink
Explicitly set the status of the new task.
Browse files Browse the repository at this point in the history
Following wtsi-npg/npg_porch#72,
Status code 422 "Unprocessable Entity" error is received
from the server if the status is not set.
  • Loading branch information
mgcam committed Jul 17, 2024
1 parent 5fe758f commit 9d45a44
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/npg_porch_cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@
PORCH_OPENAPI_SCHEMA_URL = "api/v1/openapi.json"
PORCH_TASK_STATUS_ENUM_NAME = "TaskStateEnum"

PORCH_STATUSES = ["PENDING", "CLAIMED", "RUNNING", "DONE", "FAILED", "CANCELLED"]
INITIAL_PORCH_STATUS = "PENDING"
PORCH_STATUSES = [
INITIAL_PORCH_STATUS,
"CLAIMED",
"RUNNING",
"DONE",
"FAILED",
"CANCELLED",
]

CLIENT_TIMEOUT = (10, 60)

Expand Down Expand Up @@ -198,15 +206,22 @@ def add_pipeline(action: PorchAction, pipeline: Pipeline):


def add_task(action: PorchAction, pipeline: Pipeline):
"Registers a new task with the porch server."
"""Registers a new task with the porch server.
The new task is created with the default PENDING status.
"""

if action.task_input is None:
raise TypeError(f"task_input cannot be None for action '{action.action}'")
return send_request(
validate_ca_cert=action.validate_ca_cert,
url=urljoin(action.porch_url, "tasks"),
method="POST",
data={"pipeline": asdict(pipeline), "task_input": action.task_input},
data={
"pipeline": asdict(pipeline),
"task_input": action.task_input,
"status": INITIAL_PORCH_STATUS,
},
)


Expand Down

0 comments on commit 9d45a44

Please sign in to comment.