digitalhub 0.14.0b2__py3-none-any.whl → 0.14.0b4__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.
Potentially problematic release.
This version of digitalhub might be problematic. Click here for more details.
- digitalhub/context/builder.py +0 -4
- digitalhub/context/context.py +12 -8
- digitalhub/entities/_base/_base/entity.py +0 -4
- digitalhub/entities/_base/context/entity.py +1 -1
- digitalhub/entities/_base/entity/entity.py +0 -8
- digitalhub/entities/_base/executable/entity.py +161 -79
- digitalhub/entities/_base/material/entity.py +7 -23
- digitalhub/entities/_base/material/utils.py +28 -0
- digitalhub/entities/_base/unversioned/entity.py +1 -1
- digitalhub/entities/_base/versioned/entity.py +1 -1
- digitalhub/entities/_commons/enums.py +0 -31
- digitalhub/entities/_constructors/_resources.py +151 -0
- digitalhub/entities/_constructors/name.py +18 -0
- digitalhub/entities/_processors/base/__init__.py +3 -0
- digitalhub/entities/_processors/{base.py → base/crud.py} +7 -227
- digitalhub/entities/_processors/base/import_export.py +122 -0
- digitalhub/entities/_processors/base/processor.py +302 -0
- digitalhub/entities/_processors/base/special_ops.py +108 -0
- digitalhub/entities/_processors/context/__init__.py +3 -0
- digitalhub/entities/_processors/context/crud.py +654 -0
- digitalhub/entities/_processors/context/import_export.py +242 -0
- digitalhub/entities/_processors/context/material.py +123 -0
- digitalhub/entities/_processors/context/processor.py +400 -0
- digitalhub/entities/_processors/context/special_ops.py +476 -0
- digitalhub/entities/_processors/processors.py +12 -0
- digitalhub/entities/_processors/utils.py +2 -1
- digitalhub/entities/artifact/crud.py +45 -41
- digitalhub/entities/dataitem/crud.py +45 -37
- digitalhub/entities/dataitem/table/entity.py +5 -6
- digitalhub/entities/function/crud.py +47 -43
- digitalhub/entities/model/_base/entity.py +3 -23
- digitalhub/entities/model/crud.py +45 -39
- digitalhub/entities/project/_base/entity.py +45 -134
- digitalhub/entities/project/crud.py +13 -42
- digitalhub/entities/run/_base/builder.py +0 -4
- digitalhub/entities/run/_base/entity.py +4 -60
- digitalhub/entities/run/crud.py +61 -40
- digitalhub/entities/secret/_base/entity.py +1 -5
- digitalhub/entities/secret/crud.py +14 -42
- digitalhub/entities/task/_base/builder.py +0 -4
- digitalhub/entities/task/_base/entity.py +1 -1
- digitalhub/entities/task/crud.py +47 -44
- digitalhub/entities/trigger/_base/entity.py +1 -5
- digitalhub/entities/trigger/crud.py +51 -43
- digitalhub/entities/workflow/crud.py +47 -40
- digitalhub/factory/registry.py +0 -24
- digitalhub/stores/client/_base/enums.py +39 -0
- digitalhub/stores/client/_base/key_builder.py +1 -1
- digitalhub/stores/client/_base/params_builder.py +48 -0
- digitalhub/stores/client/dhcore/api_builder.py +2 -1
- digitalhub/stores/client/dhcore/client.py +67 -73
- digitalhub/stores/client/dhcore/configurator.py +5 -28
- digitalhub/stores/client/dhcore/error_parser.py +0 -4
- digitalhub/stores/client/dhcore/params_builder.py +130 -75
- digitalhub/stores/client/local/api_builder.py +1 -1
- digitalhub/stores/client/local/params_builder.py +18 -41
- digitalhub/stores/credentials/configurator.py +0 -24
- digitalhub/stores/credentials/handler.py +0 -12
- digitalhub/stores/credentials/store.py +0 -4
- digitalhub/stores/data/_base/store.py +0 -16
- digitalhub/stores/data/builder.py +0 -4
- digitalhub/stores/data/remote/store.py +0 -4
- digitalhub/stores/data/s3/configurator.py +0 -8
- digitalhub/stores/data/s3/store.py +8 -17
- digitalhub/stores/data/sql/configurator.py +0 -8
- digitalhub/stores/data/sql/store.py +0 -4
- digitalhub/stores/readers/data/factory.py +0 -8
- digitalhub/stores/readers/data/pandas/reader.py +0 -16
- digitalhub/utils/io_utils.py +0 -4
- {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b4.dist-info}/METADATA +1 -1
- {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b4.dist-info}/RECORD +74 -62
- digitalhub/entities/_processors/context.py +0 -1499
- {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b4.dist-info}/WHEEL +0 -0
- {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b4.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b4.dist-info}/licenses/LICENSE +0 -0
digitalhub/context/builder.py
CHANGED
digitalhub/context/context.py
CHANGED
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
+
import os
|
|
7
8
|
import typing
|
|
8
9
|
from pathlib import Path
|
|
9
10
|
|
|
11
|
+
from digitalhub.runtimes.enums import RuntimeEnvVar
|
|
12
|
+
|
|
10
13
|
if typing.TYPE_CHECKING:
|
|
11
14
|
from digitalhub.entities.project._base.entity import Project
|
|
12
15
|
from digitalhub.stores.client._base.client import Client
|
|
@@ -47,6 +50,15 @@ class Context:
|
|
|
47
50
|
|
|
48
51
|
self.is_running: bool = False
|
|
49
52
|
self._run_ctx: str | None = None
|
|
53
|
+
self._search_run_ctx()
|
|
54
|
+
|
|
55
|
+
def _search_run_ctx(self) -> None:
|
|
56
|
+
"""
|
|
57
|
+
Search for an existing run id in env.
|
|
58
|
+
"""
|
|
59
|
+
run_id = os.getenv(RuntimeEnvVar.RUN_ID.value)
|
|
60
|
+
if run_id is not None:
|
|
61
|
+
self.set_run(run_id)
|
|
50
62
|
|
|
51
63
|
def set_run(self, run_ctx: str) -> None:
|
|
52
64
|
"""
|
|
@@ -56,10 +68,6 @@ class Context:
|
|
|
56
68
|
----------
|
|
57
69
|
run_ctx : str
|
|
58
70
|
The run key to set.
|
|
59
|
-
|
|
60
|
-
Returns
|
|
61
|
-
-------
|
|
62
|
-
None
|
|
63
71
|
"""
|
|
64
72
|
self.is_running = True
|
|
65
73
|
self._run_ctx = run_ctx
|
|
@@ -67,10 +75,6 @@ class Context:
|
|
|
67
75
|
def unset_run(self) -> None:
|
|
68
76
|
"""
|
|
69
77
|
Clear the current run key and reset running state.
|
|
70
|
-
|
|
71
|
-
Returns
|
|
72
|
-
-------
|
|
73
|
-
None
|
|
74
78
|
"""
|
|
75
79
|
self.is_running = False
|
|
76
80
|
self._run_ctx = None
|
|
@@ -8,7 +8,7 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.context.api import get_context
|
|
10
10
|
from digitalhub.entities._base.entity.entity import Entity
|
|
11
|
-
from digitalhub.entities._processors.
|
|
11
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
12
|
from digitalhub.utils.generic_utils import get_timestamp
|
|
13
13
|
from digitalhub.utils.io_utils import write_yaml
|
|
14
14
|
|
|
@@ -67,10 +67,6 @@ class Entity(Base):
|
|
|
67
67
|
----------
|
|
68
68
|
obj : dict
|
|
69
69
|
Mapping representation of object.
|
|
70
|
-
|
|
71
|
-
Returns
|
|
72
|
-
-------
|
|
73
|
-
None
|
|
74
70
|
"""
|
|
75
71
|
self.metadata = obj.metadata
|
|
76
72
|
self.spec = obj.spec
|
|
@@ -95,10 +91,6 @@ class Entity(Base):
|
|
|
95
91
|
The target entity.
|
|
96
92
|
source : str
|
|
97
93
|
The source entity.
|
|
98
|
-
|
|
99
|
-
Returns
|
|
100
|
-
-------
|
|
101
|
-
None
|
|
102
94
|
"""
|
|
103
95
|
if self.metadata.relationships is None:
|
|
104
96
|
self.metadata.relationships = []
|
|
@@ -9,7 +9,7 @@ from abc import abstractmethod
|
|
|
9
9
|
|
|
10
10
|
from digitalhub.entities._base.versioned.entity import VersionedEntity
|
|
11
11
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
12
|
-
from digitalhub.entities._processors.
|
|
12
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
13
13
|
from digitalhub.entities.run.crud import list_runs
|
|
14
14
|
from digitalhub.entities.task.crud import delete_task, list_tasks
|
|
15
15
|
from digitalhub.entities.trigger.crud import list_triggers
|
|
@@ -94,10 +94,6 @@ class ExecutableEntity(VersionedEntity):
|
|
|
94
94
|
----------
|
|
95
95
|
tasks : list[dict]
|
|
96
96
|
List of tasks to import.
|
|
97
|
-
|
|
98
|
-
Returns
|
|
99
|
-
-------
|
|
100
|
-
None
|
|
101
97
|
"""
|
|
102
98
|
# Loop over tasks list, in the case where the function
|
|
103
99
|
# is imported from local file.
|
|
@@ -183,21 +179,62 @@ class ExecutableEntity(VersionedEntity):
|
|
|
183
179
|
self._tasks[kind] = resp[0]
|
|
184
180
|
return self._tasks[kind]
|
|
185
181
|
|
|
186
|
-
def list_task(
|
|
182
|
+
def list_task(
|
|
183
|
+
self,
|
|
184
|
+
q: str | None = None,
|
|
185
|
+
name: str | None = None,
|
|
186
|
+
kind: str | None = None,
|
|
187
|
+
user: str | None = None,
|
|
188
|
+
state: str | None = None,
|
|
189
|
+
created: str | None = None,
|
|
190
|
+
updated: str | None = None,
|
|
191
|
+
) -> list[Task]:
|
|
187
192
|
"""
|
|
188
|
-
List tasks.
|
|
193
|
+
List tasks of the executable entity from backend.
|
|
189
194
|
|
|
190
195
|
Parameters
|
|
191
196
|
----------
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
q : str
|
|
198
|
+
Query string to filter objects.
|
|
199
|
+
name : str
|
|
200
|
+
Object name.
|
|
201
|
+
kind : str
|
|
202
|
+
Kind of the object.
|
|
203
|
+
user : str
|
|
204
|
+
User that created the object.
|
|
205
|
+
state : str
|
|
206
|
+
Object state.
|
|
207
|
+
created : str
|
|
208
|
+
Creation date filter.
|
|
209
|
+
updated : str
|
|
210
|
+
Update date filter.
|
|
194
211
|
|
|
195
212
|
Returns
|
|
196
213
|
-------
|
|
197
|
-
list
|
|
198
|
-
List of
|
|
214
|
+
list[Task]
|
|
215
|
+
List of object instances.
|
|
216
|
+
"""
|
|
217
|
+
return self._list_tasks(
|
|
218
|
+
self.project,
|
|
219
|
+
q=q,
|
|
220
|
+
name=name,
|
|
221
|
+
kind=kind,
|
|
222
|
+
user=user,
|
|
223
|
+
state=state,
|
|
224
|
+
created=created,
|
|
225
|
+
updated=updated,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
def _list_tasks(self, **kwargs) -> list[Task]:
|
|
199
229
|
"""
|
|
200
|
-
|
|
230
|
+
List all tasks of the executable entity from backend.
|
|
231
|
+
|
|
232
|
+
Returns
|
|
233
|
+
-------
|
|
234
|
+
list[Task]
|
|
235
|
+
List of object instances.
|
|
236
|
+
"""
|
|
237
|
+
kwargs[self.ENTITY_TYPE] = self._get_executable_string()
|
|
201
238
|
return list_tasks(self.project, **kwargs)
|
|
202
239
|
|
|
203
240
|
def update_task(self, kind: str, **kwargs) -> Task:
|
|
@@ -265,7 +302,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
265
302
|
Response from backend.
|
|
266
303
|
"""
|
|
267
304
|
params = {self.ENTITY_TYPE: self._get_executable_string(), "kind": kind}
|
|
268
|
-
return context_processor.list_context_entities(self.project, EntityTypes.TASK.value, params
|
|
305
|
+
return context_processor.list_context_entities(self.project, EntityTypes.TASK.value, **params)
|
|
269
306
|
|
|
270
307
|
def _check_task_in_backend(self, kind: str) -> bool:
|
|
271
308
|
"""
|
|
@@ -295,10 +332,6 @@ class ExecutableEntity(VersionedEntity):
|
|
|
295
332
|
kind : str
|
|
296
333
|
Kind the object.
|
|
297
334
|
|
|
298
|
-
Returns
|
|
299
|
-
-------
|
|
300
|
-
None
|
|
301
|
-
|
|
302
335
|
Raises
|
|
303
336
|
------
|
|
304
337
|
EntityError
|
|
@@ -316,10 +349,6 @@ class ExecutableEntity(VersionedEntity):
|
|
|
316
349
|
kind : str
|
|
317
350
|
Kind the object.
|
|
318
351
|
|
|
319
|
-
Returns
|
|
320
|
-
-------
|
|
321
|
-
None
|
|
322
|
-
|
|
323
352
|
Raises
|
|
324
353
|
------
|
|
325
354
|
EntityError
|
|
@@ -338,39 +367,21 @@ class ExecutableEntity(VersionedEntity):
|
|
|
338
367
|
Create and execute a new run.
|
|
339
368
|
"""
|
|
340
369
|
|
|
341
|
-
def get_run(
|
|
342
|
-
self,
|
|
343
|
-
identifier: str,
|
|
344
|
-
**kwargs,
|
|
345
|
-
) -> Run:
|
|
370
|
+
def get_run(self, identifier: str) -> Run:
|
|
346
371
|
"""
|
|
347
|
-
Get object from backend.
|
|
372
|
+
Get specific run object of the executable from backend.
|
|
348
373
|
|
|
349
374
|
Parameters
|
|
350
375
|
----------
|
|
351
376
|
identifier : str
|
|
352
377
|
Entity key (store://...) or entity ID.
|
|
353
|
-
**kwargs : dict
|
|
354
|
-
Parameters to pass to the API call.
|
|
355
378
|
|
|
356
379
|
Returns
|
|
357
380
|
-------
|
|
358
381
|
Run
|
|
359
382
|
Object instance.
|
|
360
|
-
|
|
361
|
-
Examples
|
|
362
|
-
--------
|
|
363
|
-
Using entity key:
|
|
364
|
-
>>> obj = executable.get_run(
|
|
365
|
-
... "store://my-secret-key"
|
|
366
|
-
... )
|
|
367
|
-
|
|
368
|
-
Using entity ID:
|
|
369
|
-
>>> obj = executable.get_run(
|
|
370
|
-
... "123"
|
|
371
|
-
... )
|
|
372
383
|
"""
|
|
373
|
-
entities = self.
|
|
384
|
+
entities = self._list_runs()
|
|
374
385
|
for entity in entities:
|
|
375
386
|
if getattr(entity.spec, self.ENTITY_TYPE) == self._get_executable_string():
|
|
376
387
|
if entity.id == identifier:
|
|
@@ -379,25 +390,69 @@ class ExecutableEntity(VersionedEntity):
|
|
|
379
390
|
return entity
|
|
380
391
|
raise EntityError(f"Run '{identifier}' does not exist or does not belong to this executable.")
|
|
381
392
|
|
|
382
|
-
def list_runs(
|
|
393
|
+
def list_runs(
|
|
394
|
+
self,
|
|
395
|
+
q: str | None = None,
|
|
396
|
+
name: str | None = None,
|
|
397
|
+
kind: str | None = None,
|
|
398
|
+
user: str | None = None,
|
|
399
|
+
state: str | None = None,
|
|
400
|
+
created: str | None = None,
|
|
401
|
+
updated: str | None = None,
|
|
402
|
+
task: str | None = None,
|
|
403
|
+
action: str | None = None,
|
|
404
|
+
) -> list[Run]:
|
|
383
405
|
"""
|
|
384
|
-
List
|
|
406
|
+
List runs of the executable entity from backend.
|
|
385
407
|
|
|
386
408
|
Parameters
|
|
387
409
|
----------
|
|
388
|
-
|
|
389
|
-
|
|
410
|
+
q : str
|
|
411
|
+
Query string to filter objects.
|
|
412
|
+
name : str
|
|
413
|
+
Object name.
|
|
414
|
+
kind : str
|
|
415
|
+
Kind of the object.
|
|
416
|
+
user : str
|
|
417
|
+
User that created the object.
|
|
418
|
+
state : str
|
|
419
|
+
Object state.
|
|
420
|
+
created : str
|
|
421
|
+
Creation date filter.
|
|
422
|
+
updated : str
|
|
423
|
+
Update date filter.
|
|
424
|
+
task : str
|
|
425
|
+
Task string filter.
|
|
426
|
+
action : str
|
|
427
|
+
Action name filter.
|
|
390
428
|
|
|
391
429
|
Returns
|
|
392
430
|
-------
|
|
393
431
|
list[Run]
|
|
394
432
|
List of object instances.
|
|
433
|
+
"""
|
|
434
|
+
return self._list_runs(
|
|
435
|
+
q=q,
|
|
436
|
+
name=name,
|
|
437
|
+
kind=kind,
|
|
438
|
+
user=user,
|
|
439
|
+
state=state,
|
|
440
|
+
created=created,
|
|
441
|
+
updated=updated,
|
|
442
|
+
task=task,
|
|
443
|
+
action=action,
|
|
444
|
+
)
|
|
395
445
|
|
|
396
|
-
|
|
397
|
-
--------
|
|
398
|
-
>>> objs = executable.list_runs()
|
|
446
|
+
def _list_runs(self, **kwargs) -> list[Run]:
|
|
399
447
|
"""
|
|
400
|
-
|
|
448
|
+
List all runs of the executable entity from backend.
|
|
449
|
+
|
|
450
|
+
Returns
|
|
451
|
+
-------
|
|
452
|
+
list[Run]
|
|
453
|
+
List of object instances.
|
|
454
|
+
"""
|
|
455
|
+
kwargs[self.ENTITY_TYPE] = self._get_executable_string()
|
|
401
456
|
return list_runs(self.project, **kwargs)
|
|
402
457
|
|
|
403
458
|
##############################
|
|
@@ -425,8 +480,8 @@ class ExecutableEntity(VersionedEntity):
|
|
|
425
480
|
|
|
426
481
|
Returns
|
|
427
482
|
-------
|
|
428
|
-
|
|
429
|
-
|
|
483
|
+
Trigger
|
|
484
|
+
Object instance.
|
|
430
485
|
"""
|
|
431
486
|
# Get task
|
|
432
487
|
task_kind = entity_factory.get_task_kind_from_action(self.kind, action)
|
|
@@ -449,11 +504,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
449
504
|
trigger.save()
|
|
450
505
|
return trigger
|
|
451
506
|
|
|
452
|
-
def get_trigger(
|
|
453
|
-
self,
|
|
454
|
-
identifier: str,
|
|
455
|
-
**kwargs,
|
|
456
|
-
) -> Trigger:
|
|
507
|
+
def get_trigger(self, identifier: str) -> Trigger:
|
|
457
508
|
"""
|
|
458
509
|
Get object from backend.
|
|
459
510
|
|
|
@@ -461,27 +512,13 @@ class ExecutableEntity(VersionedEntity):
|
|
|
461
512
|
----------
|
|
462
513
|
identifier : str
|
|
463
514
|
Entity key (store://...) or entity ID.
|
|
464
|
-
**kwargs : dict
|
|
465
|
-
Parameters to pass to the API call.
|
|
466
515
|
|
|
467
516
|
Returns
|
|
468
517
|
-------
|
|
469
518
|
Trigger
|
|
470
519
|
Object instance.
|
|
471
|
-
|
|
472
|
-
Examples
|
|
473
|
-
--------
|
|
474
|
-
Using entity key:
|
|
475
|
-
>>> obj = executable.get_trigger(
|
|
476
|
-
... "store://my-trigger-key"
|
|
477
|
-
... )
|
|
478
|
-
|
|
479
|
-
Using entity ID:
|
|
480
|
-
>>> obj = executable.get_trigger(
|
|
481
|
-
... "123"
|
|
482
|
-
... )
|
|
483
520
|
"""
|
|
484
|
-
entities = self.
|
|
521
|
+
entities = self._list_triggers()
|
|
485
522
|
for entity in entities:
|
|
486
523
|
if getattr(entity.spec, self.ENTITY_TYPE) == self._get_executable_string():
|
|
487
524
|
if entity.id == identifier:
|
|
@@ -490,9 +527,58 @@ class ExecutableEntity(VersionedEntity):
|
|
|
490
527
|
return entity
|
|
491
528
|
raise EntityError(f"Trigger '{identifier}' does not exist or does not belong to this executable.")
|
|
492
529
|
|
|
493
|
-
def list_triggers(
|
|
530
|
+
def list_triggers(
|
|
531
|
+
self,
|
|
532
|
+
q: str | None = None,
|
|
533
|
+
name: str | None = None,
|
|
534
|
+
kind: str | None = None,
|
|
535
|
+
user: str | None = None,
|
|
536
|
+
created: str | None = None,
|
|
537
|
+
updated: str | None = None,
|
|
538
|
+
version: str | None = None,
|
|
539
|
+
task: str | None = None,
|
|
540
|
+
) -> list[Trigger]:
|
|
494
541
|
"""
|
|
495
|
-
List
|
|
542
|
+
List triggers of the executable entity from backend.
|
|
543
|
+
|
|
544
|
+
Parameters
|
|
545
|
+
----------
|
|
546
|
+
q : str
|
|
547
|
+
Query string to filter objects.
|
|
548
|
+
name : str
|
|
549
|
+
Object name.
|
|
550
|
+
kind : str
|
|
551
|
+
Kind of the object.
|
|
552
|
+
user : str
|
|
553
|
+
User that created the object.
|
|
554
|
+
created : str
|
|
555
|
+
Creation date filter.
|
|
556
|
+
updated : str
|
|
557
|
+
Update date filter.
|
|
558
|
+
version : str
|
|
559
|
+
Object version, default is latest.
|
|
560
|
+
task : str
|
|
561
|
+
Task string filter.
|
|
562
|
+
|
|
563
|
+
Returns
|
|
564
|
+
-------
|
|
565
|
+
list[Trigger]
|
|
566
|
+
List of object instances.
|
|
567
|
+
"""
|
|
568
|
+
return self._list_triggers(
|
|
569
|
+
q=q,
|
|
570
|
+
name=name,
|
|
571
|
+
kind=kind,
|
|
572
|
+
user=user,
|
|
573
|
+
created=created,
|
|
574
|
+
updated=updated,
|
|
575
|
+
version=version,
|
|
576
|
+
task=task,
|
|
577
|
+
)
|
|
578
|
+
|
|
579
|
+
def _list_triggers(self, **kwargs) -> list[Trigger]:
|
|
580
|
+
"""
|
|
581
|
+
List triggers of the executable from backend.
|
|
496
582
|
|
|
497
583
|
Parameters
|
|
498
584
|
----------
|
|
@@ -503,10 +589,6 @@ class ExecutableEntity(VersionedEntity):
|
|
|
503
589
|
-------
|
|
504
590
|
list[Trigger]
|
|
505
591
|
List of object instances.
|
|
506
|
-
|
|
507
|
-
Examples
|
|
508
|
-
--------
|
|
509
|
-
>>> objs = executable.list_triggers()
|
|
510
592
|
"""
|
|
511
|
-
kwargs[
|
|
593
|
+
kwargs[self.ENTITY_TYPE] = self._get_executable_string()
|
|
512
594
|
return list_triggers(self.project, **kwargs)
|
|
@@ -7,8 +7,9 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
|
|
10
|
+
from digitalhub.entities._base.material.utils import refresh_decorator
|
|
10
11
|
from digitalhub.entities._base.versioned.entity import VersionedEntity
|
|
11
|
-
from digitalhub.entities._processors.
|
|
12
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
13
|
from digitalhub.stores.data.api import get_store
|
|
13
14
|
from digitalhub.utils.types import SourcesOrListOfSources
|
|
14
15
|
|
|
@@ -72,6 +73,7 @@ class MaterialEntity(VersionedEntity):
|
|
|
72
73
|
# I/O Methods
|
|
73
74
|
##############################
|
|
74
75
|
|
|
76
|
+
@refresh_decorator
|
|
75
77
|
def as_file(self) -> list[str]:
|
|
76
78
|
"""
|
|
77
79
|
Get object as file(s). It downloads the object from storage in
|
|
@@ -86,6 +88,7 @@ class MaterialEntity(VersionedEntity):
|
|
|
86
88
|
dst = store._build_temp()
|
|
87
89
|
return store.download(self.spec.path, dst=dst)
|
|
88
90
|
|
|
91
|
+
@refresh_decorator
|
|
89
92
|
def download(
|
|
90
93
|
self,
|
|
91
94
|
destination: str | None = None,
|
|
@@ -130,6 +133,7 @@ class MaterialEntity(VersionedEntity):
|
|
|
130
133
|
|
|
131
134
|
return store.download(self.spec.path, dst, overwrite=overwrite)
|
|
132
135
|
|
|
136
|
+
@refresh_decorator
|
|
133
137
|
def upload(self, source: SourcesOrListOfSources) -> None:
|
|
134
138
|
"""
|
|
135
139
|
Upload object from given local path to spec path destination.
|
|
@@ -142,24 +146,16 @@ class MaterialEntity(VersionedEntity):
|
|
|
142
146
|
source : str | list[str]
|
|
143
147
|
Local filepath, directory or list of filepaths.
|
|
144
148
|
|
|
145
|
-
Returns
|
|
146
|
-
-------
|
|
147
|
-
None
|
|
148
|
-
|
|
149
149
|
Examples
|
|
150
150
|
--------
|
|
151
151
|
Upload a single file:
|
|
152
152
|
|
|
153
153
|
>>> entity.spec.path = "s3://bucket/data.csv"
|
|
154
|
-
>>> entity.upload(
|
|
155
|
-
... "./data.csv"
|
|
156
|
-
... )
|
|
154
|
+
>>> entity.upload("./data.csv")
|
|
157
155
|
|
|
158
156
|
Upload a folder:
|
|
159
157
|
>>> entity.spec.path = "s3://bucket/data/"
|
|
160
|
-
>>> entity.upload(
|
|
161
|
-
... "./data"
|
|
162
|
-
... )
|
|
158
|
+
>>> entity.upload("./data")
|
|
163
159
|
"""
|
|
164
160
|
# Get store and upload object
|
|
165
161
|
store = get_store(self.spec.path)
|
|
@@ -181,10 +177,6 @@ class MaterialEntity(VersionedEntity):
|
|
|
181
177
|
----------
|
|
182
178
|
files : list[dict]
|
|
183
179
|
Files to add.
|
|
184
|
-
|
|
185
|
-
Returns
|
|
186
|
-
-------
|
|
187
|
-
None
|
|
188
180
|
"""
|
|
189
181
|
available = 100 - len(self.status.files)
|
|
190
182
|
if len(files) > available:
|
|
@@ -218,10 +210,6 @@ class MaterialEntity(VersionedEntity):
|
|
|
218
210
|
----------
|
|
219
211
|
files_info : list[dict] | None
|
|
220
212
|
Files info.
|
|
221
|
-
|
|
222
|
-
Returns
|
|
223
|
-
-------
|
|
224
|
-
None
|
|
225
213
|
"""
|
|
226
214
|
if files_info is None:
|
|
227
215
|
return
|
|
@@ -233,10 +221,6 @@ class MaterialEntity(VersionedEntity):
|
|
|
233
221
|
def _get_files_info(self) -> None:
|
|
234
222
|
"""
|
|
235
223
|
Get files info from backend.
|
|
236
|
-
|
|
237
|
-
Returns
|
|
238
|
-
-------
|
|
239
|
-
None
|
|
240
224
|
"""
|
|
241
225
|
if not self._context().local and not self.status.files:
|
|
242
226
|
files = context_processor.read_files_info(
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
+
import typing
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
|
|
9
10
|
from digitalhub.stores.data.api import get_default_store
|
|
11
|
+
from digitalhub.utils.exceptions import BackendError
|
|
10
12
|
from digitalhub.utils.file_utils import eval_zip_type
|
|
11
13
|
from digitalhub.utils.uri_utils import has_local_scheme
|
|
12
14
|
|
|
@@ -108,3 +110,29 @@ def build_log_path_from_source(
|
|
|
108
110
|
path += f"/{Path(source).name}"
|
|
109
111
|
|
|
110
112
|
return path
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def refresh_decorator(fn: typing.Callable) -> typing.Callable:
|
|
116
|
+
"""
|
|
117
|
+
Refresh decorator.
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
fn : Callable
|
|
122
|
+
Function to decorate.
|
|
123
|
+
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
Callable
|
|
127
|
+
Decorated function.
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
def wrapper(self, *args, **kwargs):
|
|
131
|
+
# Prevent rising error if entity is not yet created in backend
|
|
132
|
+
try:
|
|
133
|
+
self.refresh()
|
|
134
|
+
except BackendError:
|
|
135
|
+
pass
|
|
136
|
+
return fn(self, *args, **kwargs)
|
|
137
|
+
|
|
138
|
+
return wrapper
|
|
@@ -7,7 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._base.context.entity import ContextEntity
|
|
10
|
-
from digitalhub.entities._processors.
|
|
10
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
11
11
|
|
|
12
12
|
if typing.TYPE_CHECKING:
|
|
13
13
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -7,7 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._base.context.entity import ContextEntity
|
|
10
|
-
from digitalhub.entities._processors.
|
|
10
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
11
11
|
|
|
12
12
|
if typing.TYPE_CHECKING:
|
|
13
13
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -63,37 +63,6 @@ class State(Enum):
|
|
|
63
63
|
UPLOADING = "UPLOADING"
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
class ApiCategories(Enum):
|
|
67
|
-
"""
|
|
68
|
-
Entity categories.
|
|
69
|
-
"""
|
|
70
|
-
|
|
71
|
-
BASE = "base"
|
|
72
|
-
CONTEXT = "context"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
class BackendOperations(Enum):
|
|
76
|
-
"""
|
|
77
|
-
Backend operations.
|
|
78
|
-
"""
|
|
79
|
-
|
|
80
|
-
CREATE = "create"
|
|
81
|
-
READ = "read"
|
|
82
|
-
READ_ALL_VERSIONS = "read_all_versions"
|
|
83
|
-
UPDATE = "update"
|
|
84
|
-
DELETE = "delete"
|
|
85
|
-
LIST = "list"
|
|
86
|
-
LIST_FIRST = "list_first"
|
|
87
|
-
STOP = "stop"
|
|
88
|
-
RESUME = "resume"
|
|
89
|
-
DATA = "data"
|
|
90
|
-
FILES = "files"
|
|
91
|
-
LOGS = "logs"
|
|
92
|
-
SEARCH = "search"
|
|
93
|
-
SHARE = "share"
|
|
94
|
-
METRICS = "metrics"
|
|
95
|
-
|
|
96
|
-
|
|
97
66
|
class EntityKinds(Enum):
|
|
98
67
|
"""
|
|
99
68
|
Entity kinds.
|