Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly set the status of the new task. #11

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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