mlops-python-sdk 0.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 (36) hide show
  1. mlops/__init__.py +46 -0
  2. mlops/api/client/__init__.py +8 -0
  3. mlops/api/client/api/__init__.py +1 -0
  4. mlops/api/client/api/tasks/__init__.py +1 -0
  5. mlops/api/client/api/tasks/cancel_task.py +196 -0
  6. mlops/api/client/api/tasks/delete_task.py +204 -0
  7. mlops/api/client/api/tasks/get_task.py +196 -0
  8. mlops/api/client/api/tasks/list_tasks.py +255 -0
  9. mlops/api/client/api/tasks/submit_task.py +188 -0
  10. mlops/api/client/client.py +268 -0
  11. mlops/api/client/errors.py +16 -0
  12. mlops/api/client/models/__init__.py +33 -0
  13. mlops/api/client/models/error_response.py +68 -0
  14. mlops/api/client/models/message_response.py +59 -0
  15. mlops/api/client/models/task.py +1629 -0
  16. mlops/api/client/models/task_alloc_tres_type_0.py +49 -0
  17. mlops/api/client/models/task_gres_detail_type_0_item.py +44 -0
  18. mlops/api/client/models/task_job_resources_type_0.py +49 -0
  19. mlops/api/client/models/task_list_response.py +102 -0
  20. mlops/api/client/models/task_resources_type_0.py +49 -0
  21. mlops/api/client/models/task_status.py +15 -0
  22. mlops/api/client/models/task_submit_request.py +640 -0
  23. mlops/api/client/models/task_submit_request_environment_type_0.py +49 -0
  24. mlops/api/client/models/task_submit_response.py +78 -0
  25. mlops/api/client/models/task_tres_type_0.py +49 -0
  26. mlops/api/client/models/task_tres_used_type_0.py +49 -0
  27. mlops/api/client/py.typed +1 -0
  28. mlops/api/client/types.py +54 -0
  29. mlops/connection_config.py +106 -0
  30. mlops/exceptions.py +82 -0
  31. mlops/task/__init__.py +10 -0
  32. mlops/task/client.py +146 -0
  33. mlops/task/task.py +464 -0
  34. mlops_python_sdk-0.0.1.dist-info/METADATA +416 -0
  35. mlops_python_sdk-0.0.1.dist-info/RECORD +36 -0
  36. mlops_python_sdk-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,255 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.error_response import ErrorResponse
9
+ from ...models.task_list_response import TaskListResponse
10
+ from ...models.task_status import TaskStatus
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ page: Union[Unset, int] = 1,
17
+ page_size: Union[Unset, int] = 20,
18
+ status: Union[Unset, TaskStatus] = UNSET,
19
+ user_id: Union[Unset, int] = UNSET,
20
+ team_id: Union[Unset, int] = UNSET,
21
+ cluster_id: Union[Unset, int] = UNSET,
22
+ ) -> dict[str, Any]:
23
+ params: dict[str, Any] = {}
24
+
25
+ params["page"] = page
26
+
27
+ params["page_size"] = page_size
28
+
29
+ json_status: Union[Unset, str] = UNSET
30
+ if not isinstance(status, Unset):
31
+ json_status = status.value
32
+
33
+ params["status"] = json_status
34
+
35
+ params["user_id"] = user_id
36
+
37
+ params["team_id"] = team_id
38
+
39
+ params["cluster_id"] = cluster_id
40
+
41
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
42
+
43
+ _kwargs: dict[str, Any] = {
44
+ "method": "get",
45
+ "url": "/tasks",
46
+ "params": params,
47
+ }
48
+
49
+ return _kwargs
50
+
51
+
52
+ def _parse_response(
53
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
54
+ ) -> Optional[Union[ErrorResponse, TaskListResponse]]:
55
+ if response.status_code == 200:
56
+ response_200 = TaskListResponse.from_dict(response.json())
57
+
58
+ return response_200
59
+ if response.status_code == 401:
60
+ response_401 = ErrorResponse.from_dict(response.json())
61
+
62
+ return response_401
63
+ if response.status_code == 500:
64
+ response_500 = ErrorResponse.from_dict(response.json())
65
+
66
+ return response_500
67
+ if client.raise_on_unexpected_status:
68
+ raise errors.UnexpectedStatus(response.status_code, response.content)
69
+ else:
70
+ return None
71
+
72
+
73
+ def _build_response(
74
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
75
+ ) -> Response[Union[ErrorResponse, TaskListResponse]]:
76
+ return Response(
77
+ status_code=HTTPStatus(response.status_code),
78
+ content=response.content,
79
+ headers=response.headers,
80
+ parsed=_parse_response(client=client, response=response),
81
+ )
82
+
83
+
84
+ def sync_detailed(
85
+ *,
86
+ client: AuthenticatedClient,
87
+ page: Union[Unset, int] = 1,
88
+ page_size: Union[Unset, int] = 20,
89
+ status: Union[Unset, TaskStatus] = UNSET,
90
+ user_id: Union[Unset, int] = UNSET,
91
+ team_id: Union[Unset, int] = UNSET,
92
+ cluster_id: Union[Unset, int] = UNSET,
93
+ ) -> Response[Union[ErrorResponse, TaskListResponse]]:
94
+ """Get task list
95
+
96
+ Get task list with pagination and filtering support
97
+
98
+ Args:
99
+ page (Union[Unset, int]): Default: 1.
100
+ page_size (Union[Unset, int]): Default: 20.
101
+ status (Union[Unset, TaskStatus]): Task status Example: pending.
102
+ user_id (Union[Unset, int]):
103
+ team_id (Union[Unset, int]):
104
+ cluster_id (Union[Unset, int]):
105
+
106
+ Raises:
107
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
108
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
109
+
110
+ Returns:
111
+ Response[Union[ErrorResponse, TaskListResponse]]
112
+ """
113
+
114
+ kwargs = _get_kwargs(
115
+ page=page,
116
+ page_size=page_size,
117
+ status=status,
118
+ user_id=user_id,
119
+ team_id=team_id,
120
+ cluster_id=cluster_id,
121
+ )
122
+
123
+ response = client.get_httpx_client().request(
124
+ **kwargs,
125
+ )
126
+
127
+ return _build_response(client=client, response=response)
128
+
129
+
130
+ def sync(
131
+ *,
132
+ client: AuthenticatedClient,
133
+ page: Union[Unset, int] = 1,
134
+ page_size: Union[Unset, int] = 20,
135
+ status: Union[Unset, TaskStatus] = UNSET,
136
+ user_id: Union[Unset, int] = UNSET,
137
+ team_id: Union[Unset, int] = UNSET,
138
+ cluster_id: Union[Unset, int] = UNSET,
139
+ ) -> Optional[Union[ErrorResponse, TaskListResponse]]:
140
+ """Get task list
141
+
142
+ Get task list with pagination and filtering support
143
+
144
+ Args:
145
+ page (Union[Unset, int]): Default: 1.
146
+ page_size (Union[Unset, int]): Default: 20.
147
+ status (Union[Unset, TaskStatus]): Task status Example: pending.
148
+ user_id (Union[Unset, int]):
149
+ team_id (Union[Unset, int]):
150
+ cluster_id (Union[Unset, int]):
151
+
152
+ Raises:
153
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
154
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
155
+
156
+ Returns:
157
+ Union[ErrorResponse, TaskListResponse]
158
+ """
159
+
160
+ return sync_detailed(
161
+ client=client,
162
+ page=page,
163
+ page_size=page_size,
164
+ status=status,
165
+ user_id=user_id,
166
+ team_id=team_id,
167
+ cluster_id=cluster_id,
168
+ ).parsed
169
+
170
+
171
+ async def asyncio_detailed(
172
+ *,
173
+ client: AuthenticatedClient,
174
+ page: Union[Unset, int] = 1,
175
+ page_size: Union[Unset, int] = 20,
176
+ status: Union[Unset, TaskStatus] = UNSET,
177
+ user_id: Union[Unset, int] = UNSET,
178
+ team_id: Union[Unset, int] = UNSET,
179
+ cluster_id: Union[Unset, int] = UNSET,
180
+ ) -> Response[Union[ErrorResponse, TaskListResponse]]:
181
+ """Get task list
182
+
183
+ Get task list with pagination and filtering support
184
+
185
+ Args:
186
+ page (Union[Unset, int]): Default: 1.
187
+ page_size (Union[Unset, int]): Default: 20.
188
+ status (Union[Unset, TaskStatus]): Task status Example: pending.
189
+ user_id (Union[Unset, int]):
190
+ team_id (Union[Unset, int]):
191
+ cluster_id (Union[Unset, int]):
192
+
193
+ Raises:
194
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
195
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
196
+
197
+ Returns:
198
+ Response[Union[ErrorResponse, TaskListResponse]]
199
+ """
200
+
201
+ kwargs = _get_kwargs(
202
+ page=page,
203
+ page_size=page_size,
204
+ status=status,
205
+ user_id=user_id,
206
+ team_id=team_id,
207
+ cluster_id=cluster_id,
208
+ )
209
+
210
+ response = await client.get_async_httpx_client().request(**kwargs)
211
+
212
+ return _build_response(client=client, response=response)
213
+
214
+
215
+ async def asyncio(
216
+ *,
217
+ client: AuthenticatedClient,
218
+ page: Union[Unset, int] = 1,
219
+ page_size: Union[Unset, int] = 20,
220
+ status: Union[Unset, TaskStatus] = UNSET,
221
+ user_id: Union[Unset, int] = UNSET,
222
+ team_id: Union[Unset, int] = UNSET,
223
+ cluster_id: Union[Unset, int] = UNSET,
224
+ ) -> Optional[Union[ErrorResponse, TaskListResponse]]:
225
+ """Get task list
226
+
227
+ Get task list with pagination and filtering support
228
+
229
+ Args:
230
+ page (Union[Unset, int]): Default: 1.
231
+ page_size (Union[Unset, int]): Default: 20.
232
+ status (Union[Unset, TaskStatus]): Task status Example: pending.
233
+ user_id (Union[Unset, int]):
234
+ team_id (Union[Unset, int]):
235
+ cluster_id (Union[Unset, int]):
236
+
237
+ Raises:
238
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
239
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
240
+
241
+ Returns:
242
+ Union[ErrorResponse, TaskListResponse]
243
+ """
244
+
245
+ return (
246
+ await asyncio_detailed(
247
+ client=client,
248
+ page=page,
249
+ page_size=page_size,
250
+ status=status,
251
+ user_id=user_id,
252
+ team_id=team_id,
253
+ cluster_id=cluster_id,
254
+ )
255
+ ).parsed
@@ -0,0 +1,188 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.error_response import ErrorResponse
9
+ from ...models.task_submit_request import TaskSubmitRequest
10
+ from ...models.task_submit_response import TaskSubmitResponse
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ body: TaskSubmitRequest,
17
+ ) -> dict[str, Any]:
18
+ headers: dict[str, Any] = {}
19
+
20
+ _kwargs: dict[str, Any] = {
21
+ "method": "post",
22
+ "url": "/tasks",
23
+ }
24
+
25
+ _kwargs["json"] = body.to_dict()
26
+
27
+ headers["Content-Type"] = "application/json"
28
+
29
+ _kwargs["headers"] = headers
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
35
+ ) -> Optional[Union[ErrorResponse, TaskSubmitResponse]]:
36
+ if response.status_code == 201:
37
+ response_201 = TaskSubmitResponse.from_dict(response.json())
38
+
39
+ return response_201
40
+ if response.status_code == 400:
41
+ response_400 = ErrorResponse.from_dict(response.json())
42
+
43
+ return response_400
44
+ if response.status_code == 401:
45
+ response_401 = ErrorResponse.from_dict(response.json())
46
+
47
+ return response_401
48
+ if response.status_code == 403:
49
+ response_403 = ErrorResponse.from_dict(response.json())
50
+
51
+ return response_403
52
+ if response.status_code == 404:
53
+ response_404 = ErrorResponse.from_dict(response.json())
54
+
55
+ return response_404
56
+ if response.status_code == 500:
57
+ response_500 = ErrorResponse.from_dict(response.json())
58
+
59
+ return response_500
60
+ if client.raise_on_unexpected_status:
61
+ raise errors.UnexpectedStatus(response.status_code, response.content)
62
+ else:
63
+ return None
64
+
65
+
66
+ def _build_response(
67
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
68
+ ) -> Response[Union[ErrorResponse, TaskSubmitResponse]]:
69
+ return Response(
70
+ status_code=HTTPStatus(response.status_code),
71
+ content=response.content,
72
+ headers=response.headers,
73
+ parsed=_parse_response(client=client, response=response),
74
+ )
75
+
76
+
77
+ def sync_detailed(
78
+ *,
79
+ client: AuthenticatedClient,
80
+ body: TaskSubmitRequest,
81
+ ) -> Response[Union[ErrorResponse, TaskSubmitResponse]]:
82
+ """Submit task
83
+
84
+ Submit a new task (Slurm job)
85
+
86
+ Args:
87
+ body (TaskSubmitRequest): Task submission request
88
+
89
+ Raises:
90
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
91
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
92
+
93
+ Returns:
94
+ Response[Union[ErrorResponse, TaskSubmitResponse]]
95
+ """
96
+
97
+ kwargs = _get_kwargs(
98
+ body=body,
99
+ )
100
+
101
+ response = client.get_httpx_client().request(
102
+ **kwargs,
103
+ )
104
+
105
+ return _build_response(client=client, response=response)
106
+
107
+
108
+ def sync(
109
+ *,
110
+ client: AuthenticatedClient,
111
+ body: TaskSubmitRequest,
112
+ ) -> Optional[Union[ErrorResponse, TaskSubmitResponse]]:
113
+ """Submit task
114
+
115
+ Submit a new task (Slurm job)
116
+
117
+ Args:
118
+ body (TaskSubmitRequest): Task submission request
119
+
120
+ Raises:
121
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
122
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
123
+
124
+ Returns:
125
+ Union[ErrorResponse, TaskSubmitResponse]
126
+ """
127
+
128
+ return sync_detailed(
129
+ client=client,
130
+ body=body,
131
+ ).parsed
132
+
133
+
134
+ async def asyncio_detailed(
135
+ *,
136
+ client: AuthenticatedClient,
137
+ body: TaskSubmitRequest,
138
+ ) -> Response[Union[ErrorResponse, TaskSubmitResponse]]:
139
+ """Submit task
140
+
141
+ Submit a new task (Slurm job)
142
+
143
+ Args:
144
+ body (TaskSubmitRequest): Task submission request
145
+
146
+ Raises:
147
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
148
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
149
+
150
+ Returns:
151
+ Response[Union[ErrorResponse, TaskSubmitResponse]]
152
+ """
153
+
154
+ kwargs = _get_kwargs(
155
+ body=body,
156
+ )
157
+
158
+ response = await client.get_async_httpx_client().request(**kwargs)
159
+
160
+ return _build_response(client=client, response=response)
161
+
162
+
163
+ async def asyncio(
164
+ *,
165
+ client: AuthenticatedClient,
166
+ body: TaskSubmitRequest,
167
+ ) -> Optional[Union[ErrorResponse, TaskSubmitResponse]]:
168
+ """Submit task
169
+
170
+ Submit a new task (Slurm job)
171
+
172
+ Args:
173
+ body (TaskSubmitRequest): Task submission request
174
+
175
+ Raises:
176
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
177
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
178
+
179
+ Returns:
180
+ Union[ErrorResponse, TaskSubmitResponse]
181
+ """
182
+
183
+ return (
184
+ await asyncio_detailed(
185
+ client=client,
186
+ body=body,
187
+ )
188
+ ).parsed