Skip to content

Commit

Permalink
feat: add CreatedBy in result and task python API
Browse files Browse the repository at this point in the history
  • Loading branch information
ereali-aneo committed Aug 29, 2024
1 parent 9b51d00 commit f603118
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/python/src/armonik/common/filter/_filter_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)

Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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),
}

Expand Down
10 changes: 10 additions & 0 deletions packages/python/src/armonik/common/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 []
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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),
Expand Down
1 change: 1 addition & 0 deletions packages/python/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
Expand Down

0 comments on commit f603118

Please sign in to comment.