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,640 @@
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, 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
+ if TYPE_CHECKING:
10
+ from ..models.task_submit_request_environment_type_0 import TaskSubmitRequestEnvironmentType0
11
+
12
+
13
+ T = TypeVar("T", bound="TaskSubmitRequest")
14
+
15
+
16
+ @_attrs_define
17
+ class TaskSubmitRequest:
18
+ """Task submission request
19
+
20
+ Attributes:
21
+ cluster_id (int): Slurm cluster ID to submit task to Example: 1.
22
+ name (str): Task name Example: training-job.
23
+ account (Union[None, Unset, str]): Account Example: research.
24
+ command (Union[None, Unset, str]): Command to execute (alternative to script) Example: python train.py.
25
+ comment (Union[None, Unset, str]): Job comment
26
+ constraint (Union[None, Unset, str]): Node constraint Example: gpu.
27
+ cpu_bind (Union[None, Unset, str]): CPU binding
28
+ cpus_per_task (Union[None, Unset, int]): CPUs per task Example: 1.
29
+ dependency (Union[None, Unset, str]): Job dependencies Example: afterok:12345.
30
+ distribution (Union[None, Unset, str]): Task distribution Example: block.
31
+ environment (Union['TaskSubmitRequestEnvironmentType0', None, Unset]): Environment variables as key-value pairs
32
+ Example: {'CUDA_VISIBLE_DEVICES': '0,1', 'PYTHONPATH': '/opt/python/lib'}.
33
+ error (Union[None, Unset, str]): Standard error file pattern Example: error_%j.log.
34
+ exclude (Union[None, Unset, str]): Nodes to exclude
35
+ export (Union[None, Unset, str]): Environment export Example: ALL.
36
+ gres (Union[None, Unset, str]): Generic resources (e.g., "gpu:1", "gpu:tesla:2") Example: gpu:1.
37
+ input_ (Union[None, Unset, str]): Standard input file
38
+ mem_bind (Union[None, Unset, str]): Memory binding
39
+ memory (Union[None, Unset, str]): Memory requirement (e.g., "8G", "4096M") Example: 8G.
40
+ nice (Union[None, Unset, int]): Nice value
41
+ nodelist (Union[None, Unset, str]): Specific nodes to use
42
+ nodes (Union[None, Unset, int]): Number of nodes Example: 1.
43
+ ntasks (Union[None, Unset, int]): Number of tasks Example: 4.
44
+ output (Union[None, Unset, str]): Standard output file pattern Example: output_%j.log.
45
+ partition (Union[None, Unset, str]): Partition name Example: gpu.
46
+ qos (Union[None, Unset, str]): Quality of Service Example: normal.
47
+ reservation (Union[None, Unset, str]): Reservation name
48
+ script (Union[Unset, str]): Task script content (bash script with Example: #!/bin/bash
49
+ #SBATCH --job-name=training
50
+ python train.py.
51
+ team_id (Union[None, Unset, int]): Team ID (auto-filled from current team) Example: 1.
52
+ time (Union[None, Unset, str]): Time limit (format: DD-HH:MM:SS, HH:MM:SS, or MM:SS) Example: 01:00:00.
53
+ tres (Union[None, Unset, str]): Trackable resources string Example: cpu=4,mem=8G.
54
+ """
55
+
56
+ cluster_id: int
57
+ name: str
58
+ account: Union[None, Unset, str] = UNSET
59
+ command: Union[None, Unset, str] = UNSET
60
+ comment: Union[None, Unset, str] = UNSET
61
+ constraint: Union[None, Unset, str] = UNSET
62
+ cpu_bind: Union[None, Unset, str] = UNSET
63
+ cpus_per_task: Union[None, Unset, int] = UNSET
64
+ dependency: Union[None, Unset, str] = UNSET
65
+ distribution: Union[None, Unset, str] = UNSET
66
+ environment: Union["TaskSubmitRequestEnvironmentType0", None, Unset] = UNSET
67
+ error: Union[None, Unset, str] = UNSET
68
+ exclude: Union[None, Unset, str] = UNSET
69
+ export: Union[None, Unset, str] = UNSET
70
+ gres: Union[None, Unset, str] = UNSET
71
+ input_: Union[None, Unset, str] = UNSET
72
+ mem_bind: Union[None, Unset, str] = UNSET
73
+ memory: Union[None, Unset, str] = UNSET
74
+ nice: Union[None, Unset, int] = UNSET
75
+ nodelist: Union[None, Unset, str] = UNSET
76
+ nodes: Union[None, Unset, int] = UNSET
77
+ ntasks: Union[None, Unset, int] = UNSET
78
+ output: Union[None, Unset, str] = UNSET
79
+ partition: Union[None, Unset, str] = UNSET
80
+ qos: Union[None, Unset, str] = UNSET
81
+ reservation: Union[None, Unset, str] = UNSET
82
+ script: Union[Unset, str] = UNSET
83
+ team_id: Union[None, Unset, int] = UNSET
84
+ time: Union[None, Unset, str] = UNSET
85
+ tres: Union[None, Unset, str] = UNSET
86
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
87
+
88
+ def to_dict(self) -> dict[str, Any]:
89
+ from ..models.task_submit_request_environment_type_0 import TaskSubmitRequestEnvironmentType0
90
+
91
+ cluster_id = self.cluster_id
92
+
93
+ name = self.name
94
+
95
+ account: Union[None, Unset, str]
96
+ if isinstance(self.account, Unset):
97
+ account = UNSET
98
+ else:
99
+ account = self.account
100
+
101
+ command: Union[None, Unset, str]
102
+ if isinstance(self.command, Unset):
103
+ command = UNSET
104
+ else:
105
+ command = self.command
106
+
107
+ comment: Union[None, Unset, str]
108
+ if isinstance(self.comment, Unset):
109
+ comment = UNSET
110
+ else:
111
+ comment = self.comment
112
+
113
+ constraint: Union[None, Unset, str]
114
+ if isinstance(self.constraint, Unset):
115
+ constraint = UNSET
116
+ else:
117
+ constraint = self.constraint
118
+
119
+ cpu_bind: Union[None, Unset, str]
120
+ if isinstance(self.cpu_bind, Unset):
121
+ cpu_bind = UNSET
122
+ else:
123
+ cpu_bind = self.cpu_bind
124
+
125
+ cpus_per_task: Union[None, Unset, int]
126
+ if isinstance(self.cpus_per_task, Unset):
127
+ cpus_per_task = UNSET
128
+ else:
129
+ cpus_per_task = self.cpus_per_task
130
+
131
+ dependency: Union[None, Unset, str]
132
+ if isinstance(self.dependency, Unset):
133
+ dependency = UNSET
134
+ else:
135
+ dependency = self.dependency
136
+
137
+ distribution: Union[None, Unset, str]
138
+ if isinstance(self.distribution, Unset):
139
+ distribution = UNSET
140
+ else:
141
+ distribution = self.distribution
142
+
143
+ environment: Union[None, Unset, dict[str, Any]]
144
+ if isinstance(self.environment, Unset):
145
+ environment = UNSET
146
+ elif isinstance(self.environment, TaskSubmitRequestEnvironmentType0):
147
+ environment = self.environment.to_dict()
148
+ else:
149
+ environment = self.environment
150
+
151
+ error: Union[None, Unset, str]
152
+ if isinstance(self.error, Unset):
153
+ error = UNSET
154
+ else:
155
+ error = self.error
156
+
157
+ exclude: Union[None, Unset, str]
158
+ if isinstance(self.exclude, Unset):
159
+ exclude = UNSET
160
+ else:
161
+ exclude = self.exclude
162
+
163
+ export: Union[None, Unset, str]
164
+ if isinstance(self.export, Unset):
165
+ export = UNSET
166
+ else:
167
+ export = self.export
168
+
169
+ gres: Union[None, Unset, str]
170
+ if isinstance(self.gres, Unset):
171
+ gres = UNSET
172
+ else:
173
+ gres = self.gres
174
+
175
+ input_: Union[None, Unset, str]
176
+ if isinstance(self.input_, Unset):
177
+ input_ = UNSET
178
+ else:
179
+ input_ = self.input_
180
+
181
+ mem_bind: Union[None, Unset, str]
182
+ if isinstance(self.mem_bind, Unset):
183
+ mem_bind = UNSET
184
+ else:
185
+ mem_bind = self.mem_bind
186
+
187
+ memory: Union[None, Unset, str]
188
+ if isinstance(self.memory, Unset):
189
+ memory = UNSET
190
+ else:
191
+ memory = self.memory
192
+
193
+ nice: Union[None, Unset, int]
194
+ if isinstance(self.nice, Unset):
195
+ nice = UNSET
196
+ else:
197
+ nice = self.nice
198
+
199
+ nodelist: Union[None, Unset, str]
200
+ if isinstance(self.nodelist, Unset):
201
+ nodelist = UNSET
202
+ else:
203
+ nodelist = self.nodelist
204
+
205
+ nodes: Union[None, Unset, int]
206
+ if isinstance(self.nodes, Unset):
207
+ nodes = UNSET
208
+ else:
209
+ nodes = self.nodes
210
+
211
+ ntasks: Union[None, Unset, int]
212
+ if isinstance(self.ntasks, Unset):
213
+ ntasks = UNSET
214
+ else:
215
+ ntasks = self.ntasks
216
+
217
+ output: Union[None, Unset, str]
218
+ if isinstance(self.output, Unset):
219
+ output = UNSET
220
+ else:
221
+ output = self.output
222
+
223
+ partition: Union[None, Unset, str]
224
+ if isinstance(self.partition, Unset):
225
+ partition = UNSET
226
+ else:
227
+ partition = self.partition
228
+
229
+ qos: Union[None, Unset, str]
230
+ if isinstance(self.qos, Unset):
231
+ qos = UNSET
232
+ else:
233
+ qos = self.qos
234
+
235
+ reservation: Union[None, Unset, str]
236
+ if isinstance(self.reservation, Unset):
237
+ reservation = UNSET
238
+ else:
239
+ reservation = self.reservation
240
+
241
+ script = self.script
242
+
243
+ team_id: Union[None, Unset, int]
244
+ if isinstance(self.team_id, Unset):
245
+ team_id = UNSET
246
+ else:
247
+ team_id = self.team_id
248
+
249
+ time: Union[None, Unset, str]
250
+ if isinstance(self.time, Unset):
251
+ time = UNSET
252
+ else:
253
+ time = self.time
254
+
255
+ tres: Union[None, Unset, str]
256
+ if isinstance(self.tres, Unset):
257
+ tres = UNSET
258
+ else:
259
+ tres = self.tres
260
+
261
+ field_dict: dict[str, Any] = {}
262
+ field_dict.update(self.additional_properties)
263
+ field_dict.update(
264
+ {
265
+ "cluster_id": cluster_id,
266
+ "name": name,
267
+ }
268
+ )
269
+ if account is not UNSET:
270
+ field_dict["account"] = account
271
+ if command is not UNSET:
272
+ field_dict["command"] = command
273
+ if comment is not UNSET:
274
+ field_dict["comment"] = comment
275
+ if constraint is not UNSET:
276
+ field_dict["constraint"] = constraint
277
+ if cpu_bind is not UNSET:
278
+ field_dict["cpu_bind"] = cpu_bind
279
+ if cpus_per_task is not UNSET:
280
+ field_dict["cpus_per_task"] = cpus_per_task
281
+ if dependency is not UNSET:
282
+ field_dict["dependency"] = dependency
283
+ if distribution is not UNSET:
284
+ field_dict["distribution"] = distribution
285
+ if environment is not UNSET:
286
+ field_dict["environment"] = environment
287
+ if error is not UNSET:
288
+ field_dict["error"] = error
289
+ if exclude is not UNSET:
290
+ field_dict["exclude"] = exclude
291
+ if export is not UNSET:
292
+ field_dict["export"] = export
293
+ if gres is not UNSET:
294
+ field_dict["gres"] = gres
295
+ if input_ is not UNSET:
296
+ field_dict["input"] = input_
297
+ if mem_bind is not UNSET:
298
+ field_dict["mem_bind"] = mem_bind
299
+ if memory is not UNSET:
300
+ field_dict["memory"] = memory
301
+ if nice is not UNSET:
302
+ field_dict["nice"] = nice
303
+ if nodelist is not UNSET:
304
+ field_dict["nodelist"] = nodelist
305
+ if nodes is not UNSET:
306
+ field_dict["nodes"] = nodes
307
+ if ntasks is not UNSET:
308
+ field_dict["ntasks"] = ntasks
309
+ if output is not UNSET:
310
+ field_dict["output"] = output
311
+ if partition is not UNSET:
312
+ field_dict["partition"] = partition
313
+ if qos is not UNSET:
314
+ field_dict["qos"] = qos
315
+ if reservation is not UNSET:
316
+ field_dict["reservation"] = reservation
317
+ if script is not UNSET:
318
+ field_dict["script"] = script
319
+ if team_id is not UNSET:
320
+ field_dict["team_id"] = team_id
321
+ if time is not UNSET:
322
+ field_dict["time"] = time
323
+ if tres is not UNSET:
324
+ field_dict["tres"] = tres
325
+
326
+ return field_dict
327
+
328
+ @classmethod
329
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
330
+ from ..models.task_submit_request_environment_type_0 import TaskSubmitRequestEnvironmentType0
331
+
332
+ d = dict(src_dict)
333
+ cluster_id = d.pop("cluster_id")
334
+
335
+ name = d.pop("name")
336
+
337
+ def _parse_account(data: object) -> Union[None, Unset, str]:
338
+ if data is None:
339
+ return data
340
+ if isinstance(data, Unset):
341
+ return data
342
+ return cast(Union[None, Unset, str], data)
343
+
344
+ account = _parse_account(d.pop("account", UNSET))
345
+
346
+ def _parse_command(data: object) -> Union[None, Unset, str]:
347
+ if data is None:
348
+ return data
349
+ if isinstance(data, Unset):
350
+ return data
351
+ return cast(Union[None, Unset, str], data)
352
+
353
+ command = _parse_command(d.pop("command", UNSET))
354
+
355
+ def _parse_comment(data: object) -> Union[None, Unset, str]:
356
+ if data is None:
357
+ return data
358
+ if isinstance(data, Unset):
359
+ return data
360
+ return cast(Union[None, Unset, str], data)
361
+
362
+ comment = _parse_comment(d.pop("comment", UNSET))
363
+
364
+ def _parse_constraint(data: object) -> Union[None, Unset, str]:
365
+ if data is None:
366
+ return data
367
+ if isinstance(data, Unset):
368
+ return data
369
+ return cast(Union[None, Unset, str], data)
370
+
371
+ constraint = _parse_constraint(d.pop("constraint", UNSET))
372
+
373
+ def _parse_cpu_bind(data: object) -> Union[None, Unset, str]:
374
+ if data is None:
375
+ return data
376
+ if isinstance(data, Unset):
377
+ return data
378
+ return cast(Union[None, Unset, str], data)
379
+
380
+ cpu_bind = _parse_cpu_bind(d.pop("cpu_bind", UNSET))
381
+
382
+ def _parse_cpus_per_task(data: object) -> Union[None, Unset, int]:
383
+ if data is None:
384
+ return data
385
+ if isinstance(data, Unset):
386
+ return data
387
+ return cast(Union[None, Unset, int], data)
388
+
389
+ cpus_per_task = _parse_cpus_per_task(d.pop("cpus_per_task", UNSET))
390
+
391
+ def _parse_dependency(data: object) -> Union[None, Unset, str]:
392
+ if data is None:
393
+ return data
394
+ if isinstance(data, Unset):
395
+ return data
396
+ return cast(Union[None, Unset, str], data)
397
+
398
+ dependency = _parse_dependency(d.pop("dependency", UNSET))
399
+
400
+ def _parse_distribution(data: object) -> Union[None, Unset, str]:
401
+ if data is None:
402
+ return data
403
+ if isinstance(data, Unset):
404
+ return data
405
+ return cast(Union[None, Unset, str], data)
406
+
407
+ distribution = _parse_distribution(d.pop("distribution", UNSET))
408
+
409
+ def _parse_environment(data: object) -> Union["TaskSubmitRequestEnvironmentType0", None, Unset]:
410
+ if data is None:
411
+ return data
412
+ if isinstance(data, Unset):
413
+ return data
414
+ try:
415
+ if not isinstance(data, dict):
416
+ raise TypeError()
417
+ environment_type_0 = TaskSubmitRequestEnvironmentType0.from_dict(data)
418
+
419
+ return environment_type_0
420
+ except: # noqa: E722
421
+ pass
422
+ return cast(Union["TaskSubmitRequestEnvironmentType0", None, Unset], data)
423
+
424
+ environment = _parse_environment(d.pop("environment", UNSET))
425
+
426
+ def _parse_error(data: object) -> Union[None, Unset, str]:
427
+ if data is None:
428
+ return data
429
+ if isinstance(data, Unset):
430
+ return data
431
+ return cast(Union[None, Unset, str], data)
432
+
433
+ error = _parse_error(d.pop("error", UNSET))
434
+
435
+ def _parse_exclude(data: object) -> Union[None, Unset, str]:
436
+ if data is None:
437
+ return data
438
+ if isinstance(data, Unset):
439
+ return data
440
+ return cast(Union[None, Unset, str], data)
441
+
442
+ exclude = _parse_exclude(d.pop("exclude", UNSET))
443
+
444
+ def _parse_export(data: object) -> Union[None, Unset, str]:
445
+ if data is None:
446
+ return data
447
+ if isinstance(data, Unset):
448
+ return data
449
+ return cast(Union[None, Unset, str], data)
450
+
451
+ export = _parse_export(d.pop("export", UNSET))
452
+
453
+ def _parse_gres(data: object) -> Union[None, Unset, str]:
454
+ if data is None:
455
+ return data
456
+ if isinstance(data, Unset):
457
+ return data
458
+ return cast(Union[None, Unset, str], data)
459
+
460
+ gres = _parse_gres(d.pop("gres", UNSET))
461
+
462
+ def _parse_input_(data: object) -> Union[None, Unset, str]:
463
+ if data is None:
464
+ return data
465
+ if isinstance(data, Unset):
466
+ return data
467
+ return cast(Union[None, Unset, str], data)
468
+
469
+ input_ = _parse_input_(d.pop("input", UNSET))
470
+
471
+ def _parse_mem_bind(data: object) -> Union[None, Unset, str]:
472
+ if data is None:
473
+ return data
474
+ if isinstance(data, Unset):
475
+ return data
476
+ return cast(Union[None, Unset, str], data)
477
+
478
+ mem_bind = _parse_mem_bind(d.pop("mem_bind", UNSET))
479
+
480
+ def _parse_memory(data: object) -> Union[None, Unset, str]:
481
+ if data is None:
482
+ return data
483
+ if isinstance(data, Unset):
484
+ return data
485
+ return cast(Union[None, Unset, str], data)
486
+
487
+ memory = _parse_memory(d.pop("memory", UNSET))
488
+
489
+ def _parse_nice(data: object) -> Union[None, Unset, int]:
490
+ if data is None:
491
+ return data
492
+ if isinstance(data, Unset):
493
+ return data
494
+ return cast(Union[None, Unset, int], data)
495
+
496
+ nice = _parse_nice(d.pop("nice", UNSET))
497
+
498
+ def _parse_nodelist(data: object) -> Union[None, Unset, str]:
499
+ if data is None:
500
+ return data
501
+ if isinstance(data, Unset):
502
+ return data
503
+ return cast(Union[None, Unset, str], data)
504
+
505
+ nodelist = _parse_nodelist(d.pop("nodelist", UNSET))
506
+
507
+ def _parse_nodes(data: object) -> Union[None, Unset, int]:
508
+ if data is None:
509
+ return data
510
+ if isinstance(data, Unset):
511
+ return data
512
+ return cast(Union[None, Unset, int], data)
513
+
514
+ nodes = _parse_nodes(d.pop("nodes", UNSET))
515
+
516
+ def _parse_ntasks(data: object) -> Union[None, Unset, int]:
517
+ if data is None:
518
+ return data
519
+ if isinstance(data, Unset):
520
+ return data
521
+ return cast(Union[None, Unset, int], data)
522
+
523
+ ntasks = _parse_ntasks(d.pop("ntasks", UNSET))
524
+
525
+ def _parse_output(data: object) -> Union[None, Unset, str]:
526
+ if data is None:
527
+ return data
528
+ if isinstance(data, Unset):
529
+ return data
530
+ return cast(Union[None, Unset, str], data)
531
+
532
+ output = _parse_output(d.pop("output", UNSET))
533
+
534
+ def _parse_partition(data: object) -> Union[None, Unset, str]:
535
+ if data is None:
536
+ return data
537
+ if isinstance(data, Unset):
538
+ return data
539
+ return cast(Union[None, Unset, str], data)
540
+
541
+ partition = _parse_partition(d.pop("partition", UNSET))
542
+
543
+ def _parse_qos(data: object) -> Union[None, Unset, str]:
544
+ if data is None:
545
+ return data
546
+ if isinstance(data, Unset):
547
+ return data
548
+ return cast(Union[None, Unset, str], data)
549
+
550
+ qos = _parse_qos(d.pop("qos", UNSET))
551
+
552
+ def _parse_reservation(data: object) -> Union[None, Unset, str]:
553
+ if data is None:
554
+ return data
555
+ if isinstance(data, Unset):
556
+ return data
557
+ return cast(Union[None, Unset, str], data)
558
+
559
+ reservation = _parse_reservation(d.pop("reservation", UNSET))
560
+
561
+ script = d.pop("script", UNSET)
562
+
563
+ def _parse_team_id(data: object) -> Union[None, Unset, int]:
564
+ if data is None:
565
+ return data
566
+ if isinstance(data, Unset):
567
+ return data
568
+ return cast(Union[None, Unset, int], data)
569
+
570
+ team_id = _parse_team_id(d.pop("team_id", UNSET))
571
+
572
+ def _parse_time(data: object) -> Union[None, Unset, str]:
573
+ if data is None:
574
+ return data
575
+ if isinstance(data, Unset):
576
+ return data
577
+ return cast(Union[None, Unset, str], data)
578
+
579
+ time = _parse_time(d.pop("time", UNSET))
580
+
581
+ def _parse_tres(data: object) -> Union[None, Unset, str]:
582
+ if data is None:
583
+ return data
584
+ if isinstance(data, Unset):
585
+ return data
586
+ return cast(Union[None, Unset, str], data)
587
+
588
+ tres = _parse_tres(d.pop("tres", UNSET))
589
+
590
+ task_submit_request = cls(
591
+ cluster_id=cluster_id,
592
+ name=name,
593
+ account=account,
594
+ command=command,
595
+ comment=comment,
596
+ constraint=constraint,
597
+ cpu_bind=cpu_bind,
598
+ cpus_per_task=cpus_per_task,
599
+ dependency=dependency,
600
+ distribution=distribution,
601
+ environment=environment,
602
+ error=error,
603
+ exclude=exclude,
604
+ export=export,
605
+ gres=gres,
606
+ input_=input_,
607
+ mem_bind=mem_bind,
608
+ memory=memory,
609
+ nice=nice,
610
+ nodelist=nodelist,
611
+ nodes=nodes,
612
+ ntasks=ntasks,
613
+ output=output,
614
+ partition=partition,
615
+ qos=qos,
616
+ reservation=reservation,
617
+ script=script,
618
+ team_id=team_id,
619
+ time=time,
620
+ tres=tres,
621
+ )
622
+
623
+ task_submit_request.additional_properties = d
624
+ return task_submit_request
625
+
626
+ @property
627
+ def additional_keys(self) -> list[str]:
628
+ return list(self.additional_properties.keys())
629
+
630
+ def __getitem__(self, key: str) -> Any:
631
+ return self.additional_properties[key]
632
+
633
+ def __setitem__(self, key: str, value: Any) -> None:
634
+ self.additional_properties[key] = value
635
+
636
+ def __delitem__(self, key: str) -> None:
637
+ del self.additional_properties[key]
638
+
639
+ def __contains__(self, key: str) -> bool:
640
+ return key in self.additional_properties
@@ -0,0 +1,49 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar
3
+
4
+ from attrs import define as _attrs_define
5
+ from attrs import field as _attrs_field
6
+
7
+ T = TypeVar("T", bound="TaskSubmitRequestEnvironmentType0")
8
+
9
+
10
+ @_attrs_define
11
+ class TaskSubmitRequestEnvironmentType0:
12
+ """Environment variables as key-value pairs
13
+
14
+ Example:
15
+ {'CUDA_VISIBLE_DEVICES': '0,1', 'PYTHONPATH': '/opt/python/lib'}
16
+
17
+ """
18
+
19
+ additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict)
20
+
21
+ def to_dict(self) -> dict[str, Any]:
22
+ field_dict: dict[str, Any] = {}
23
+ field_dict.update(self.additional_properties)
24
+
25
+ return field_dict
26
+
27
+ @classmethod
28
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
29
+ d = dict(src_dict)
30
+ task_submit_request_environment_type_0 = cls()
31
+
32
+ task_submit_request_environment_type_0.additional_properties = d
33
+ return task_submit_request_environment_type_0
34
+
35
+ @property
36
+ def additional_keys(self) -> list[str]:
37
+ return list(self.additional_properties.keys())
38
+
39
+ def __getitem__(self, key: str) -> str:
40
+ return self.additional_properties[key]
41
+
42
+ def __setitem__(self, key: str, value: str) -> None:
43
+ self.additional_properties[key] = value
44
+
45
+ def __delitem__(self, key: str) -> None:
46
+ del self.additional_properties[key]
47
+
48
+ def __contains__(self, key: str) -> bool:
49
+ return key in self.additional_properties