Skip to content

Commit

Permalink
status takes a list instead of a single literal
Browse files Browse the repository at this point in the history
  • Loading branch information
VerstraeteBert committed Jun 3, 2024
1 parent 983f384 commit 0b6deeb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cognite/client/_api/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def list(
workflow_version_ids: WorkflowVersionIdentifier | MutableSequence[WorkflowVersionIdentifier] | None = None,
created_time_start: int | None = None,
created_time_end: int | None = None,
status: Literal["completed", "failed", "running", "terminated", "timed_out"] | None = None,
statuses: list[Literal["completed", "failed", "running", "terminated", "timed_out"]] | None = None,
limit: int = DEFAULT_LIMIT_READ,
) -> WorkflowExecutionList:
"""`List workflow executions in the project. <https://api-docs.cognite.com/20230101-beta/tag/Workflow-executions/operation/ListWorkflowExecutions>`_
Expand All @@ -221,7 +221,7 @@ def list(
workflow_version_ids (WorkflowVersionIdentifier | MutableSequence[WorkflowVersionIdentifier] | None): Workflow version id or list of workflow version ids to filter on.
created_time_start (int | None): Filter out executions that was created before this time. Time is in milliseconds since epoch.
created_time_end (int | None): Filter out executions that was created after this time. Time is in milliseconds since epoch.
status (Literal["completed", "failed", "running", "terminated", "timed_out"] | None): Fetch only executions with this status.
statuses (list[Literal["completed", "failed", "running", "terminated", "timed_out"]] | None): Fetch only executions with these statuses.
limit (int): Maximum number of results to return. Defaults to 25. Set to -1, float("inf") or None
to return all items.
Returns:
Expand Down Expand Up @@ -253,8 +253,8 @@ def list(
filter_["createdTimeStart"] = created_time_start
if created_time_end is not None:
filter_["createdTimeEnd"] = created_time_end
if status is not None:
filter_["status"] = status.upper()
if statuses is not None:
filter_["status"] = [status.upper() for status in statuses]

return self._list(
method="POST",
Expand Down
8 changes: 4 additions & 4 deletions tests/tests_integration/test_api/test_data_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@ def test_list_workflow_executions_by_status(

# the new execution should not be completed yet, but running
listed_completed = cognite_client.workflows.executions.list(
workflow_version_ids=add_multiply_workflow.as_id(), status="completed", limit=3
workflow_version_ids=add_multiply_workflow.as_id(), status=["completed"], limit=3
)
listed_failed = cognite_client.workflows.executions.list(
workflow_version_ids=add_multiply_workflow.as_id(), status="running", limit=3
listed_running = cognite_client.workflows.executions.list(
workflow_version_ids=add_multiply_workflow.as_id(), status=["running"], limit=3
)
assert filter(lambda x: x.id == result.id, listed_completed) == []
assert len(filter(lambda x: x.id == result.id, listed_failed)) == 1
assert len(filter(lambda x: x.id == result.id, listed_running)) == 1

def test_retrieve_workflow_execution_detailed(
self,
Expand Down

0 comments on commit 0b6deeb

Please sign in to comment.