Skip to content

Commit

Permalink
feat: add fetched field
Browse files Browse the repository at this point in the history
  • Loading branch information
qdelamea-aneo committed Feb 8, 2024
1 parent 7ae8910 commit 81593be
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Protos/V1/tasks_common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ message TaskDetailed {
google.protobuf.Timestamp submitted_at = 12; /** The task submission date. */
google.protobuf.Timestamp received_at = 18; /** When the task is received by the agent. */
google.protobuf.Timestamp acquired_at = 19; /** When the task is acquired by the agent. */
google.protobuf.Timestamp started_at = 13; /** The task start date. */
google.protobuf.Timestamp fetched = 26; /** Task data retrevial end date. */
google.protobuf.Timestamp started_at = 25; /** The task start date. */
google.protobuf.Timestamp processed_at = 24; /** The end of task processing date. */
google.protobuf.Timestamp ended_at = 14; /** The task end date. Also used when task failed. */
google.protobuf.Timestamp pod_ttl = 15; /** The pod TTL (Time To Live). */
Expand Down Expand Up @@ -88,6 +89,7 @@ message TaskSummary {
google.protobuf.Timestamp submitted_at = 12; /** The task submission date. */
google.protobuf.Timestamp received_at = 18; /** When the task is received by the agent. */
google.protobuf.Timestamp acquired_at = 19; /** When the task is acquired by the agent. */
google.protobuf.Timestamp fetched = 25; /** Task data retrevial end date. */
google.protobuf.Timestamp started_at = 6; /** The task start date. */
google.protobuf.Timestamp processed_at = 23; /** The end of task processing date. */
google.protobuf.Timestamp ended_at = 7; /** The task end date. Also used when task failed. */
Expand Down
3 changes: 2 additions & 1 deletion Protos/V1/tasks_fields.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ enum TaskSummaryEnumField {
TASK_SUMMARY_ENUM_FIELD_POD_HOSTNAME = 13; /** The hostname of the container running the task. */
TASK_SUMMARY_ENUM_FIELD_RECEIVED_AT = 14; /** When the task is received by the agent. */
TASK_SUMMARY_ENUM_FIELD_ACQUIRED_AT = 15; /** When the task is acquired by the agent. */
TASK_SUMMARY_ENUM_FIELD_PROCESSED_AT = 17; /** When the task is processed by the agent. */
TASK_SUMMARY_ENUM_FIELD_PROCESSED_AT = 19; /** When the task is processed by the agent. */
TASK_SUMMARY_ENUM_FIELD_ERROR = 8; /** The error message. Only set if task have failed. */
TASK_SUMMARY_ENUM_FIELD_FETCHED_AT = 20; /** When task data are fetched by the agent. */
}

/**
Expand Down
18 changes: 12 additions & 6 deletions packages/python/src/armonik/common/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ class Task:
options: Optional[TaskOptions] = None
created_at: Optional[datetime] = None
submitted_at: Optional[datetime] = None
received_at: Optional[datetime] = None
acquired_at: Optional[datetime] = None
fetched_at: Optional[datetime] = None
started_at: Optional[datetime] = None
processed_at: Optional[datetime] = None
ended_at: Optional[datetime] = None
pod_ttl: Optional[datetime] = None
output: Optional[Output] = None
pod_hostname: Optional[str] = None
received_at: Optional[datetime] = None
acquired_at: Optional[datetime] = None

def refresh(self, task_client) -> None:
"""Refresh the fields of this task object by using the given task client
Expand All @@ -135,13 +137,15 @@ def refresh(self, task_client) -> None:
self.options = result.options
self.created_at = result.created_at
self.submitted_at = result.submitted_at
self.received_at = result.received_at
self.acquired_at = result.acquired_at
self.fetched_at = result.fetched_at
self.started_at = result.started_at
self.processed_at = result.processed_at
self.ended_at = result.ended_at
self.pod_ttl = result.pod_ttl
self.output = result.output
self.pod_hostname = result.pod_hostname
self.received_at = result.received_at
self.acquired_at = result.acquired_at
self.is_init = True

@classmethod
Expand All @@ -159,13 +163,15 @@ def from_message(cls, task_raw: TaskDetailed) -> "Task":
options=TaskOptions.from_message(task_raw.options),
created_at=timestamp_to_datetime(task_raw.created_at),
submitted_at=timestamp_to_datetime(task_raw.submitted_at),
received_at=timestamp_to_datetime(task_raw.received_at),
acquired_at=timestamp_to_datetime(task_raw.acquired_at),
fetched_at=timestamp_to_datetime(task_raw.fetched_at),
started_at=timestamp_to_datetime(task_raw.started_at),
processed_at=timestamp_to_datetime(task_raw.processed_at),
ended_at=timestamp_to_datetime(task_raw.ended_at),
pod_ttl=timestamp_to_datetime(task_raw.pod_ttl),
output=Output(error=(task_raw.output.error if not task_raw.output.success else None)),
pod_hostname=task_raw.pod_hostname,
received_at=timestamp_to_datetime(task_raw.received_at),
acquired_at=timestamp_to_datetime(task_raw.acquired_at),
)


Expand Down
6 changes: 4 additions & 2 deletions packages/python/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ class TestArmoniKTasks:
),
created_at=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
submitted_at=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
received_at=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
acquired_at=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
fetched_at=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
started_at=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
processed_at=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
ended_at=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
pod_ttl=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
output=Output(error=""),
pod_hostname="",
received_at=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
acquired_at=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
)

def test_get_task(self):
Expand Down

0 comments on commit 81593be

Please sign in to comment.