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
mlops/__init__.py ADDED
@@ -0,0 +1,46 @@
1
+ """
2
+ XClient Python SDK for accessing XCloud Service API.
3
+
4
+ This package provides a client library for interacting with the XCloud Service API.
5
+ """
6
+
7
+ from .api.client import Client, AuthenticatedClient
8
+ from .connection_config import (
9
+ ConnectionConfig,
10
+ ProxyTypes,
11
+ )
12
+ from .exceptions import (
13
+ XClientException,
14
+ TimeoutException,
15
+ NotFoundException,
16
+ AuthenticationException,
17
+ InvalidArgumentException,
18
+ NotEnoughSpaceException,
19
+ RateLimitException,
20
+ APIException,
21
+ )
22
+ from .task import Task, TaskClient
23
+
24
+ __all__ = [
25
+ # API
26
+ "Client",
27
+ "AuthenticatedClient",
28
+ # Connection config
29
+ "ConnectionConfig",
30
+ "ProxyTypes",
31
+ # Exceptions
32
+ "XClientException",
33
+ "TimeoutException",
34
+ "NotFoundException",
35
+ "AuthenticationException",
36
+ "InvalidArgumentException",
37
+ "NotEnoughSpaceException",
38
+ "RateLimitException",
39
+ "APIException",
40
+ # Task SDK
41
+ "Task",
42
+ "TaskClient",
43
+ ]
44
+
45
+ __version__ = "1.0.0"
46
+
@@ -0,0 +1,8 @@
1
+ """A client library for accessing XCloud Service API"""
2
+
3
+ from .client import AuthenticatedClient, Client
4
+
5
+ __all__ = (
6
+ "AuthenticatedClient",
7
+ "Client",
8
+ )
@@ -0,0 +1 @@
1
+ """Contains methods for accessing the API"""
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,196 @@
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.message_response import MessageResponse
10
+ from ...types import UNSET, Response
11
+
12
+
13
+ def _get_kwargs(
14
+ id: int,
15
+ *,
16
+ cluster_id: int,
17
+ ) -> dict[str, Any]:
18
+ params: dict[str, Any] = {}
19
+
20
+ params["cluster_id"] = cluster_id
21
+
22
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
23
+
24
+ _kwargs: dict[str, Any] = {
25
+ "method": "delete",
26
+ "url": f"/tasks/{id}",
27
+ "params": params,
28
+ }
29
+
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
35
+ ) -> Optional[Union[ErrorResponse, MessageResponse]]:
36
+ if response.status_code == 200:
37
+ response_200 = MessageResponse.from_dict(response.json())
38
+
39
+ return response_200
40
+ if response.status_code == 401:
41
+ response_401 = ErrorResponse.from_dict(response.json())
42
+
43
+ return response_401
44
+ if response.status_code == 403:
45
+ response_403 = ErrorResponse.from_dict(response.json())
46
+
47
+ return response_403
48
+ if response.status_code == 404:
49
+ response_404 = ErrorResponse.from_dict(response.json())
50
+
51
+ return response_404
52
+ if response.status_code == 500:
53
+ response_500 = ErrorResponse.from_dict(response.json())
54
+
55
+ return response_500
56
+ if client.raise_on_unexpected_status:
57
+ raise errors.UnexpectedStatus(response.status_code, response.content)
58
+ else:
59
+ return None
60
+
61
+
62
+ def _build_response(
63
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
64
+ ) -> Response[Union[ErrorResponse, MessageResponse]]:
65
+ return Response(
66
+ status_code=HTTPStatus(response.status_code),
67
+ content=response.content,
68
+ headers=response.headers,
69
+ parsed=_parse_response(client=client, response=response),
70
+ )
71
+
72
+
73
+ def sync_detailed(
74
+ id: int,
75
+ *,
76
+ client: AuthenticatedClient,
77
+ cluster_id: int,
78
+ ) -> Response[Union[ErrorResponse, MessageResponse]]:
79
+ """Cancel task
80
+
81
+ Cancel the specified task
82
+
83
+ Args:
84
+ id (int):
85
+ cluster_id (int):
86
+
87
+ Raises:
88
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
89
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
90
+
91
+ Returns:
92
+ Response[Union[ErrorResponse, MessageResponse]]
93
+ """
94
+
95
+ kwargs = _get_kwargs(
96
+ id=id,
97
+ cluster_id=cluster_id,
98
+ )
99
+
100
+ response = client.get_httpx_client().request(
101
+ **kwargs,
102
+ )
103
+
104
+ return _build_response(client=client, response=response)
105
+
106
+
107
+ def sync(
108
+ id: int,
109
+ *,
110
+ client: AuthenticatedClient,
111
+ cluster_id: int,
112
+ ) -> Optional[Union[ErrorResponse, MessageResponse]]:
113
+ """Cancel task
114
+
115
+ Cancel the specified task
116
+
117
+ Args:
118
+ id (int):
119
+ cluster_id (int):
120
+
121
+ Raises:
122
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
123
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
124
+
125
+ Returns:
126
+ Union[ErrorResponse, MessageResponse]
127
+ """
128
+
129
+ return sync_detailed(
130
+ id=id,
131
+ client=client,
132
+ cluster_id=cluster_id,
133
+ ).parsed
134
+
135
+
136
+ async def asyncio_detailed(
137
+ id: int,
138
+ *,
139
+ client: AuthenticatedClient,
140
+ cluster_id: int,
141
+ ) -> Response[Union[ErrorResponse, MessageResponse]]:
142
+ """Cancel task
143
+
144
+ Cancel the specified task
145
+
146
+ Args:
147
+ id (int):
148
+ cluster_id (int):
149
+
150
+ Raises:
151
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
152
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
153
+
154
+ Returns:
155
+ Response[Union[ErrorResponse, MessageResponse]]
156
+ """
157
+
158
+ kwargs = _get_kwargs(
159
+ id=id,
160
+ cluster_id=cluster_id,
161
+ )
162
+
163
+ response = await client.get_async_httpx_client().request(**kwargs)
164
+
165
+ return _build_response(client=client, response=response)
166
+
167
+
168
+ async def asyncio(
169
+ id: int,
170
+ *,
171
+ client: AuthenticatedClient,
172
+ cluster_id: int,
173
+ ) -> Optional[Union[ErrorResponse, MessageResponse]]:
174
+ """Cancel task
175
+
176
+ Cancel the specified task
177
+
178
+ Args:
179
+ id (int):
180
+ cluster_id (int):
181
+
182
+ Raises:
183
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
184
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
185
+
186
+ Returns:
187
+ Union[ErrorResponse, MessageResponse]
188
+ """
189
+
190
+ return (
191
+ await asyncio_detailed(
192
+ id=id,
193
+ client=client,
194
+ cluster_id=cluster_id,
195
+ )
196
+ ).parsed
@@ -0,0 +1,204 @@
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.message_response import MessageResponse
10
+ from ...types import UNSET, Response
11
+
12
+
13
+ def _get_kwargs(
14
+ id: int,
15
+ *,
16
+ cluster_id: int,
17
+ ) -> dict[str, Any]:
18
+ params: dict[str, Any] = {}
19
+
20
+ params["cluster_id"] = cluster_id
21
+
22
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
23
+
24
+ _kwargs: dict[str, Any] = {
25
+ "method": "delete",
26
+ "url": f"/tasks/{id}/delete",
27
+ "params": params,
28
+ }
29
+
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
35
+ ) -> Optional[Union[ErrorResponse, MessageResponse]]:
36
+ if response.status_code == 200:
37
+ response_200 = MessageResponse.from_dict(response.json())
38
+
39
+ return response_200
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, MessageResponse]]:
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
+ id: int,
79
+ *,
80
+ client: AuthenticatedClient,
81
+ cluster_id: int,
82
+ ) -> Response[Union[ErrorResponse, MessageResponse]]:
83
+ """Delete task record
84
+
85
+ Delete a task record from the database. This should only be used for tasks that are already
86
+ completed, failed, or cancelled. Cannot delete running or pending tasks.
87
+
88
+ Args:
89
+ id (int):
90
+ cluster_id (int):
91
+
92
+ Raises:
93
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
94
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
95
+
96
+ Returns:
97
+ Response[Union[ErrorResponse, MessageResponse]]
98
+ """
99
+
100
+ kwargs = _get_kwargs(
101
+ id=id,
102
+ cluster_id=cluster_id,
103
+ )
104
+
105
+ response = client.get_httpx_client().request(
106
+ **kwargs,
107
+ )
108
+
109
+ return _build_response(client=client, response=response)
110
+
111
+
112
+ def sync(
113
+ id: int,
114
+ *,
115
+ client: AuthenticatedClient,
116
+ cluster_id: int,
117
+ ) -> Optional[Union[ErrorResponse, MessageResponse]]:
118
+ """Delete task record
119
+
120
+ Delete a task record from the database. This should only be used for tasks that are already
121
+ completed, failed, or cancelled. Cannot delete running or pending tasks.
122
+
123
+ Args:
124
+ id (int):
125
+ cluster_id (int):
126
+
127
+ Raises:
128
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
129
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
130
+
131
+ Returns:
132
+ Union[ErrorResponse, MessageResponse]
133
+ """
134
+
135
+ return sync_detailed(
136
+ id=id,
137
+ client=client,
138
+ cluster_id=cluster_id,
139
+ ).parsed
140
+
141
+
142
+ async def asyncio_detailed(
143
+ id: int,
144
+ *,
145
+ client: AuthenticatedClient,
146
+ cluster_id: int,
147
+ ) -> Response[Union[ErrorResponse, MessageResponse]]:
148
+ """Delete task record
149
+
150
+ Delete a task record from the database. This should only be used for tasks that are already
151
+ completed, failed, or cancelled. Cannot delete running or pending tasks.
152
+
153
+ Args:
154
+ id (int):
155
+ cluster_id (int):
156
+
157
+ Raises:
158
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
159
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
160
+
161
+ Returns:
162
+ Response[Union[ErrorResponse, MessageResponse]]
163
+ """
164
+
165
+ kwargs = _get_kwargs(
166
+ id=id,
167
+ cluster_id=cluster_id,
168
+ )
169
+
170
+ response = await client.get_async_httpx_client().request(**kwargs)
171
+
172
+ return _build_response(client=client, response=response)
173
+
174
+
175
+ async def asyncio(
176
+ id: int,
177
+ *,
178
+ client: AuthenticatedClient,
179
+ cluster_id: int,
180
+ ) -> Optional[Union[ErrorResponse, MessageResponse]]:
181
+ """Delete task record
182
+
183
+ Delete a task record from the database. This should only be used for tasks that are already
184
+ completed, failed, or cancelled. Cannot delete running or pending tasks.
185
+
186
+ Args:
187
+ id (int):
188
+ cluster_id (int):
189
+
190
+ Raises:
191
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
192
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
193
+
194
+ Returns:
195
+ Union[ErrorResponse, MessageResponse]
196
+ """
197
+
198
+ return (
199
+ await asyncio_detailed(
200
+ id=id,
201
+ client=client,
202
+ cluster_id=cluster_id,
203
+ )
204
+ ).parsed
@@ -0,0 +1,196 @@
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 import Task
10
+ from ...types import UNSET, Response, Unset
11
+
12
+
13
+ def _get_kwargs(
14
+ id: int,
15
+ *,
16
+ cluster_id: Union[Unset, int] = UNSET,
17
+ ) -> dict[str, Any]:
18
+ params: dict[str, Any] = {}
19
+
20
+ params["cluster_id"] = cluster_id
21
+
22
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
23
+
24
+ _kwargs: dict[str, Any] = {
25
+ "method": "get",
26
+ "url": f"/tasks/{id}",
27
+ "params": params,
28
+ }
29
+
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
35
+ ) -> Optional[Union[ErrorResponse, Task]]:
36
+ if response.status_code == 200:
37
+ response_200 = Task.from_dict(response.json())
38
+
39
+ return response_200
40
+ if response.status_code == 401:
41
+ response_401 = ErrorResponse.from_dict(response.json())
42
+
43
+ return response_401
44
+ if response.status_code == 403:
45
+ response_403 = ErrorResponse.from_dict(response.json())
46
+
47
+ return response_403
48
+ if response.status_code == 404:
49
+ response_404 = ErrorResponse.from_dict(response.json())
50
+
51
+ return response_404
52
+ if response.status_code == 500:
53
+ response_500 = ErrorResponse.from_dict(response.json())
54
+
55
+ return response_500
56
+ if client.raise_on_unexpected_status:
57
+ raise errors.UnexpectedStatus(response.status_code, response.content)
58
+ else:
59
+ return None
60
+
61
+
62
+ def _build_response(
63
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
64
+ ) -> Response[Union[ErrorResponse, Task]]:
65
+ return Response(
66
+ status_code=HTTPStatus(response.status_code),
67
+ content=response.content,
68
+ headers=response.headers,
69
+ parsed=_parse_response(client=client, response=response),
70
+ )
71
+
72
+
73
+ def sync_detailed(
74
+ id: int,
75
+ *,
76
+ client: AuthenticatedClient,
77
+ cluster_id: Union[Unset, int] = UNSET,
78
+ ) -> Response[Union[ErrorResponse, Task]]:
79
+ """Get task details
80
+
81
+ Get detailed task information by task ID (Slurm job ID) and cluster ID
82
+
83
+ Args:
84
+ id (int):
85
+ cluster_id (Union[Unset, int]):
86
+
87
+ Raises:
88
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
89
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
90
+
91
+ Returns:
92
+ Response[Union[ErrorResponse, Task]]
93
+ """
94
+
95
+ kwargs = _get_kwargs(
96
+ id=id,
97
+ cluster_id=cluster_id,
98
+ )
99
+
100
+ response = client.get_httpx_client().request(
101
+ **kwargs,
102
+ )
103
+
104
+ return _build_response(client=client, response=response)
105
+
106
+
107
+ def sync(
108
+ id: int,
109
+ *,
110
+ client: AuthenticatedClient,
111
+ cluster_id: Union[Unset, int] = UNSET,
112
+ ) -> Optional[Union[ErrorResponse, Task]]:
113
+ """Get task details
114
+
115
+ Get detailed task information by task ID (Slurm job ID) and cluster ID
116
+
117
+ Args:
118
+ id (int):
119
+ cluster_id (Union[Unset, int]):
120
+
121
+ Raises:
122
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
123
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
124
+
125
+ Returns:
126
+ Union[ErrorResponse, Task]
127
+ """
128
+
129
+ return sync_detailed(
130
+ id=id,
131
+ client=client,
132
+ cluster_id=cluster_id,
133
+ ).parsed
134
+
135
+
136
+ async def asyncio_detailed(
137
+ id: int,
138
+ *,
139
+ client: AuthenticatedClient,
140
+ cluster_id: Union[Unset, int] = UNSET,
141
+ ) -> Response[Union[ErrorResponse, Task]]:
142
+ """Get task details
143
+
144
+ Get detailed task information by task ID (Slurm job ID) and cluster ID
145
+
146
+ Args:
147
+ id (int):
148
+ cluster_id (Union[Unset, int]):
149
+
150
+ Raises:
151
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
152
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
153
+
154
+ Returns:
155
+ Response[Union[ErrorResponse, Task]]
156
+ """
157
+
158
+ kwargs = _get_kwargs(
159
+ id=id,
160
+ cluster_id=cluster_id,
161
+ )
162
+
163
+ response = await client.get_async_httpx_client().request(**kwargs)
164
+
165
+ return _build_response(client=client, response=response)
166
+
167
+
168
+ async def asyncio(
169
+ id: int,
170
+ *,
171
+ client: AuthenticatedClient,
172
+ cluster_id: Union[Unset, int] = UNSET,
173
+ ) -> Optional[Union[ErrorResponse, Task]]:
174
+ """Get task details
175
+
176
+ Get detailed task information by task ID (Slurm job ID) and cluster ID
177
+
178
+ Args:
179
+ id (int):
180
+ cluster_id (Union[Unset, int]):
181
+
182
+ Raises:
183
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
184
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
185
+
186
+ Returns:
187
+ Union[ErrorResponse, Task]
188
+ """
189
+
190
+ return (
191
+ await asyncio_detailed(
192
+ id=id,
193
+ client=client,
194
+ cluster_id=cluster_id,
195
+ )
196
+ ).parsed