dtlpy 1.118.14__py3-none-any.whl → 1.119.5__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.
dtlpy/__version__.py CHANGED
@@ -1 +1 @@
1
- version = '1.118.14'
1
+ version = '1.119.5'
@@ -1168,13 +1168,6 @@ class Annotation(entities.BaseEntity):
1168
1168
  annotation_definition=dl.Box(top=10,left=10,bottom=100, right=100,label='labelName'))
1169
1169
  )
1170
1170
  """
1171
- # handle fps
1172
- if self.fps is None:
1173
- if self._item is not None:
1174
- if self._item.fps is not None:
1175
- self.fps = self._item.fps
1176
- if self.fps is None:
1177
- raise PlatformException('400', 'Annotation must have fps in order to perform this action')
1178
1171
 
1179
1172
  # if this is first frame
1180
1173
  if self.annotation_definition is None:
dtlpy/entities/app.py CHANGED
@@ -48,6 +48,7 @@ class App(entities.BaseEntity):
48
48
  metadata = attr.ib(type=dict)
49
49
  status = attr.ib(type=entities.CompositionStatus)
50
50
  settings = attr.ib(type=dict)
51
+ dpk = attr.ib(type=entities.Dpk)
51
52
 
52
53
  # sdk
53
54
  _project = attr.ib(type=entities.Project, repr=False)
@@ -57,11 +58,12 @@ class App(entities.BaseEntity):
57
58
 
58
59
  @_repositories.default
59
60
  def set_repositories(self):
60
- reps = namedtuple('repositories', field_names=['projects', 'apps', 'compositions'])
61
+ reps = namedtuple('repositories', field_names=['projects', 'apps', 'compositions', 'models'])
61
62
  return reps(
62
63
  projects=repositories.Projects(client_api=self._client_api),
63
64
  apps=repositories.Apps(client_api=self._client_api, project=self._project, project_id=self.project_id),
64
- compositions=repositories.Compositions(client_api=self._client_api, project=self._project)
65
+ compositions=repositories.Compositions(client_api=self._client_api, project=self._project),
66
+ models=repositories.Models(client_api=self._client_api, app=self)
65
67
  )
66
68
 
67
69
  @property
@@ -80,6 +82,11 @@ class App(entities.BaseEntity):
80
82
  assert isinstance(self._repositories.apps, repositories.Apps)
81
83
  return self._repositories.apps
82
84
 
85
+ @property
86
+ def models(self):
87
+ assert isinstance(self._repositories.models, repositories.Models)
88
+ return self._repositories.models
89
+
83
90
  @property
84
91
  def compositions(self):
85
92
  assert isinstance(self._repositories.compositions, repositories.Compositions)
@@ -141,15 +148,15 @@ class App(entities.BaseEntity):
141
148
  :return:
142
149
  """
143
150
  try:
144
- package = App.from_json(_json=_json,
145
- client_api=client_api,
146
- project=project,
147
- is_fetched=is_fetched)
151
+ app = App.from_json(_json=_json,
152
+ client_api=client_api,
153
+ project=project,
154
+ is_fetched=is_fetched)
148
155
  status = True
149
156
  except Exception:
150
- package = traceback.format_exc()
157
+ app = traceback.format_exc()
151
158
  status = False
152
- return status, package
159
+ return status, app
153
160
 
154
161
  def to_json(self):
155
162
  _json = {}
@@ -189,6 +196,8 @@ class App(entities.BaseEntity):
189
196
  _json['settings'] = self.settings
190
197
  if self.integrations is not None:
191
198
  _json['integrations'] = self.integrations
199
+ if self.dpk is not None:
200
+ _json['dpk'] = self.dpk.to_json()
192
201
 
193
202
  return _json
194
203
 
@@ -214,7 +223,8 @@ class App(entities.BaseEntity):
214
223
  metadata=_json.get('metadata', None),
215
224
  status=_json.get('status', None),
216
225
  settings=_json.get('settings', {}),
217
- integrations=_json.get('integrations', None)
226
+ integrations=_json.get('integrations', None),
227
+ dpk=entities.Dpk.from_json(_json=_json.get('dpk', {}), client_api=client_api, project=project, is_fetched=is_fetched)
218
228
  )
219
229
  app.is_fetched = is_fetched
220
230
  return app
dtlpy/entities/compute.py CHANGED
@@ -1,8 +1,8 @@
1
1
  import traceback
2
2
  from enum import Enum
3
- from typing import List, Optional, Dict
3
+ from typing import List, Dict
4
4
  from ..services.api_client import ApiClient
5
- from .. import repositories
5
+ from .. import repositories, entities
6
6
 
7
7
 
8
8
  class ClusterProvider(str, Enum):
@@ -33,302 +33,164 @@ class ComputeConsumptionMethod(str, Enum):
33
33
  API = "API"
34
34
 
35
35
 
36
- class ComputeSettings:
37
- def __init__(self, default_namespace: str, consumption_method: ComputeConsumptionMethod):
38
- self.consumption_method = consumption_method
39
- self.default_namespace = default_namespace
36
+ class ComputeSettings(entities.DlEntity):
37
+ default_namespace: str = entities.DlProperty(location=['defaultNamespace'], _type=str)
38
+ consumption_method: str = entities.DlProperty(location=['consumptionMethod'], _type=str)
39
+
40
+ def to_json(self) -> dict:
41
+ return self._dict.copy()
40
42
 
41
43
  @classmethod
42
44
  def from_json(cls, _json):
43
- return cls(
44
- default_namespace=_json.get('defaultNamespace'),
45
- consumption_method=_json.get('consumptionMethod')
46
- )
47
-
48
- def to_json(self):
49
- return {
50
- 'defaultNamespace': self.default_namespace,
51
- 'consumptionMethod': self.consumption_method
52
- }
45
+ return cls(_dict=_json)
53
46
 
54
47
 
55
- class Toleration:
56
- def __init__(self, effect: str, key: str, operator: str, value: str):
57
- self.effect = effect
58
- self.key = key
59
- self.operator = operator
60
- self.value = value
48
+ class Toleration(entities.DlEntity):
49
+ effect: str = entities.DlProperty(location=['effect'], _type=str)
50
+ key: str = entities.DlProperty(location=['key'], _type=str)
51
+ operator: str = entities.DlProperty(location=['operator'], _type=str)
52
+ value: str = entities.DlProperty(location=['value'], _type=str)
53
+
54
+ def to_json(self) -> dict:
55
+ return self._dict.copy()
61
56
 
62
57
  @classmethod
63
58
  def from_json(cls, _json):
64
- return cls(
65
- effect=_json.get('effect'),
66
- key=_json.get('key'),
67
- operator=_json.get('operator'),
68
- value=_json.get('value')
69
- )
70
-
71
- def to_json(self):
72
- return {
73
- 'effect': self.effect,
74
- 'key': self.key,
75
- 'operator': self.operator,
76
- 'value': self.value
77
- }
59
+ return cls(_dict=_json)
78
60
 
79
61
 
80
- class DeploymentResource:
81
- def __init__(self, gpu: int, cpu: int, memory: str):
82
- self.gpu = gpu
83
- self.cpu = cpu
84
- self.memory = memory
62
+ class DeploymentResource(entities.DlEntity):
63
+ gpu: int = entities.DlProperty(location=['gpu'], _type=int)
64
+ cpu: int = entities.DlProperty(location=['cpu'], _type=int)
65
+ memory: str = entities.DlProperty(location=['memory'], _type=str)
85
66
 
86
- @classmethod
87
- def from_json(cls, _json):
88
- return cls(
89
- gpu=_json.get('gpu', None),
90
- cpu=_json.get('cpu', None),
91
- memory=_json.get('memory', None)
92
- )
93
-
94
- def to_json(self):
95
- _json = {}
96
- if self.gpu is not None:
97
- _json['gpu'] = self.gpu
98
- if self.cpu is not None:
99
- _json['cpu'] = self.cpu
100
- if self.memory is not None:
101
- _json['memory'] = self.memory
102
-
103
-
104
- class DeploymentResources:
105
- def __init__(self, request: DeploymentResource, limit: DeploymentResource):
106
- self.request = request
107
- self.limit = limit
67
+ def to_json(self) -> dict:
68
+ return self._dict.copy()
108
69
 
109
70
  @classmethod
110
71
  def from_json(cls, _json):
111
- return cls(
112
- request=DeploymentResource.from_json(_json.get('request') or dict()),
113
- limit=DeploymentResource.from_json(_json.get('limit') or dict())
114
- )
115
-
116
- def to_json(self):
117
- return {
118
- 'request': self.request.to_json(),
119
- 'limit': self.limit.to_json()
120
- }
72
+ return cls(_dict=_json)
73
+
121
74
 
75
+ class DeploymentResources(entities.DlEntity):
76
+ request: DeploymentResource = entities.DlProperty(location=['request'], _kls='DeploymentResource')
77
+ limit: DeploymentResource = entities.DlProperty(location=['limit'], _kls='DeploymentResource')
122
78
 
123
- class NodePool:
124
- def __init__(
125
- self,
126
- name: str,
127
- is_dl_type_default: bool,
128
- dl_types: Optional[List[str]] = None,
129
- tolerations: Optional[List[Toleration]] = None,
130
- description: str = "",
131
- node_selector: str = "",
132
- preemptible: bool = False,
133
- deployment_resources: DeploymentResources = None
134
- ):
135
- self.name = name
136
- self.is_dl_type_default = is_dl_type_default
137
- self.dl_types = dl_types
138
- self.tolerations = tolerations if tolerations is not None else []
139
- self.description = description
140
- self.node_selector = node_selector
141
- self.preemptible = preemptible
142
- self.deployment_resources = deployment_resources
79
+ def to_json(self) -> dict:
80
+ return self._dict.copy()
143
81
 
144
82
  @classmethod
145
83
  def from_json(cls, _json):
146
- node_pool = cls(
147
- name=_json.get('name'),
148
- is_dl_type_default=_json.get('isDlTypeDefault'),
149
- dl_types=_json.get('dlTypes'),
150
- description=_json.get('description'),
151
- node_selector=_json.get('nodeSelector'),
152
- preemptible=_json.get('preemptible'),
153
- deployment_resources=DeploymentResources.from_json(_json.get('deploymentResources', dict())),
154
- tolerations=[Toleration.from_json(t) for t in _json.get('tolerations', list())]
155
- )
156
-
157
- return node_pool
158
-
159
- def to_json(self):
160
- _json = {
161
- 'name': self.name,
162
- 'isDlTypeDefault': self.is_dl_type_default,
163
- 'description': self.description,
164
- 'nodeSelector': self.node_selector,
165
- 'preemptible': self.preemptible,
166
- 'deploymentResources': self.deployment_resources.to_json(),
167
- 'tolerations': [t.to_json() for t in self.tolerations]
168
- }
84
+ return cls(_dict=_json)
169
85
 
170
- if self.dl_types is not None:
171
- _json['dlTypes'] = self.dl_types
172
86
 
173
- return _json
87
+ class NodePool(entities.DlEntity):
88
+ name: str = entities.DlProperty(location=['name'], _type=str)
89
+ is_dl_type_default: bool = entities.DlProperty(location=['isDlTypeDefault'], _type=bool)
90
+ is_monitoring_configuration: bool = entities.DlProperty(location=['isMonitoringConfiguration'], _type=bool)
91
+ dl_types: List[str] = entities.DlProperty(location=['dlTypes'], _type=list)
92
+ tolerations: List[Toleration] = entities.DlProperty(location=['tolerations'], _kls='Toleration', default=[])
93
+ description: str = entities.DlProperty(location=['description'], _type=str, default='')
94
+ node_selector: str = entities.DlProperty(location=['nodeSelector'], _type=str, default='')
95
+ preemptible: bool = entities.DlProperty(location=['preemptible'], _type=bool, default=False)
96
+ deployment_resources: DeploymentResources = entities.DlProperty(location=['deploymentResources'], _kls='DeploymentResources')
174
97
 
175
-
176
- class AuthenticationIntegration:
177
- def __init__(self, id: str, type: str):
178
- self.id = id
179
- self.type = type
98
+ def to_json(self) -> dict:
99
+ return self._dict.copy()
180
100
 
181
101
  @classmethod
182
102
  def from_json(cls, _json):
183
- return cls(
184
- id=_json.get('id'),
185
- type=_json.get('type')
186
- )
187
-
188
- def to_json(self):
189
- return {
190
- 'id': self.id,
191
- 'type': self.type
192
- }
103
+ return cls(_dict=_json)
193
104
 
194
105
 
195
- class Authentication:
196
- def __init__(self, integration: AuthenticationIntegration):
197
- self.integration = integration
106
+ class AuthenticationIntegration(entities.DlEntity):
107
+ id: str = entities.DlProperty(location=['id'], _type=str)
108
+ type: str = entities.DlProperty(location=['type'], _type=str)
109
+
110
+ def to_json(self) -> dict:
111
+ return self._dict.copy()
198
112
 
199
113
  @classmethod
200
114
  def from_json(cls, _json):
201
- return cls(
202
- integration=AuthenticationIntegration.from_json(_json.get('integration', dict()))
203
- )
115
+ return cls(_dict=_json)
204
116
 
205
- def to_json(self):
206
- return {
207
- 'integration': self.integration.to_json()
208
- }
209
117
 
118
+ class Authentication(entities.DlEntity):
119
+ integration: AuthenticationIntegration = entities.DlProperty(location=['integration'], _kls='AuthenticationIntegration')
210
120
 
211
- class ComputeCluster:
212
- def __init__(
213
- self,
214
- name: str,
215
- endpoint: str,
216
- kubernetes_version: str,
217
- provider: ClusterProvider,
218
- node_pools: Optional[List[NodePool]] = None,
219
- metadata: Optional[Dict] = None,
220
- authentication: Optional[Authentication] = None,
221
- plugins: Optional[dict] = None,
222
- deployment_configuration: Optional[Dict] = None
223
- ):
224
- self.name = name
225
- self.endpoint = endpoint
226
- self.kubernetes_version = kubernetes_version
227
- self.provider = provider
228
- self.node_pools = node_pools if node_pools is not None else []
229
- self.metadata = metadata if metadata is not None else {}
230
- self.authentication = authentication if authentication is not None else Authentication(
231
- AuthenticationIntegration("", ""))
232
- self.plugins = plugins
233
- self.deployment_configuration = deployment_configuration if deployment_configuration is not None else {}
121
+ def to_json(self) -> dict:
122
+ return self._dict.copy()
234
123
 
124
+ @classmethod
125
+ def from_json(cls, _json):
126
+ return cls(_dict=_json)
235
127
 
236
128
 
129
+ class ComputeCluster(entities.DlEntity):
130
+ name: str = entities.DlProperty(location=['name'], _type=str)
131
+ endpoint: str = entities.DlProperty(location=['endpoint'], _type=str)
132
+ kubernetes_version: str = entities.DlProperty(location=['kubernetesVersion'], _type=str)
133
+ provider: str = entities.DlProperty(location=['provider'], _type=str)
134
+ node_pools: List[NodePool] = entities.DlProperty(location=['nodePools'], _kls='NodePool', default=[])
135
+ metadata: Dict = entities.DlProperty(location=['metadata'], _type=dict, default={})
136
+ authentication: Authentication = entities.DlProperty(location=['authentication'], _kls='Authentication')
137
+ plugins: dict = entities.DlProperty(location=['plugins'], _type=dict)
138
+ deployment_configuration: Dict = entities.DlProperty(location=['deploymentConfiguration'], _type=dict, default={})
139
+
140
+ def to_json(self) -> dict:
141
+ return self._dict.copy()
142
+
237
143
  @classmethod
238
144
  def from_json(cls, _json):
239
- return cls(
240
- name=_json.get('name'),
241
- endpoint=_json.get('endpoint'),
242
- kubernetes_version=_json.get('kubernetesVersion'),
243
- provider=ClusterProvider(_json.get('provider')),
244
- node_pools=[NodePool.from_json(np) for np in _json.get('nodePools', list())],
245
- metadata=_json.get('metadata'),
246
- authentication=Authentication.from_json(_json.get('authentication', dict())),
247
- plugins=_json.get('plugins'),
248
- deployment_configuration=_json.get('deploymentConfiguration'),
249
- )
250
-
251
- def to_json(self):
252
- return {
253
- 'name': self.name,
254
- 'endpoint': self.endpoint,
255
- 'kubernetesVersion': self.kubernetes_version,
256
- 'provider': self.provider.value,
257
- 'nodePools': [np.to_json() for np in self.node_pools],
258
- 'metadata': self.metadata,
259
- 'authentication': self.authentication.to_json(),
260
- 'plugins': self.plugins,
261
- 'deploymentConfiguration': self.deployment_configuration
262
- }
145
+ return cls(_dict=_json)
263
146
 
264
147
  @classmethod
265
148
  def from_setup_json(cls, devops_output, integration):
266
- node_pools = [NodePool.from_json(n) for n in devops_output['config']['nodePools']]
267
- return cls(
268
- name=devops_output['config']['name'],
269
- endpoint=devops_output['config']['endpoint'],
270
- kubernetes_version=devops_output['config']['kubernetesVersion'],
271
- provider=ClusterProvider(devops_output['config']['provider']),
272
- node_pools=node_pools,
273
- metadata={},
274
- authentication=Authentication(AuthenticationIntegration(integration.id, integration.type)),
275
- plugins=devops_output['config'].get('plugins'),
276
- deployment_configuration=devops_output['config'].get('deploymentConfiguration', {})
277
- )
278
-
279
-
280
- class ComputeContext:
281
- def __init__(self, labels: List[str], org: str, project: Optional[str] = None):
282
- self.labels = labels
283
- self.org = org
284
- self.project = project
285
-
286
- @classmethod
287
- def from_json(cls, _json):
288
- return cls(
289
- labels=_json.get('labels', list()),
290
- org=_json.get('org'),
291
- project=_json.get('project')
292
- )
293
-
294
- def to_json(self):
295
- return {
296
- 'labels': self.labels,
297
- 'org': self.org,
298
- 'project': self.project
149
+ _json = {
150
+ 'name': devops_output['config']['name'],
151
+ 'endpoint': devops_output['config']['endpoint'],
152
+ 'kubernetesVersion': devops_output['config']['kubernetesVersion'],
153
+ 'provider': devops_output['config']['provider'],
154
+ 'nodePools': devops_output['config']['nodePools'],
155
+ 'metadata': {},
156
+ 'authentication': {'integration': {'id': integration.id, 'type': integration.type}},
157
+ 'plugins': devops_output['config'].get('plugins'),
158
+ 'deploymentConfiguration': devops_output['config'].get('deploymentConfiguration', {})
299
159
  }
160
+ return cls(_dict=_json)
161
+
300
162
 
163
+ class ComputeContext(entities.DlEntity):
164
+ labels: List[str] = entities.DlProperty(location=['labels'], _type=list, default=[])
165
+ org: str = entities.DlProperty(location=['org'], _type=str)
166
+ project: str = entities.DlProperty(location=['project'], _type=str)
301
167
 
302
- class Compute:
303
- def __init__(
304
- self,
305
- id: str,
306
- name: str,
307
- context: ComputeContext,
308
- client_api: ApiClient,
309
- shared_contexts: Optional[List[ComputeContext]] = None,
310
- global_: Optional[bool] = None,
311
- status: ComputeStatus = ComputeStatus.INITIALIZING,
312
- type: ComputeType = ComputeType.KUBERNETES,
313
- features: Optional[Dict] = None,
314
- metadata: Optional[Dict] = None,
315
- settings: Optional[ComputeSettings] = None,
316
- url: Optional[str] = None
317
- ):
318
- self.id = id
319
- self.name = name
320
- self.context = context
321
- self.shared_contexts = shared_contexts if shared_contexts is not None else []
322
- self.global_ = global_
323
- self.status = status
324
- self.type = type
325
- self.features = features if features is not None else dict()
326
- self.metadata = metadata if metadata is not None else dict()
168
+ def to_json(self) -> dict:
169
+ return self._dict.copy()
170
+
171
+ @classmethod
172
+ def from_json(cls, _json):
173
+ return cls(_dict=_json)
174
+
175
+
176
+ class Compute(entities.DlEntity):
177
+ id: str = entities.DlProperty(location=['id'], _type=str)
178
+ name: str = entities.DlProperty(location=['name'], _type=str)
179
+ context: ComputeContext = entities.DlProperty(location=['context'], _kls='ComputeContext')
180
+ shared_contexts: List[ComputeContext] = entities.DlProperty(location=['sharedContexts'], _kls='ComputeContext', default=[])
181
+ global_: bool = entities.DlProperty(location=['global'], _type=bool)
182
+ status: str = entities.DlProperty(location=['status'], _type=str, default=ComputeStatus.INITIALIZING.value)
183
+ type: str = entities.DlProperty(location=['type'], _type=str, default=ComputeType.KUBERNETES.value)
184
+ features: Dict = entities.DlProperty(location=['features'], _type=dict, default={})
185
+ metadata: Dict = entities.DlProperty(location=['metadata'], _type=dict, default={})
186
+ settings: ComputeSettings = entities.DlProperty(location=['settings'], _kls='ComputeSettings')
187
+ url: str = entities.DlProperty(location=['url'], _type=str)
188
+
189
+ def __init__(self, _dict=None, client_api: ApiClient = None, **kwargs):
190
+ super().__init__(_dict=_dict, **kwargs)
327
191
  self._client_api = client_api
328
192
  self._computes = None
329
193
  self._serviceDrivers = None
330
- self.settings = settings
331
- self.url = url
332
194
 
333
195
  @property
334
196
  def computes(self):
@@ -362,89 +224,18 @@ class Compute:
362
224
 
363
225
  @classmethod
364
226
  def from_json(cls, _json, client_api: ApiClient):
365
- return cls(
366
- id=_json.get('id'),
367
- name=_json.get('name'),
368
- context=ComputeContext.from_json(_json.get('context', dict())),
369
- shared_contexts=[ComputeContext.from_json(sc) for sc in _json.get('sharedContexts', list())],
370
- global_=_json.get('global'),
371
- status=ComputeStatus(_json.get('status')),
372
- type=ComputeType(_json.get('type')),
373
- features=_json.get('features'),
374
- client_api=client_api,
375
- metadata=_json.get('metadata'),
376
- settings=ComputeSettings.from_json(_json.get('settings', dict())) if _json.get('settings') else None,
377
- url=_json.get('url'),
378
- )
379
-
380
- def to_json(self):
381
- return {
382
- 'id': self.id,
383
- 'name': self.name,
384
- 'context': self.context.to_json(),
385
- 'sharedContexts': [sc.to_json() for sc in self.shared_contexts],
386
- 'global': self.global_,
387
- 'status': self.status.value,
388
- 'type': self.type.value,
389
- 'features': self.features,
390
- 'metadata': self.metadata,
391
- 'settings': self.settings.to_json() if isinstance(self.settings, ComputeSettings) else self.settings,
392
- 'url': self.url
393
- }
227
+ return cls(_dict=_json, client_api=client_api)
228
+
229
+ def to_json(self) -> dict:
230
+ return self._dict.copy()
394
231
 
395
232
 
396
233
  class KubernetesCompute(Compute):
397
- def __init__(
398
- self,
399
- id: str,
400
- name: str,
401
- context: ComputeContext,
402
- cluster: ComputeCluster,
403
- shared_contexts: Optional[List[ComputeContext]] = None,
404
- global_: Optional[bool] = None,
405
- status: ComputeStatus = ComputeStatus.INITIALIZING,
406
- type: ComputeType = ComputeType.KUBERNETES,
407
- features: Optional[Dict] = None,
408
- metadata: Optional[Dict] = None,
409
- client_api: ApiClient = None,
410
- settings: Optional[ComputeSettings] = None,
411
- url: Optional[str] = None
412
- ):
413
- super().__init__(id=id, context=context, shared_contexts=shared_contexts, global_=global_, status=status,
414
- type=type, features=features, metadata=metadata, client_api=client_api, settings=settings,
415
- name=name, url=url)
416
- self.cluster = cluster
234
+ cluster: ComputeCluster = entities.DlProperty(location=['cluster'], _kls='ComputeCluster')
417
235
 
418
236
  @classmethod
419
237
  def from_json(cls, _json, client_api: ApiClient):
420
- return cls(
421
- id=_json.get('id'),
422
- name=_json.get('name'),
423
- context=ComputeContext.from_json(_json.get('context', dict())),
424
- cluster=ComputeCluster.from_json(_json.get('cluster', dict())),
425
- shared_contexts=[ComputeContext.from_json(sc) for sc in _json.get('sharedContexts', list())],
426
- global_=_json.get('global'),
427
- status=ComputeStatus(_json.get('status')),
428
- type=ComputeType(_json.get('type')),
429
- features=_json.get('features'),
430
- metadata=_json.get('metadata'),
431
- client_api=client_api,
432
- settings=ComputeSettings.from_json(_json.get('settings', dict())) if _json.get('settings') else None,
433
- url=_json.get('url')
434
- )
435
-
436
- def to_json(self):
437
- return {
438
- 'id': self.id,
439
- 'name': self.name,
440
- 'context': self.context.to_json(),
441
- 'cluster': self.cluster.to_json(),
442
- 'sharedContexts': [sc.to_json() for sc in self.shared_contexts],
443
- 'global': self.global_,
444
- 'status': self.status.value,
445
- 'type': self.type.value,
446
- 'features': self.features,
447
- 'metadata': self.metadata,
448
- 'settings': self.settings.to_json() if isinstance(self.settings, ComputeSettings) else self.settings,
449
- 'url': self.url
450
- }
238
+ return cls(_dict=_json, client_api=client_api)
239
+
240
+ def to_json(self) -> dict:
241
+ return self._dict.copy()