From f603118e2d2b1c7c1f9263734a46c475374cbe62 Mon Sep 17 00:00:00 2001 From: ereali-aneo Date: Thu, 29 Aug 2024 15:16:04 +0200 Subject: [PATCH] feat: add CreatedBy in result and task python API --- .../python/src/armonik/common/filter/_filter_field.py | 4 ++++ packages/python/src/armonik/common/objects.py | 10 ++++++++++ packages/python/tests/test_tasks.py | 1 + 3 files changed, 15 insertions(+) diff --git a/packages/python/src/armonik/common/filter/_filter_field.py b/packages/python/src/armonik/common/filter/_filter_field.py index 87e4dc053..8a8427cd7 100644 --- a/packages/python/src/armonik/common/filter/_filter_field.py +++ b/packages/python/src/armonik/common/filter/_filter_field.py @@ -14,6 +14,7 @@ TASK_SUMMARY_ENUM_FIELD_SESSION_ID, TASK_SUMMARY_ENUM_FIELD_OWNER_POD_ID, TASK_SUMMARY_ENUM_FIELD_INITIAL_TASK_ID, + TASK_SUMMARY_ENUM_FIELD_CREATED_BY, TASK_SUMMARY_ENUM_FIELD_STATUS, TASK_SUMMARY_ENUM_FIELD_CREATED_AT, TASK_SUMMARY_ENUM_FIELD_SUBMITTED_AT, @@ -78,6 +79,7 @@ RESULT_RAW_ENUM_FIELD_COMPLETED_AT, RESULT_RAW_ENUM_FIELD_CREATED_AT, RESULT_RAW_ENUM_FIELD_SESSION_ID, + RESULT_RAW_ENUM_FIELD_CREATED_BY, RESULT_RAW_ENUM_FIELD_OWNER_TASK_ID, ) @@ -207,6 +209,7 @@ class TaskFilter(FilterWrapper): "session_id": (FType.STR, TASK_SUMMARY_ENUM_FIELD_SESSION_ID), "owner_pod_id": (FType.STR, TASK_SUMMARY_ENUM_FIELD_OWNER_POD_ID), "initial_task_id": (FType.STR, TASK_SUMMARY_ENUM_FIELD_INITIAL_TASK_ID), + "created_by": (FType.STR, TASK_SUMMARY_ENUM_FIELD_CREATED_BY), "parent_task_ids": (FType.NA, "parent_task_ids"), "data_dependencies": (FType.NA, "data_dependencies"), "expected_output_ids": (FType.NA, "expected_output_ids"), @@ -333,6 +336,7 @@ class ResultFilter(FilterWrapper): "completed_at": (FType.DATE, RESULT_RAW_ENUM_FIELD_COMPLETED_AT), "result_id": (FType.STR, RESULT_RAW_ENUM_FIELD_RESULT_ID), "size": (FType.NUM, RESULT_RAW_ENUM_FIELD_SIZE), + "created_by": (FType.STR, RESULT_RAW_ENUM_FIELD_CREATED_BY), "owner_task_id": (FType.STR, RESULT_RAW_ENUM_FIELD_OWNER_TASK_ID), } diff --git a/packages/python/src/armonik/common/objects.py b/packages/python/src/armonik/common/objects.py index a7ca8bda4..5b1ae3572 100644 --- a/packages/python/src/armonik/common/objects.py +++ b/packages/python/src/armonik/common/objects.py @@ -135,6 +135,7 @@ class Task: owner_pod_id = FilterDescriptor(_task_filter) initial_task_id = FilterDescriptor(_task_filter) + created_by = FilterDescriptor(_task_filter) parent_task_ids = FilterDescriptor(_task_filter) data_dependencies = FilterDescriptor(_task_filter) expected_output_ids = FilterDescriptor(_task_filter) @@ -169,6 +170,7 @@ def __init__( session_id: Optional[str] = None, owner_pod_id: Optional[str] = None, initial_task_id: Optional[str] = None, + created_by: Optional[str] = None, parent_task_ids: Optional[List[str]] = None, data_dependencies: Optional[List[str]] = None, expected_output_ids: Optional[List[str]] = None, @@ -196,6 +198,7 @@ def __init__( self.session_id = session_id self.owner_pod_id = owner_pod_id self.initial_task_id = initial_task_id + self.created_by = created_by self.parent_task_ids = parent_task_ids if parent_task_ids is not None else [] self.data_dependencies = data_dependencies if data_dependencies is not None else [] self.expected_output_ids = expected_output_ids if expected_output_ids is not None else [] @@ -230,6 +233,7 @@ def refresh(self, task_client) -> None: self.owner_pod_id = result.owner_pod_id self.initial_task_id = result.initial_task_id + self.created_by = result.created_by self.parent_task_ids = result.parent_task_ids self.data_dependencies = result.data_dependencies self.expected_output_ids = result.expected_output_ids @@ -266,6 +270,7 @@ def from_message(cls, task_raw: TaskDetailed) -> "Task": session_id=task_raw.session_id, owner_pod_id=task_raw.owner_pod_id, initial_task_id=task_raw.initial_task_id, + created_by=task_raw.created_by, parent_task_ids=list(task_raw.parent_task_ids), data_dependencies=list(task_raw.data_dependencies), expected_output_ids=list(task_raw.expected_output_ids), @@ -296,6 +301,7 @@ def __eq__(self, other: "Task") -> bool: and self.session_id == other.session_id and self.owner_pod_id == other.owner_pod_id and self.initial_task_id == other.initial_task_id + and self.created_by == other.created_by and self.parent_task_ids == other.parent_task_ids and self.data_dependencies == other.data_dependencies and self.expected_output_ids == other.expected_output_ids @@ -415,6 +421,7 @@ def __eq__(self, other: "Session") -> bool: class Result: session_id = FilterDescriptor(_resultFilter) name = FilterDescriptor(_resultFilter) + created_by = FilterDescriptor(_resultFilter) owner_task_id = FilterDescriptor(_resultFilter) status = FilterDescriptor(_resultFilter) created_at = FilterDescriptor(_resultFilter) @@ -426,6 +433,7 @@ def __init__( self, session_id: Optional[str] = None, name: Optional[str] = None, + created_by: Optional[str] = None, owner_task_id: Optional[str] = None, status: RawResultStatus = ResultStatus.UNSPECIFIED, created_at: Optional[datetime] = None, @@ -435,6 +443,7 @@ def __init__( ): self.session_id = session_id self.name = name + self.created_by = created_by self.owner_task_id = owner_task_id self.status = status self.created_at = created_at @@ -447,6 +456,7 @@ def from_message(cls, result_raw: ResultRaw) -> "Result": return cls( session_id=result_raw.session_id, name=result_raw.name, + created_by=result_raw.created_by, owner_task_id=result_raw.owner_task_id, status=result_raw.status, created_at=timestamp_to_datetime(result_raw.created_at), diff --git a/packages/python/tests/test_tasks.py b/packages/python/tests/test_tasks.py index 383fee529..0711cecf5 100644 --- a/packages/python/tests/test_tasks.py +++ b/packages/python/tests/test_tasks.py @@ -11,6 +11,7 @@ class TestArmoniKTasks: session_id="session-id", owner_pod_id="", initial_task_id="", + created_by="", parent_task_ids=[], data_dependencies=[], expected_output_ids=[],