Skip to content

Commit

Permalink
feat: Add new fields to dataclass Session
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyzyngeraneo committed Jan 17, 2024
1 parent a34f85f commit 33d3248
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/python/src/armonik/common/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,29 @@ def is_available(self) -> bool:
class Session:
session_id: Optional[str] = None
status: RawSessionStatus = SessionStatus.UNSPECIFIED
client_submission: Optional[bool] = None
worker_submission: Optional[bool] = None
partition_ids: List[str] = field(default_factory=list)
options: Optional[TaskOptions] = None
created_at: Optional[datetime] = None
cancelled_at: Optional[datetime] = None
purged_at: Optional[datetime] = None
deleted_at: Optional[datetime] = None
duration: Optional[timedelta] = None

@classmethod
def from_message(cls, session_raw: SessionRaw) -> "Session":
return cls(
session_id=session_raw.session_id,
status=session_raw.status,
client_submission=session_raw.client_submission,
worker_submission=session_raw.worker_submission,
partition_ids=list(session_raw.partition_ids),
options=TaskOptions.from_message(session_raw.options),
created_at=timestamp_to_datetime(session_raw.created_at),
cancelled_at=timestamp_to_datetime(session_raw.cancelled_at),
purged_at=timestamp_to_datetime(session_raw.purged_at),
deleted_at=timestamp_to_datetime(session_raw.deleted_at),
duration=duration_to_timedelta(session_raw.duration),
)

Expand Down

0 comments on commit 33d3248

Please sign in to comment.