mlops-python-sdk 1.0.0__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. mlops/__init__.py +3 -3
  2. mlops/api/client/api/storage/__init__.py +1 -0
  3. mlops/api/client/api/storage/get_storage_presign_download.py +175 -0
  4. mlops/api/client/api/storage/get_storage_presign_upload.py +175 -0
  5. mlops/api/client/api/tasks/cancel_task.py +14 -14
  6. mlops/api/client/api/tasks/delete_task.py +14 -14
  7. mlops/api/client/api/tasks/get_task.py +15 -15
  8. mlops/api/client/api/tasks/get_task_by_task_id.py +204 -0
  9. mlops/api/client/api/tasks/get_task_logs.py +300 -0
  10. mlops/api/client/api/tasks/list_tasks.py +14 -14
  11. mlops/api/client/models/__init__.py +16 -0
  12. mlops/api/client/models/get_storage_presign_download_response_200.py +60 -0
  13. mlops/api/client/models/get_storage_presign_upload_response_200.py +79 -0
  14. mlops/api/client/models/get_task_logs_direction.py +9 -0
  15. mlops/api/client/models/get_task_logs_log_type.py +10 -0
  16. mlops/api/client/models/log_pagination.py +90 -0
  17. mlops/api/client/models/task_log_entry.py +105 -0
  18. mlops/api/client/models/task_log_entry_log_type.py +9 -0
  19. mlops/api/client/models/task_logs_response.py +112 -0
  20. mlops/api/client/models/task_submit_request.py +6 -6
  21. mlops/connection_config.py +0 -7
  22. mlops/exceptions.py +10 -10
  23. mlops/task/__init__.py +1 -1
  24. mlops/task/client.py +11 -35
  25. mlops/task/task.py +152 -34
  26. {mlops_python_sdk-1.0.0.dist-info → mlops_python_sdk-1.0.1.dist-info}/METADATA +3 -12
  27. mlops_python_sdk-1.0.1.dist-info/RECORD +52 -0
  28. mlops_python_sdk-1.0.0.dist-info/RECORD +0 -39
  29. {mlops_python_sdk-1.0.0.dist-info → mlops_python_sdk-1.0.1.dist-info}/WHEEL +0 -0
@@ -18,7 +18,7 @@ def _get_kwargs(
18
18
  status: Union[Unset, TaskStatus] = UNSET,
19
19
  user_id: Union[Unset, int] = UNSET,
20
20
  team_id: Union[Unset, int] = UNSET,
21
- cluster_id: Union[Unset, int] = UNSET,
21
+ cluster_name: Union[Unset, str] = UNSET,
22
22
  ) -> dict[str, Any]:
23
23
  params: dict[str, Any] = {}
24
24
 
@@ -36,7 +36,7 @@ def _get_kwargs(
36
36
 
37
37
  params["team_id"] = team_id
38
38
 
39
- params["cluster_id"] = cluster_id
39
+ params["cluster_name"] = cluster_name
40
40
 
41
41
  params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
42
42
 
@@ -89,7 +89,7 @@ def sync_detailed(
89
89
  status: Union[Unset, TaskStatus] = UNSET,
90
90
  user_id: Union[Unset, int] = UNSET,
91
91
  team_id: Union[Unset, int] = UNSET,
92
- cluster_id: Union[Unset, int] = UNSET,
92
+ cluster_name: Union[Unset, str] = UNSET,
93
93
  ) -> Response[Union[ErrorResponse, TaskListResponse]]:
94
94
  """Get task list
95
95
 
@@ -101,7 +101,7 @@ def sync_detailed(
101
101
  status (Union[Unset, TaskStatus]): Task status Example: pending.
102
102
  user_id (Union[Unset, int]):
103
103
  team_id (Union[Unset, int]):
104
- cluster_id (Union[Unset, int]):
104
+ cluster_name (Union[Unset, str]):
105
105
 
106
106
  Raises:
107
107
  errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -117,7 +117,7 @@ def sync_detailed(
117
117
  status=status,
118
118
  user_id=user_id,
119
119
  team_id=team_id,
120
- cluster_id=cluster_id,
120
+ cluster_name=cluster_name,
121
121
  )
122
122
 
123
123
  response = client.get_httpx_client().request(
@@ -135,7 +135,7 @@ def sync(
135
135
  status: Union[Unset, TaskStatus] = UNSET,
136
136
  user_id: Union[Unset, int] = UNSET,
137
137
  team_id: Union[Unset, int] = UNSET,
138
- cluster_id: Union[Unset, int] = UNSET,
138
+ cluster_name: Union[Unset, str] = UNSET,
139
139
  ) -> Optional[Union[ErrorResponse, TaskListResponse]]:
140
140
  """Get task list
141
141
 
@@ -147,7 +147,7 @@ def sync(
147
147
  status (Union[Unset, TaskStatus]): Task status Example: pending.
148
148
  user_id (Union[Unset, int]):
149
149
  team_id (Union[Unset, int]):
150
- cluster_id (Union[Unset, int]):
150
+ cluster_name (Union[Unset, str]):
151
151
 
152
152
  Raises:
153
153
  errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -164,7 +164,7 @@ def sync(
164
164
  status=status,
165
165
  user_id=user_id,
166
166
  team_id=team_id,
167
- cluster_id=cluster_id,
167
+ cluster_name=cluster_name,
168
168
  ).parsed
169
169
 
170
170
 
@@ -176,7 +176,7 @@ async def asyncio_detailed(
176
176
  status: Union[Unset, TaskStatus] = UNSET,
177
177
  user_id: Union[Unset, int] = UNSET,
178
178
  team_id: Union[Unset, int] = UNSET,
179
- cluster_id: Union[Unset, int] = UNSET,
179
+ cluster_name: Union[Unset, str] = UNSET,
180
180
  ) -> Response[Union[ErrorResponse, TaskListResponse]]:
181
181
  """Get task list
182
182
 
@@ -188,7 +188,7 @@ async def asyncio_detailed(
188
188
  status (Union[Unset, TaskStatus]): Task status Example: pending.
189
189
  user_id (Union[Unset, int]):
190
190
  team_id (Union[Unset, int]):
191
- cluster_id (Union[Unset, int]):
191
+ cluster_name (Union[Unset, str]):
192
192
 
193
193
  Raises:
194
194
  errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -204,7 +204,7 @@ async def asyncio_detailed(
204
204
  status=status,
205
205
  user_id=user_id,
206
206
  team_id=team_id,
207
- cluster_id=cluster_id,
207
+ cluster_name=cluster_name,
208
208
  )
209
209
 
210
210
  response = await client.get_async_httpx_client().request(**kwargs)
@@ -220,7 +220,7 @@ async def asyncio(
220
220
  status: Union[Unset, TaskStatus] = UNSET,
221
221
  user_id: Union[Unset, int] = UNSET,
222
222
  team_id: Union[Unset, int] = UNSET,
223
- cluster_id: Union[Unset, int] = UNSET,
223
+ cluster_name: Union[Unset, str] = UNSET,
224
224
  ) -> Optional[Union[ErrorResponse, TaskListResponse]]:
225
225
  """Get task list
226
226
 
@@ -232,7 +232,7 @@ async def asyncio(
232
232
  status (Union[Unset, TaskStatus]): Task status Example: pending.
233
233
  user_id (Union[Unset, int]):
234
234
  team_id (Union[Unset, int]):
235
- cluster_id (Union[Unset, int]):
235
+ cluster_name (Union[Unset, str]):
236
236
 
237
237
  Raises:
238
238
  errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -250,6 +250,6 @@ async def asyncio(
250
250
  status=status,
251
251
  user_id=user_id,
252
252
  team_id=team_id,
253
- cluster_id=cluster_id,
253
+ cluster_name=cluster_name,
254
254
  )
255
255
  ).parsed
@@ -1,15 +1,23 @@
1
1
  """Contains all the data models used in inputs/outputs"""
2
2
 
3
3
  from .error_response import ErrorResponse
4
+ from .get_storage_presign_download_response_200 import GetStoragePresignDownloadResponse200
5
+ from .get_storage_presign_upload_response_200 import GetStoragePresignUploadResponse200
6
+ from .get_task_logs_direction import GetTaskLogsDirection
7
+ from .get_task_logs_log_type import GetTaskLogsLogType
4
8
  from .job_spec import JobSpec
5
9
  from .job_spec_env import JobSpecEnv
6
10
  from .job_spec_master_strategy import JobSpecMasterStrategy
11
+ from .log_pagination import LogPagination
7
12
  from .message_response import MessageResponse
8
13
  from .task import Task
9
14
  from .task_alloc_tres_type_0 import TaskAllocTresType0
10
15
  from .task_gres_detail_type_0_item import TaskGresDetailType0Item
11
16
  from .task_job_resources_type_0 import TaskJobResourcesType0
12
17
  from .task_list_response import TaskListResponse
18
+ from .task_log_entry import TaskLogEntry
19
+ from .task_log_entry_log_type import TaskLogEntryLogType
20
+ from .task_logs_response import TaskLogsResponse
13
21
  from .task_resources_type_0 import TaskResourcesType0
14
22
  from .task_status import TaskStatus
15
23
  from .task_submit_request import TaskSubmitRequest
@@ -20,15 +28,23 @@ from .task_tres_used_type_0 import TaskTresUsedType0
20
28
 
21
29
  __all__ = (
22
30
  "ErrorResponse",
31
+ "GetStoragePresignDownloadResponse200",
32
+ "GetStoragePresignUploadResponse200",
33
+ "GetTaskLogsDirection",
34
+ "GetTaskLogsLogType",
23
35
  "JobSpec",
24
36
  "JobSpecEnv",
25
37
  "JobSpecMasterStrategy",
38
+ "LogPagination",
26
39
  "MessageResponse",
27
40
  "Task",
28
41
  "TaskAllocTresType0",
29
42
  "TaskGresDetailType0Item",
30
43
  "TaskJobResourcesType0",
31
44
  "TaskListResponse",
45
+ "TaskLogEntry",
46
+ "TaskLogEntryLogType",
47
+ "TaskLogsResponse",
32
48
  "TaskResourcesType0",
33
49
  "TaskStatus",
34
50
  "TaskSubmitRequest",
@@ -0,0 +1,60 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar, Union
3
+
4
+ from attrs import define as _attrs_define
5
+ from attrs import field as _attrs_field
6
+
7
+ from ..types import UNSET, Unset
8
+
9
+ T = TypeVar("T", bound="GetStoragePresignDownloadResponse200")
10
+
11
+
12
+ @_attrs_define
13
+ class GetStoragePresignDownloadResponse200:
14
+ """
15
+ Attributes:
16
+ url (Union[Unset, str]): The presigned URL for downloading the file Example:
17
+ https://s3.example.com/bucket/uploads/20230101/123000_1234_test.zip?signature=....
18
+ """
19
+
20
+ url: Union[Unset, str] = UNSET
21
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
22
+
23
+ def to_dict(self) -> dict[str, Any]:
24
+ url = self.url
25
+
26
+ field_dict: dict[str, Any] = {}
27
+ field_dict.update(self.additional_properties)
28
+ field_dict.update({})
29
+ if url is not UNSET:
30
+ field_dict["url"] = url
31
+
32
+ return field_dict
33
+
34
+ @classmethod
35
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
36
+ d = dict(src_dict)
37
+ url = d.pop("url", UNSET)
38
+
39
+ get_storage_presign_download_response_200 = cls(
40
+ url=url,
41
+ )
42
+
43
+ get_storage_presign_download_response_200.additional_properties = d
44
+ return get_storage_presign_download_response_200
45
+
46
+ @property
47
+ def additional_keys(self) -> list[str]:
48
+ return list(self.additional_properties.keys())
49
+
50
+ def __getitem__(self, key: str) -> Any:
51
+ return self.additional_properties[key]
52
+
53
+ def __setitem__(self, key: str, value: Any) -> None:
54
+ self.additional_properties[key] = value
55
+
56
+ def __delitem__(self, key: str) -> None:
57
+ del self.additional_properties[key]
58
+
59
+ def __contains__(self, key: str) -> bool:
60
+ return key in self.additional_properties
@@ -0,0 +1,79 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar, Union
3
+
4
+ from attrs import define as _attrs_define
5
+ from attrs import field as _attrs_field
6
+
7
+ from ..types import UNSET, Unset
8
+
9
+ T = TypeVar("T", bound="GetStoragePresignUploadResponse200")
10
+
11
+
12
+ @_attrs_define
13
+ class GetStoragePresignUploadResponse200:
14
+ """
15
+ Attributes:
16
+ key (Union[Unset, str]): Object key Example: uploads/20230101/123000_1234_test.zip.
17
+ s3_url (Union[Unset, str]): S3 URL (s3://bucket/key) in S3 Example: s3://my-
18
+ bucket/uploads/20230101/123000_1234_test.zip.
19
+ url (Union[Unset, str]): The presigned URL for uploading the file Example:
20
+ https://s3.example.com/bucket/uploads/20230101/123000_1234_test.zip?signature=....
21
+ """
22
+
23
+ key: Union[Unset, str] = UNSET
24
+ s3_url: Union[Unset, str] = UNSET
25
+ url: Union[Unset, str] = UNSET
26
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
27
+
28
+ def to_dict(self) -> dict[str, Any]:
29
+ key = self.key
30
+
31
+ s3_url = self.s3_url
32
+
33
+ url = self.url
34
+
35
+ field_dict: dict[str, Any] = {}
36
+ field_dict.update(self.additional_properties)
37
+ field_dict.update({})
38
+ if key is not UNSET:
39
+ field_dict["key"] = key
40
+ if s3_url is not UNSET:
41
+ field_dict["s3_url"] = s3_url
42
+ if url is not UNSET:
43
+ field_dict["url"] = url
44
+
45
+ return field_dict
46
+
47
+ @classmethod
48
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
49
+ d = dict(src_dict)
50
+ key = d.pop("key", UNSET)
51
+
52
+ s3_url = d.pop("s3_url", UNSET)
53
+
54
+ url = d.pop("url", UNSET)
55
+
56
+ get_storage_presign_upload_response_200 = cls(
57
+ key=key,
58
+ s3_url=s3_url,
59
+ url=url,
60
+ )
61
+
62
+ get_storage_presign_upload_response_200.additional_properties = d
63
+ return get_storage_presign_upload_response_200
64
+
65
+ @property
66
+ def additional_keys(self) -> list[str]:
67
+ return list(self.additional_properties.keys())
68
+
69
+ def __getitem__(self, key: str) -> Any:
70
+ return self.additional_properties[key]
71
+
72
+ def __setitem__(self, key: str, value: Any) -> None:
73
+ self.additional_properties[key] = value
74
+
75
+ def __delitem__(self, key: str) -> None:
76
+ del self.additional_properties[key]
77
+
78
+ def __contains__(self, key: str) -> bool:
79
+ return key in self.additional_properties
@@ -0,0 +1,9 @@
1
+ from enum import Enum
2
+
3
+
4
+ class GetTaskLogsDirection(str, Enum):
5
+ BACKWARD = "backward"
6
+ FORWARD = "forward"
7
+
8
+ def __str__(self) -> str:
9
+ return str(self.value)
@@ -0,0 +1,10 @@
1
+ from enum import Enum
2
+
3
+
4
+ class GetTaskLogsLogType(str, Enum):
5
+ ALL = "all"
6
+ STDERR = "stderr"
7
+ STDOUT = "stdout"
8
+
9
+ def __str__(self) -> str:
10
+ return str(self.value)
@@ -0,0 +1,90 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar, Union, cast
3
+
4
+ from attrs import define as _attrs_define
5
+ from attrs import field as _attrs_field
6
+
7
+ from ..types import UNSET, Unset
8
+
9
+ T = TypeVar("T", bound="LogPagination")
10
+
11
+
12
+ @_attrs_define
13
+ class LogPagination:
14
+ """Pagination information for logs
15
+
16
+ Attributes:
17
+ has_more (Union[Unset, bool]): Whether there are more logs available Example: True.
18
+ next_cursor (Union[None, Unset, str]): Cursor for the next page (timestamp in nanoseconds) Example:
19
+ 1706612400123456789.
20
+ total_fetched (Union[Unset, int]): Number of log entries fetched in this request Example: 1000.
21
+ """
22
+
23
+ has_more: Union[Unset, bool] = UNSET
24
+ next_cursor: Union[None, Unset, str] = UNSET
25
+ total_fetched: Union[Unset, int] = UNSET
26
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
27
+
28
+ def to_dict(self) -> dict[str, Any]:
29
+ has_more = self.has_more
30
+
31
+ next_cursor: Union[None, Unset, str]
32
+ if isinstance(self.next_cursor, Unset):
33
+ next_cursor = UNSET
34
+ else:
35
+ next_cursor = self.next_cursor
36
+
37
+ total_fetched = self.total_fetched
38
+
39
+ field_dict: dict[str, Any] = {}
40
+ field_dict.update(self.additional_properties)
41
+ field_dict.update({})
42
+ if has_more is not UNSET:
43
+ field_dict["has_more"] = has_more
44
+ if next_cursor is not UNSET:
45
+ field_dict["next_cursor"] = next_cursor
46
+ if total_fetched is not UNSET:
47
+ field_dict["total_fetched"] = total_fetched
48
+
49
+ return field_dict
50
+
51
+ @classmethod
52
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
53
+ d = dict(src_dict)
54
+ has_more = d.pop("has_more", UNSET)
55
+
56
+ def _parse_next_cursor(data: object) -> Union[None, Unset, str]:
57
+ if data is None:
58
+ return data
59
+ if isinstance(data, Unset):
60
+ return data
61
+ return cast(Union[None, Unset, str], data)
62
+
63
+ next_cursor = _parse_next_cursor(d.pop("next_cursor", UNSET))
64
+
65
+ total_fetched = d.pop("total_fetched", UNSET)
66
+
67
+ log_pagination = cls(
68
+ has_more=has_more,
69
+ next_cursor=next_cursor,
70
+ total_fetched=total_fetched,
71
+ )
72
+
73
+ log_pagination.additional_properties = d
74
+ return log_pagination
75
+
76
+ @property
77
+ def additional_keys(self) -> list[str]:
78
+ return list(self.additional_properties.keys())
79
+
80
+ def __getitem__(self, key: str) -> Any:
81
+ return self.additional_properties[key]
82
+
83
+ def __setitem__(self, key: str, value: Any) -> None:
84
+ self.additional_properties[key] = value
85
+
86
+ def __delitem__(self, key: str) -> None:
87
+ del self.additional_properties[key]
88
+
89
+ def __contains__(self, key: str) -> bool:
90
+ return key in self.additional_properties
@@ -0,0 +1,105 @@
1
+ import datetime
2
+ from collections.abc import Mapping
3
+ from typing import Any, TypeVar, Union
4
+
5
+ from attrs import define as _attrs_define
6
+ from attrs import field as _attrs_field
7
+ from dateutil.parser import isoparse
8
+
9
+ from ..models.task_log_entry_log_type import TaskLogEntryLogType
10
+ from ..types import UNSET, Unset
11
+
12
+ T = TypeVar("T", bound="TaskLogEntry")
13
+
14
+
15
+ @_attrs_define
16
+ class TaskLogEntry:
17
+ """A single log entry
18
+
19
+ Attributes:
20
+ content (Union[Unset, str]): Log line content Example: Training epoch 1/100....
21
+ log_type (Union[Unset, TaskLogEntryLogType]): Log type (stdout or stderr) Example: stdout.
22
+ node (Union[Unset, str]): Node hostname where the log was generated Example: compute-node-01.
23
+ timestamp (Union[Unset, datetime.datetime]): Log timestamp in RFC3339 format Example:
24
+ 2024-01-30T10:30:00.123456789Z.
25
+ """
26
+
27
+ content: Union[Unset, str] = UNSET
28
+ log_type: Union[Unset, TaskLogEntryLogType] = UNSET
29
+ node: Union[Unset, str] = UNSET
30
+ timestamp: Union[Unset, datetime.datetime] = UNSET
31
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
32
+
33
+ def to_dict(self) -> dict[str, Any]:
34
+ content = self.content
35
+
36
+ log_type: Union[Unset, str] = UNSET
37
+ if not isinstance(self.log_type, Unset):
38
+ log_type = self.log_type.value
39
+
40
+ node = self.node
41
+
42
+ timestamp: Union[Unset, str] = UNSET
43
+ if not isinstance(self.timestamp, Unset):
44
+ timestamp = self.timestamp.isoformat()
45
+
46
+ field_dict: dict[str, Any] = {}
47
+ field_dict.update(self.additional_properties)
48
+ field_dict.update({})
49
+ if content is not UNSET:
50
+ field_dict["content"] = content
51
+ if log_type is not UNSET:
52
+ field_dict["log_type"] = log_type
53
+ if node is not UNSET:
54
+ field_dict["node"] = node
55
+ if timestamp is not UNSET:
56
+ field_dict["timestamp"] = timestamp
57
+
58
+ return field_dict
59
+
60
+ @classmethod
61
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
62
+ d = dict(src_dict)
63
+ content = d.pop("content", UNSET)
64
+
65
+ _log_type = d.pop("log_type", UNSET)
66
+ log_type: Union[Unset, TaskLogEntryLogType]
67
+ if isinstance(_log_type, Unset):
68
+ log_type = UNSET
69
+ else:
70
+ log_type = TaskLogEntryLogType(_log_type)
71
+
72
+ node = d.pop("node", UNSET)
73
+
74
+ _timestamp = d.pop("timestamp", UNSET)
75
+ timestamp: Union[Unset, datetime.datetime]
76
+ if isinstance(_timestamp, Unset):
77
+ timestamp = UNSET
78
+ else:
79
+ timestamp = isoparse(_timestamp)
80
+
81
+ task_log_entry = cls(
82
+ content=content,
83
+ log_type=log_type,
84
+ node=node,
85
+ timestamp=timestamp,
86
+ )
87
+
88
+ task_log_entry.additional_properties = d
89
+ return task_log_entry
90
+
91
+ @property
92
+ def additional_keys(self) -> list[str]:
93
+ return list(self.additional_properties.keys())
94
+
95
+ def __getitem__(self, key: str) -> Any:
96
+ return self.additional_properties[key]
97
+
98
+ def __setitem__(self, key: str, value: Any) -> None:
99
+ self.additional_properties[key] = value
100
+
101
+ def __delitem__(self, key: str) -> None:
102
+ del self.additional_properties[key]
103
+
104
+ def __contains__(self, key: str) -> bool:
105
+ return key in self.additional_properties
@@ -0,0 +1,9 @@
1
+ from enum import Enum
2
+
3
+
4
+ class TaskLogEntryLogType(str, Enum):
5
+ STDERR = "stderr"
6
+ STDOUT = "stdout"
7
+
8
+ def __str__(self) -> str:
9
+ return str(self.value)
@@ -0,0 +1,112 @@
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, Any, TypeVar, Union
3
+
4
+ from attrs import define as _attrs_define
5
+ from attrs import field as _attrs_field
6
+
7
+ from ..types import UNSET, Unset
8
+
9
+ if TYPE_CHECKING:
10
+ from ..models.log_pagination import LogPagination
11
+ from ..models.task_log_entry import TaskLogEntry
12
+
13
+
14
+ T = TypeVar("T", bound="TaskLogsResponse")
15
+
16
+
17
+ @_attrs_define
18
+ class TaskLogsResponse:
19
+ """Task logs response with pagination support
20
+
21
+ Attributes:
22
+ cluster_id (Union[Unset, int]): Cluster ID Example: 1.
23
+ job_id (Union[Unset, int]): Slurm Job ID Example: 12345.
24
+ logs (Union[Unset, list['TaskLogEntry']]): List of log entries
25
+ pagination (Union[Unset, LogPagination]): Pagination information for logs
26
+ """
27
+
28
+ cluster_id: Union[Unset, int] = UNSET
29
+ job_id: Union[Unset, int] = UNSET
30
+ logs: Union[Unset, list["TaskLogEntry"]] = UNSET
31
+ pagination: Union[Unset, "LogPagination"] = UNSET
32
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
33
+
34
+ def to_dict(self) -> dict[str, Any]:
35
+ cluster_id = self.cluster_id
36
+
37
+ job_id = self.job_id
38
+
39
+ logs: Union[Unset, list[dict[str, Any]]] = UNSET
40
+ if not isinstance(self.logs, Unset):
41
+ logs = []
42
+ for logs_item_data in self.logs:
43
+ logs_item = logs_item_data.to_dict()
44
+ logs.append(logs_item)
45
+
46
+ pagination: Union[Unset, dict[str, Any]] = UNSET
47
+ if not isinstance(self.pagination, Unset):
48
+ pagination = self.pagination.to_dict()
49
+
50
+ field_dict: dict[str, Any] = {}
51
+ field_dict.update(self.additional_properties)
52
+ field_dict.update({})
53
+ if cluster_id is not UNSET:
54
+ field_dict["cluster_id"] = cluster_id
55
+ if job_id is not UNSET:
56
+ field_dict["job_id"] = job_id
57
+ if logs is not UNSET:
58
+ field_dict["logs"] = logs
59
+ if pagination is not UNSET:
60
+ field_dict["pagination"] = pagination
61
+
62
+ return field_dict
63
+
64
+ @classmethod
65
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
66
+ from ..models.log_pagination import LogPagination
67
+ from ..models.task_log_entry import TaskLogEntry
68
+
69
+ d = dict(src_dict)
70
+ cluster_id = d.pop("cluster_id", UNSET)
71
+
72
+ job_id = d.pop("job_id", UNSET)
73
+
74
+ logs = []
75
+ _logs = d.pop("logs", UNSET)
76
+ for logs_item_data in _logs or []:
77
+ logs_item = TaskLogEntry.from_dict(logs_item_data)
78
+
79
+ logs.append(logs_item)
80
+
81
+ _pagination = d.pop("pagination", UNSET)
82
+ pagination: Union[Unset, LogPagination]
83
+ if isinstance(_pagination, Unset):
84
+ pagination = UNSET
85
+ else:
86
+ pagination = LogPagination.from_dict(_pagination)
87
+
88
+ task_logs_response = cls(
89
+ cluster_id=cluster_id,
90
+ job_id=job_id,
91
+ logs=logs,
92
+ pagination=pagination,
93
+ )
94
+
95
+ task_logs_response.additional_properties = d
96
+ return task_logs_response
97
+
98
+ @property
99
+ def additional_keys(self) -> list[str]:
100
+ return list(self.additional_properties.keys())
101
+
102
+ def __getitem__(self, key: str) -> Any:
103
+ return self.additional_properties[key]
104
+
105
+ def __setitem__(self, key: str, value: Any) -> None:
106
+ self.additional_properties[key] = value
107
+
108
+ def __delitem__(self, key: str) -> None:
109
+ del self.additional_properties[key]
110
+
111
+ def __contains__(self, key: str) -> bool:
112
+ return key in self.additional_properties