Skip to content

Commit

Permalink
Execution cancellation dead code clean up (#1753)
Browse files Browse the repository at this point in the history
Dead code cleanups
  • Loading branch information
VerstraeteBert committed May 6, 2024
1 parent 0632f98 commit 3da9fe2
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 39 deletions.
2 changes: 0 additions & 2 deletions cognite/client/_api/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ def cancel(self, id: str, reason: str | None) -> WorkflowExecution:
Trigger a workflow execution for the workflow "foo", version 1 and cancel it:
>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes import CancelExecution
>>> client = CogniteClient()
>>> res = client.workflows.executions.trigger("foo", "1")
>>> client.workflows.executions.cancel(id="foo", reason="test cancelation")
Expand Down Expand Up @@ -311,7 +310,6 @@ def retry(self, id: str, client_credentials: ClientCredentials | None = None) ->
Retry a workflow execution that has been cancelled or failed:
>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes import CancelExecution
>>> client = CogniteClient()
>>> res = client.workflows.executions.trigger("foo", "1")
>>> client.workflows.executions.cancel(id=res.id, reason="test cancellation")
Expand Down
2 changes: 0 additions & 2 deletions cognite/client/data_classes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@
)
from cognite.client.data_classes.user_profiles import UserProfile, UserProfileList
from cognite.client.data_classes.workflows import (
CancelExecution,
CDFTaskOutput,
CDFTaskParameters,
DynamicTaskOutput,
Expand Down Expand Up @@ -541,7 +540,6 @@
"CoordinateReferenceSystem",
"UserProfile",
"UserProfileList",
"CancelExecution",
"WorkflowUpsert",
"WorkflowExecution",
"WorkflowExecutionDetailed",
Expand Down
35 changes: 0 additions & 35 deletions cognite/client/data_classes/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,38 +1173,3 @@ def load(cls, resource: Any, cognite_client: CogniteClient | None = None) -> Wor

def dump(self, camel_case: bool = True, as_external_id: bool = False) -> list[dict[str, Any]]:
return [workflow_id.dump(camel_case, as_external_id_key=as_external_id) for workflow_id in self.data]


@dataclass(frozen=True)
class CancelExecution:
"""
This class represents a Workflow Version Identifier.
Args:
workflow_external_id (str): The external ID of the workflow.
version (str, optional): The version of the workflow. Defaults to None.
"""

id: str
reason: str | None = None

def as_primitive(self) -> tuple[str, str | None]:
return self.id, self.reason

@classmethod
def load(cls, resource: dict, cognite_client: CogniteClient | None = None) -> CancelExecution:
if "id" in resource:
execution_id = resource["id"]
else:
raise ValueError("Invalid input to WorkflowVersionId.load")

return cls(
id=execution_id,
reason=resource.get("reason"),
)

def dump(self, camel_case: bool = True) -> dict[str, Any]:
output = {"id": self.id}
if self.reason:
output["reason"] = self.reason
return output

0 comments on commit 3da9fe2

Please sign in to comment.