dtlpy 1.114.13__py3-none-any.whl → 1.114.15__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/__init__.py +4 -1
- dtlpy/__version__.py +1 -1
- dtlpy/assets/__pycache__/{__init__.cpython-38.pyc → __init__.cpython-310.pyc} +0 -0
- dtlpy/entities/__init__.py +1 -1
- dtlpy/entities/driver.py +3 -2
- dtlpy/entities/filters.py +165 -161
- dtlpy/entities/model.py +14 -24
- dtlpy/entities/paged_entities.py +14 -5
- dtlpy/entities/pipeline.py +31 -0
- dtlpy/entities/task.py +4 -0
- dtlpy/ml/base_model_adapter.py +208 -67
- dtlpy/new_instance.py +1 -1
- dtlpy/repositories/downloader.py +18 -10
- dtlpy/repositories/dpks.py +1 -1
- dtlpy/repositories/drivers.py +293 -81
- dtlpy/repositories/models.py +137 -26
- dtlpy/repositories/pipeline_executions.py +14 -11
- dtlpy/repositories/pipelines.py +179 -181
- dtlpy/repositories/tasks.py +711 -359
- {dtlpy-1.114.13.dist-info → dtlpy-1.114.15.dist-info}/METADATA +14 -3
- {dtlpy-1.114.13.dist-info → dtlpy-1.114.15.dist-info}/RECORD +28 -28
- {dtlpy-1.114.13.dist-info → dtlpy-1.114.15.dist-info}/WHEEL +1 -1
- {dtlpy-1.114.13.data → dtlpy-1.114.15.data}/scripts/dlp +0 -0
- {dtlpy-1.114.13.data → dtlpy-1.114.15.data}/scripts/dlp.bat +0 -0
- {dtlpy-1.114.13.data → dtlpy-1.114.15.data}/scripts/dlp.py +0 -0
- {dtlpy-1.114.13.dist-info → dtlpy-1.114.15.dist-info}/entry_points.txt +0 -0
- {dtlpy-1.114.13.dist-info → dtlpy-1.114.15.dist-info/licenses}/LICENSE +0 -0
- {dtlpy-1.114.13.dist-info → dtlpy-1.114.15.dist-info}/top_level.txt +0 -0
dtlpy/repositories/pipelines.py
CHANGED
|
@@ -2,7 +2,7 @@ import logging
|
|
|
2
2
|
from .. import entities, repositories, exceptions, miscellaneous, _api_reference
|
|
3
3
|
from ..services.api_client import ApiClient
|
|
4
4
|
|
|
5
|
-
logger = logging.getLogger(name=
|
|
5
|
+
logger = logging.getLogger(name="dtlpy")
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def generate_basic_pipeline():
|
|
@@ -30,14 +30,15 @@ class Pipelines:
|
|
|
30
30
|
self._project = repositories.Projects(client_api=self._client_api).get()
|
|
31
31
|
except exceptions.NotFound:
|
|
32
32
|
raise exceptions.PlatformException(
|
|
33
|
-
error=
|
|
34
|
-
message='Missing "project". need to set a Project entity or use project.pipelines repository'
|
|
33
|
+
error="2001",
|
|
34
|
+
message='Missing "project". need to set a Project entity or use project.pipelines repository',
|
|
35
|
+
)
|
|
35
36
|
return self._project
|
|
36
37
|
|
|
37
38
|
@project.setter
|
|
38
39
|
def project(self, project: entities.Project):
|
|
39
40
|
if not isinstance(project, entities.Project):
|
|
40
|
-
raise ValueError(
|
|
41
|
+
raise ValueError("Must input a valid Project entity")
|
|
41
42
|
self._project = project
|
|
42
43
|
|
|
43
44
|
###########
|
|
@@ -47,10 +48,7 @@ class Pipelines:
|
|
|
47
48
|
def platform_url(self):
|
|
48
49
|
return self._client_api._get_resource_url("projects/{}/pipelines".format(self.project.id))
|
|
49
50
|
|
|
50
|
-
def open_in_web(self,
|
|
51
|
-
pipeline: entities.Pipeline = None,
|
|
52
|
-
pipeline_id: str = None,
|
|
53
|
-
pipeline_name: str = None):
|
|
51
|
+
def open_in_web(self, pipeline: entities.Pipeline = None, pipeline_id: str = None, pipeline_name: str = None):
|
|
54
52
|
"""
|
|
55
53
|
Open the pipeline in web platform.
|
|
56
54
|
|
|
@@ -71,16 +69,12 @@ class Pipelines:
|
|
|
71
69
|
if pipeline is not None:
|
|
72
70
|
pipeline.open_in_web()
|
|
73
71
|
elif pipeline_id is not None:
|
|
74
|
-
self._client_api._open_in_web(url=self.platform_url +
|
|
72
|
+
self._client_api._open_in_web(url=self.platform_url + "/" + str(pipeline_id))
|
|
75
73
|
else:
|
|
76
74
|
self._client_api._open_in_web(url=self.platform_url)
|
|
77
75
|
|
|
78
|
-
@_api_reference.add(path=
|
|
79
|
-
def get(self,
|
|
80
|
-
pipeline_name=None,
|
|
81
|
-
pipeline_id=None,
|
|
82
|
-
fetch=None
|
|
83
|
-
) -> entities.Pipeline:
|
|
76
|
+
@_api_reference.add(path="/pipelines/{pipelineId}", method="get")
|
|
77
|
+
def get(self, pipeline_name=None, pipeline_id=None, fetch=None) -> entities.Pipeline:
|
|
84
78
|
"""
|
|
85
79
|
Get Pipeline object to use in your code.
|
|
86
80
|
|
|
@@ -104,76 +98,63 @@ class Pipelines:
|
|
|
104
98
|
fetch = self._client_api.fetch_entities
|
|
105
99
|
|
|
106
100
|
if pipeline_name is None and pipeline_id is None:
|
|
107
|
-
raise exceptions.PlatformException(
|
|
108
|
-
error='400',
|
|
109
|
-
message='Must provide an identifier in inputs')
|
|
101
|
+
raise exceptions.PlatformException(error="400", message="Must provide an identifier in inputs")
|
|
110
102
|
elif fetch:
|
|
111
103
|
if pipeline_id is not None:
|
|
112
104
|
success, response = self._client_api.gen_request(
|
|
113
|
-
req_type="get",
|
|
114
|
-
|
|
105
|
+
req_type="get", path="/pipelines/{}".format(pipeline_id)
|
|
106
|
+
)
|
|
115
107
|
if not success:
|
|
116
108
|
raise exceptions.PlatformException(response)
|
|
117
109
|
pipeline = entities.Pipeline.from_json(
|
|
118
|
-
client_api=self._client_api,
|
|
119
|
-
_json=response.json(),
|
|
120
|
-
project=self._project
|
|
110
|
+
client_api=self._client_api, _json=response.json(), project=self._project
|
|
121
111
|
)
|
|
122
112
|
if pipeline_name is not None and pipeline.name != pipeline_name:
|
|
123
113
|
logger.warning(
|
|
124
114
|
"Mismatch found in pipeline.get: pipeline_name is different then pipeline.name:"
|
|
125
|
-
" {!r} != {!r}".format(
|
|
126
|
-
pipeline_name,
|
|
127
|
-
pipeline.name
|
|
128
|
-
)
|
|
115
|
+
" {!r} != {!r}".format(pipeline_name, pipeline.name)
|
|
129
116
|
)
|
|
130
117
|
elif pipeline_name is not None:
|
|
131
118
|
filters = entities.Filters(
|
|
132
|
-
field=
|
|
133
|
-
values=pipeline_name,
|
|
134
|
-
resource=entities.FiltersResource.PIPELINE,
|
|
135
|
-
use_defaults=False
|
|
119
|
+
field="name", values=pipeline_name, resource=entities.FiltersResource.PIPELINE, use_defaults=False
|
|
136
120
|
)
|
|
137
121
|
if self._project is not None:
|
|
138
|
-
filters.add(field=
|
|
122
|
+
filters.add(field="projectId", values=self._project.id)
|
|
139
123
|
pipelines = self.list(filters=filters)
|
|
140
124
|
if pipelines.items_count == 0:
|
|
141
125
|
raise exceptions.PlatformException(
|
|
142
|
-
error=
|
|
143
|
-
|
|
126
|
+
error="404", message="Pipeline not found. Name: {}".format(pipeline_name)
|
|
127
|
+
)
|
|
144
128
|
elif pipelines.items_count > 1:
|
|
145
129
|
raise exceptions.PlatformException(
|
|
146
|
-
error=
|
|
147
|
-
message=
|
|
148
|
-
|
|
130
|
+
error="400",
|
|
131
|
+
message="More than one pipelines found by the name of: {} "
|
|
132
|
+
"Please get pipeline from a project entity".format(pipeline_name),
|
|
133
|
+
)
|
|
149
134
|
pipeline = pipelines.items[0]
|
|
150
135
|
else:
|
|
151
136
|
raise exceptions.PlatformException(
|
|
152
|
-
error=
|
|
153
|
-
message=
|
|
137
|
+
error="400",
|
|
138
|
+
message="No checked-out pipeline was found, must checkout or provide an identifier in inputs",
|
|
139
|
+
)
|
|
154
140
|
else:
|
|
155
141
|
pipeline = entities.Pipeline.from_json(
|
|
156
|
-
_json={
|
|
157
|
-
'name': pipeline_name},
|
|
142
|
+
_json={"id": pipeline_id, "name": pipeline_name},
|
|
158
143
|
client_api=self._client_api,
|
|
159
144
|
project=self._project,
|
|
160
|
-
is_fetched=False
|
|
145
|
+
is_fetched=False,
|
|
161
146
|
)
|
|
162
147
|
|
|
163
148
|
return pipeline
|
|
164
149
|
|
|
165
150
|
def _build_entities_from_response(self, response_items) -> miscellaneous.List[entities.Pipeline]:
|
|
166
|
-
pool = self._client_api.thread_pools(pool_name=
|
|
151
|
+
pool = self._client_api.thread_pools(pool_name="entity.create")
|
|
167
152
|
jobs = [None for _ in range(len(response_items))]
|
|
168
153
|
|
|
169
154
|
for i_pipeline, pipeline in enumerate(response_items):
|
|
170
155
|
jobs[i_pipeline] = pool.submit(
|
|
171
156
|
entities.Pipeline._protected_from_json,
|
|
172
|
-
**{
|
|
173
|
-
'client_api': self._client_api,
|
|
174
|
-
'_json': pipeline,
|
|
175
|
-
'project': self._project
|
|
176
|
-
}
|
|
157
|
+
**{"client_api": self._client_api, "_json": pipeline, "project": self._project}
|
|
177
158
|
)
|
|
178
159
|
|
|
179
160
|
# get all results
|
|
@@ -186,23 +167,16 @@ class Pipelines:
|
|
|
186
167
|
return pipelines
|
|
187
168
|
|
|
188
169
|
def _list(self, filters: entities.Filters):
|
|
189
|
-
url =
|
|
170
|
+
url = "/pipelines/query"
|
|
190
171
|
|
|
191
172
|
# request
|
|
192
|
-
success, response = self._client_api.gen_request(
|
|
193
|
-
req_type='post',
|
|
194
|
-
path=url,
|
|
195
|
-
json_req=filters.prepare()
|
|
196
|
-
)
|
|
173
|
+
success, response = self._client_api.gen_request(req_type="post", path=url, json_req=filters.prepare())
|
|
197
174
|
if not success:
|
|
198
175
|
raise exceptions.PlatformException(response)
|
|
199
176
|
return response.json()
|
|
200
177
|
|
|
201
|
-
@_api_reference.add(path=
|
|
202
|
-
def list(self,
|
|
203
|
-
filters: entities.Filters = None,
|
|
204
|
-
project_id: str = None
|
|
205
|
-
) -> entities.PagedEntities:
|
|
178
|
+
@_api_reference.add(path="/pipelines/query", method="post")
|
|
179
|
+
def list(self, filters: entities.Filters = None, project_id: str = None) -> entities.PagedEntities:
|
|
206
180
|
"""
|
|
207
181
|
List project pipelines.
|
|
208
182
|
|
|
@@ -223,59 +197,57 @@ class Pipelines:
|
|
|
223
197
|
filters = entities.Filters(resource=entities.FiltersResource.PIPELINE)
|
|
224
198
|
# assert type filters
|
|
225
199
|
elif not isinstance(filters, entities.Filters):
|
|
226
|
-
raise exceptions.PlatformException(error=
|
|
227
|
-
message='Unknown filters type: {!r}'.format(type(filters)))
|
|
200
|
+
raise exceptions.PlatformException(error="400", message="Unknown filters type: {!r}".format(type(filters)))
|
|
228
201
|
if filters.resource != entities.FiltersResource.PIPELINE:
|
|
229
202
|
raise exceptions.PlatformException(
|
|
230
|
-
error=
|
|
231
|
-
message=
|
|
203
|
+
error="400",
|
|
204
|
+
message="Filters resource must to be FiltersResource.PIPELINE. Got: {!r}".format(filters.resource),
|
|
205
|
+
)
|
|
232
206
|
|
|
233
207
|
if project_id is None and self._project is not None:
|
|
234
208
|
project_id = self._project.id
|
|
235
209
|
|
|
236
210
|
if project_id is not None:
|
|
237
|
-
filters.add(field=
|
|
238
|
-
|
|
239
|
-
paged = entities.PagedEntities(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
211
|
+
filters.add(field="projectId", values=project_id)
|
|
212
|
+
|
|
213
|
+
paged = entities.PagedEntities(
|
|
214
|
+
items_repository=self,
|
|
215
|
+
filters=filters,
|
|
216
|
+
page_offset=filters.page,
|
|
217
|
+
page_size=filters.page_size,
|
|
218
|
+
project_id=project_id,
|
|
219
|
+
client_api=self._client_api,
|
|
220
|
+
)
|
|
245
221
|
paged.get_page()
|
|
246
222
|
return paged
|
|
247
223
|
|
|
248
224
|
def _name_validation(self, name: str):
|
|
249
|
-
url =
|
|
225
|
+
url = "/piper-misc/naming/packages/{}".format(name)
|
|
250
226
|
|
|
251
227
|
# request
|
|
252
|
-
success, response = self._client_api.gen_request(req_type=
|
|
253
|
-
path=url)
|
|
228
|
+
success, response = self._client_api.gen_request(req_type="get", path=url)
|
|
254
229
|
if not success:
|
|
255
230
|
raise exceptions.PlatformException(response)
|
|
256
231
|
|
|
257
232
|
# @_api_reference.add(path='/pipelines/{pipelineId}', method='delete')
|
|
258
|
-
def delete(self,
|
|
259
|
-
pipeline: entities.Pipeline = None,
|
|
260
|
-
pipeline_name: str = None,
|
|
261
|
-
pipeline_id: str = None):
|
|
233
|
+
def delete(self, pipeline: entities.Pipeline = None, pipeline_name: str = None, pipeline_id: str = None):
|
|
262
234
|
"""
|
|
263
|
-
|
|
235
|
+
Delete Pipeline object.
|
|
264
236
|
|
|
265
|
-
|
|
237
|
+
**prerequisites**: You must be an *owner* or *developer* to use this method.
|
|
266
238
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
239
|
+
:param dtlpy.entities.pipeline.Pipeline pipeline: pipeline entity
|
|
240
|
+
:param str pipeline_id: pipeline id
|
|
241
|
+
:param str pipeline_name: pipeline name
|
|
242
|
+
:return: True if success
|
|
243
|
+
:rtype: bool
|
|
272
244
|
|
|
273
|
-
|
|
245
|
+
**Example**:
|
|
274
246
|
|
|
275
|
-
|
|
247
|
+
.. code-block:: python
|
|
276
248
|
|
|
277
|
-
|
|
278
|
-
|
|
249
|
+
is_deleted = project.pipelines.delete(pipeline_id='pipeline_id')
|
|
250
|
+
"""
|
|
279
251
|
# get id and name
|
|
280
252
|
if pipeline_id is None:
|
|
281
253
|
if pipeline is None:
|
|
@@ -283,8 +255,7 @@ class Pipelines:
|
|
|
283
255
|
pipeline_id = pipeline.id
|
|
284
256
|
|
|
285
257
|
# request
|
|
286
|
-
success, response = self._client_api.gen_request(req_type="delete",
|
|
287
|
-
path="/pipelines/{}".format(pipeline_id))
|
|
258
|
+
success, response = self._client_api.gen_request(req_type="delete", path="/pipelines/{}".format(pipeline_id))
|
|
288
259
|
|
|
289
260
|
# exception handling
|
|
290
261
|
if not success:
|
|
@@ -293,7 +264,7 @@ class Pipelines:
|
|
|
293
264
|
# return results
|
|
294
265
|
return True
|
|
295
266
|
|
|
296
|
-
@_api_reference.add(path=
|
|
267
|
+
@_api_reference.add(path="/pipelines/{pipelineId}/settings", method="patch")
|
|
297
268
|
def update_settings(self, pipeline: entities.Pipeline, settings: entities.PipelineSettings):
|
|
298
269
|
"""
|
|
299
270
|
Update pipeline settings.
|
|
@@ -312,55 +283,41 @@ class Pipelines:
|
|
|
312
283
|
pipeline = project.pipelines.update_settings(pipeline='pipeline_entity', settings=dl.PipelineSettings(keep_triggers_active=True))
|
|
313
284
|
"""
|
|
314
285
|
# payload
|
|
315
|
-
payload = {
|
|
286
|
+
payload = {"settings": settings.to_json()}
|
|
316
287
|
|
|
317
288
|
# request
|
|
318
289
|
success, response = self._client_api.gen_request(
|
|
319
|
-
req_type=
|
|
320
|
-
path='/pipelines/{}'.format(pipeline.id),
|
|
321
|
-
json_req=payload
|
|
290
|
+
req_type="patch", path="/pipelines/{}".format(pipeline.id), json_req=payload
|
|
322
291
|
)
|
|
323
292
|
if not success:
|
|
324
293
|
raise exceptions.PlatformException(response)
|
|
325
294
|
|
|
326
295
|
# return entity
|
|
327
|
-
return entities.Pipeline.from_json(
|
|
328
|
-
_json=response.json(),
|
|
329
|
-
client_api=self._client_api,
|
|
330
|
-
project=self._project
|
|
331
|
-
)
|
|
296
|
+
return entities.Pipeline.from_json(_json=response.json(), client_api=self._client_api, project=self._project)
|
|
332
297
|
|
|
333
298
|
def __update_variables(self, pipeline: entities.Pipeline):
|
|
334
299
|
pipeline_json = pipeline.to_json()
|
|
335
|
-
variables = pipeline_json.get(
|
|
300
|
+
variables = pipeline_json.get("variables", list())
|
|
336
301
|
|
|
337
302
|
for var in variables:
|
|
338
|
-
if var.get(
|
|
339
|
-
var[
|
|
303
|
+
if var.get("reference", None) is None:
|
|
304
|
+
var["reference"] = pipeline.id
|
|
340
305
|
|
|
341
306
|
# payload
|
|
342
|
-
payload = {
|
|
307
|
+
payload = {"variables": variables}
|
|
343
308
|
|
|
344
309
|
# request
|
|
345
310
|
success, response = self._client_api.gen_request(
|
|
346
|
-
req_type=
|
|
347
|
-
path='/pipelines/{}/variables'.format(pipeline.id),
|
|
348
|
-
json_req=payload
|
|
311
|
+
req_type="patch", path="/pipelines/{}/variables".format(pipeline.id), json_req=payload
|
|
349
312
|
)
|
|
350
313
|
if not success:
|
|
351
314
|
raise exceptions.PlatformException(response)
|
|
352
315
|
|
|
353
316
|
# return entity
|
|
354
|
-
return entities.Pipeline.from_json(
|
|
355
|
-
_json=response.json(),
|
|
356
|
-
client_api=self._client_api,
|
|
357
|
-
project=self._project
|
|
358
|
-
)
|
|
317
|
+
return entities.Pipeline.from_json(_json=response.json(), client_api=self._client_api, project=self._project)
|
|
359
318
|
|
|
360
|
-
@_api_reference.add(path=
|
|
361
|
-
def update(self,
|
|
362
|
-
pipeline: entities.Pipeline = None
|
|
363
|
-
) -> entities.Pipeline:
|
|
319
|
+
@_api_reference.add(path="/pipelines/{pipelineId}", method="patch")
|
|
320
|
+
def update(self, pipeline: entities.Pipeline = None) -> entities.Pipeline:
|
|
364
321
|
"""
|
|
365
322
|
Update pipeline changes to platform.
|
|
366
323
|
|
|
@@ -382,17 +339,15 @@ class Pipelines:
|
|
|
382
339
|
# update settings
|
|
383
340
|
if pipeline.settings_changed():
|
|
384
341
|
new_pipeline = self.update_settings(pipeline=pipeline, settings=pipeline.settings)
|
|
385
|
-
payload[
|
|
342
|
+
payload["settings"] = new_pipeline.to_json().get("settings", payload.get("settings"))
|
|
386
343
|
|
|
387
344
|
# update variables
|
|
388
345
|
if pipeline.variables_changed():
|
|
389
346
|
new_pipeline = self.__update_variables(pipeline=pipeline)
|
|
390
|
-
payload[
|
|
347
|
+
payload["variables"] = new_pipeline.to_json().get("variables", payload.get("variables"))
|
|
391
348
|
|
|
392
349
|
success, response = self._client_api.gen_request(
|
|
393
|
-
req_type=
|
|
394
|
-
path='/pipelines/{}'.format(pipeline.id),
|
|
395
|
-
json_req=payload
|
|
350
|
+
req_type="patch", path="/pipelines/{}".format(pipeline.id), json_req=payload
|
|
396
351
|
)
|
|
397
352
|
|
|
398
353
|
# exception handling
|
|
@@ -400,18 +355,10 @@ class Pipelines:
|
|
|
400
355
|
raise exceptions.PlatformException(response)
|
|
401
356
|
|
|
402
357
|
# return entity
|
|
403
|
-
return entities.Pipeline.from_json(
|
|
404
|
-
_json=response.json(),
|
|
405
|
-
client_api=self._client_api,
|
|
406
|
-
project=self._project
|
|
407
|
-
)
|
|
358
|
+
return entities.Pipeline.from_json(_json=response.json(), client_api=self._client_api, project=self._project)
|
|
408
359
|
|
|
409
|
-
@_api_reference.add(path=
|
|
410
|
-
def create(self,
|
|
411
|
-
name: str = None,
|
|
412
|
-
project_id: str = None,
|
|
413
|
-
pipeline_json: dict = None
|
|
414
|
-
) -> entities.Pipeline:
|
|
360
|
+
@_api_reference.add(path="/pipelines", method="post")
|
|
361
|
+
def create(self, name: str = None, project_id: str = None, pipeline_json: dict = None) -> entities.Pipeline:
|
|
415
362
|
"""
|
|
416
363
|
Create a new pipeline.
|
|
417
364
|
|
|
@@ -433,27 +380,25 @@ class Pipelines:
|
|
|
433
380
|
pipeline_json = generate_basic_pipeline()
|
|
434
381
|
|
|
435
382
|
if name is not None:
|
|
436
|
-
pipeline_json[
|
|
383
|
+
pipeline_json["name"] = name
|
|
437
384
|
|
|
438
385
|
if project_id is not None:
|
|
439
|
-
pipeline_json[
|
|
386
|
+
pipeline_json["projectId"] = project_id
|
|
440
387
|
else:
|
|
441
|
-
if not pipeline_json.get(
|
|
442
|
-
pipeline_json[
|
|
388
|
+
if not pipeline_json.get("projectId", None):
|
|
389
|
+
pipeline_json["projectId"] = self.project.id
|
|
443
390
|
|
|
444
|
-
success, response = self._client_api.gen_request(req_type=
|
|
445
|
-
path='/pipelines',
|
|
446
|
-
json_req=pipeline_json)
|
|
391
|
+
success, response = self._client_api.gen_request(req_type="post", path="/pipelines", json_req=pipeline_json)
|
|
447
392
|
if success:
|
|
448
|
-
pipeline = entities.Pipeline.from_json(
|
|
449
|
-
|
|
450
|
-
|
|
393
|
+
pipeline = entities.Pipeline.from_json(
|
|
394
|
+
client_api=self._client_api, _json=response.json(), project=self.project
|
|
395
|
+
)
|
|
451
396
|
else:
|
|
452
397
|
raise exceptions.PlatformException(response)
|
|
453
398
|
assert isinstance(pipeline, entities.Pipeline)
|
|
454
399
|
return pipeline
|
|
455
400
|
|
|
456
|
-
@_api_reference.add(path=
|
|
401
|
+
@_api_reference.add(path="/pipelines/{pipelineId}/install", method="post")
|
|
457
402
|
def install(self, pipeline: entities.Pipeline = None, resume_option: entities.PipelineResumeOption = None):
|
|
458
403
|
"""
|
|
459
404
|
Install (start) a pipeline.
|
|
@@ -473,22 +418,18 @@ class Pipelines:
|
|
|
473
418
|
|
|
474
419
|
payload = {}
|
|
475
420
|
if resume_option:
|
|
476
|
-
payload[
|
|
421
|
+
payload["resumeOption"] = resume_option
|
|
477
422
|
|
|
478
423
|
success, response = self._client_api.gen_request(
|
|
479
|
-
req_type=
|
|
480
|
-
path='/pipelines/{}/install'.format(pipeline.id),
|
|
481
|
-
json_req=payload
|
|
424
|
+
req_type="post", path="/pipelines/{}/install".format(pipeline.id), json_req=payload
|
|
482
425
|
)
|
|
483
426
|
|
|
484
427
|
if not success:
|
|
485
428
|
raise exceptions.PlatformException(response)
|
|
486
429
|
|
|
487
|
-
return entities.Pipeline.from_json(client_api=self._client_api,
|
|
488
|
-
_json=response.json(),
|
|
489
|
-
project=self.project)
|
|
430
|
+
return entities.Pipeline.from_json(client_api=self._client_api, _json=response.json(), project=self.project)
|
|
490
431
|
|
|
491
|
-
@_api_reference.add(path=
|
|
432
|
+
@_api_reference.add(path="/pipelines/{pipelineId}/uninstall", method="post")
|
|
492
433
|
def pause(self, pipeline: entities.Pipeline = None, keep_triggers_active: bool = None):
|
|
493
434
|
"""
|
|
494
435
|
Pause a pipeline.
|
|
@@ -508,23 +449,23 @@ class Pipelines:
|
|
|
508
449
|
|
|
509
450
|
payload = {}
|
|
510
451
|
if keep_triggers_active is not None:
|
|
511
|
-
payload[
|
|
452
|
+
payload["keepTriggersActive"] = keep_triggers_active
|
|
512
453
|
|
|
513
454
|
success, response = self._client_api.gen_request(
|
|
514
|
-
req_type=
|
|
515
|
-
path='/pipelines/{}/uninstall'.format(pipeline.id),
|
|
516
|
-
json_req=payload
|
|
455
|
+
req_type="post", path="/pipelines/{}/uninstall".format(pipeline.id), json_req=payload
|
|
517
456
|
)
|
|
518
457
|
|
|
519
458
|
if not success:
|
|
520
459
|
raise exceptions.PlatformException(response)
|
|
521
460
|
|
|
522
|
-
@_api_reference.add(path=
|
|
523
|
-
def reset(
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
461
|
+
@_api_reference.add(path="/pipelines/{pipelineId}/reset", method="post")
|
|
462
|
+
def reset(
|
|
463
|
+
self,
|
|
464
|
+
pipeline: entities.Pipeline = None,
|
|
465
|
+
pipeline_id: str = None,
|
|
466
|
+
pipeline_name: str = None,
|
|
467
|
+
stop_if_running: bool = False,
|
|
468
|
+
):
|
|
528
469
|
"""
|
|
529
470
|
Reset pipeline counters.
|
|
530
471
|
|
|
@@ -549,8 +490,7 @@ class Pipelines:
|
|
|
549
490
|
pipeline = self.get(pipeline_name=pipeline_name)
|
|
550
491
|
else:
|
|
551
492
|
raise exceptions.PlatformException(
|
|
552
|
-
|
|
553
|
-
'Must provide one of pipeline, pipeline_id or pipeline_name'
|
|
493
|
+
"400", "Must provide one of pipeline, pipeline_id or pipeline_name"
|
|
554
494
|
)
|
|
555
495
|
pipeline_id = pipeline.id
|
|
556
496
|
|
|
@@ -560,8 +500,7 @@ class Pipelines:
|
|
|
560
500
|
pipeline.pause()
|
|
561
501
|
|
|
562
502
|
success, response = self._client_api.gen_request(
|
|
563
|
-
req_type=
|
|
564
|
-
path='/pipelines/{}/reset'.format(pipeline_id)
|
|
503
|
+
req_type="post", path="/pipelines/{}/reset".format(pipeline_id)
|
|
565
504
|
)
|
|
566
505
|
|
|
567
506
|
if not success:
|
|
@@ -569,7 +508,7 @@ class Pipelines:
|
|
|
569
508
|
|
|
570
509
|
return True
|
|
571
510
|
|
|
572
|
-
@_api_reference.add(path=
|
|
511
|
+
@_api_reference.add(path="/pipelines/{id}/statistics", method="get")
|
|
573
512
|
def stats(self, pipeline: entities.Pipeline = None, pipeline_id: str = None, pipeline_name: str = None):
|
|
574
513
|
"""
|
|
575
514
|
Get pipeline counters.
|
|
@@ -595,14 +534,12 @@ class Pipelines:
|
|
|
595
534
|
pipeline = self.get(pipeline_name=pipeline_name)
|
|
596
535
|
else:
|
|
597
536
|
raise exceptions.PlatformException(
|
|
598
|
-
|
|
599
|
-
'Must provide one of pipeline, pipeline_id or pipeline_name'
|
|
537
|
+
"400", "Must provide one of pipeline, pipeline_id or pipeline_name"
|
|
600
538
|
)
|
|
601
539
|
pipeline_id = pipeline.id
|
|
602
540
|
|
|
603
541
|
success, response = self._client_api.gen_request(
|
|
604
|
-
req_type=
|
|
605
|
-
path='/pipelines/{}/statistics'.format(pipeline_id)
|
|
542
|
+
req_type="get", path="/pipelines/{}/statistics".format(pipeline_id)
|
|
606
543
|
)
|
|
607
544
|
|
|
608
545
|
if not success:
|
|
@@ -610,11 +547,13 @@ class Pipelines:
|
|
|
610
547
|
|
|
611
548
|
return entities.PipelineStats.from_json(_json=response.json())
|
|
612
549
|
|
|
613
|
-
def execute(
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
550
|
+
def execute(
|
|
551
|
+
self,
|
|
552
|
+
pipeline: entities.Pipeline = None,
|
|
553
|
+
pipeline_id: str = None,
|
|
554
|
+
pipeline_name: str = None,
|
|
555
|
+
execution_input=None,
|
|
556
|
+
):
|
|
618
557
|
"""
|
|
619
558
|
Execute a pipeline and return the pipeline execution as an object.
|
|
620
559
|
|
|
@@ -633,10 +572,69 @@ class Pipelines:
|
|
|
633
572
|
|
|
634
573
|
pipeline_execution= project.pipelines.execute(pipeline='pipeline_entity', execution_input= {'item': 'item_id'} )
|
|
635
574
|
"""
|
|
575
|
+
|
|
576
|
+
if pipeline is None and pipeline_id is None:
|
|
577
|
+
raise ValueError("Pipeline or pipeline_id must be provided")
|
|
578
|
+
|
|
636
579
|
if pipeline is None:
|
|
637
|
-
pipeline = self.get(pipeline_id=pipeline_id
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
580
|
+
pipeline = self.get(pipeline_id=pipeline_id)
|
|
581
|
+
|
|
582
|
+
execution = repositories.PipelineExecutions(
|
|
583
|
+
pipeline=pipeline, client_api=self._client_api, project=self._project
|
|
584
|
+
).create(pipeline_id=pipeline.id, execution_input=execution_input, test_mode=False)
|
|
642
585
|
return execution
|
|
586
|
+
|
|
587
|
+
def test(self, pipeline: entities.Pipeline = None, pipeline_id: str = None, execution_input=None):
|
|
588
|
+
"""
|
|
589
|
+
Execute a pipeline in test mode and return the pipeline execution as an object.
|
|
590
|
+
|
|
591
|
+
**prerequisites**: You must be an *owner* or *developer* to use this method.
|
|
592
|
+
|
|
593
|
+
:param dtlpy.entities.pipeline.Pipeline pipeline: pipeline entity
|
|
594
|
+
:param str pipeline_id: pipeline id
|
|
595
|
+
:param execution_input: list of the dl.FunctionIO or dict of pipeline input - example {'item': 'item_id'}
|
|
596
|
+
:return: entities.PipelineExecution object
|
|
597
|
+
:rtype: dtlpy.entities.pipeline_execution.PipelineExecution
|
|
598
|
+
|
|
599
|
+
**Example**:
|
|
600
|
+
|
|
601
|
+
.. code-block:: python
|
|
602
|
+
|
|
603
|
+
pipeline_execution= project.pipelines.test(pipeline='pipeline_entity', execution_input= {'item': 'item_id'} )
|
|
604
|
+
"""
|
|
605
|
+
if pipeline is None and pipeline_id is None:
|
|
606
|
+
raise ValueError("Pipeline or pipeline_id must be provided")
|
|
607
|
+
|
|
608
|
+
if pipeline is None:
|
|
609
|
+
pipeline = self.get(pipeline_id=pipeline_id)
|
|
610
|
+
|
|
611
|
+
execution = repositories.PipelineExecutions(
|
|
612
|
+
pipeline=pipeline, client_api=self._client_api, project=self._project
|
|
613
|
+
).create(pipeline_id=pipeline.id, execution_input=execution_input, test_mode=True)
|
|
614
|
+
return execution
|
|
615
|
+
|
|
616
|
+
@_api_reference.add(path="/pipelines/validate", method="post")
|
|
617
|
+
def validate(self, pipeline_json: dict):
|
|
618
|
+
"""
|
|
619
|
+
Validate a pipeline configuration.
|
|
620
|
+
|
|
621
|
+
**prerequisites**: You must be an *owner* or *developer* to use this method.
|
|
622
|
+
|
|
623
|
+
:param dict pipeline_json: pipeline configuration as JSON dictionary
|
|
624
|
+
:return: Validation result
|
|
625
|
+
:rtype: dict
|
|
626
|
+
|
|
627
|
+
**Example**:
|
|
628
|
+
|
|
629
|
+
.. code-block:: python
|
|
630
|
+
|
|
631
|
+
validation_result = project.pipelines.validate(pipeline_json={'name': 'my_pipeline', 'nodes': []})
|
|
632
|
+
"""
|
|
633
|
+
success, response = self._client_api.gen_request(
|
|
634
|
+
req_type="post", path="/pipelines/validate", json_req=pipeline_json
|
|
635
|
+
)
|
|
636
|
+
|
|
637
|
+
if not success:
|
|
638
|
+
raise exceptions.PlatformException(response)
|
|
639
|
+
|
|
640
|
+
return response.json()
|