digitalhub 0.14.0b3__py3-none-any.whl → 0.14.0b5__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.
- digitalhub/context/context.py +15 -1
- digitalhub/entities/_base/executable/entity.py +160 -58
- digitalhub/entities/_base/material/entity.py +4 -0
- digitalhub/entities/_base/material/utils.py +28 -0
- 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/crud.py +1 -1
- digitalhub/entities/_processors/base/special_ops.py +1 -1
- digitalhub/entities/_processors/context/crud.py +25 -25
- digitalhub/entities/_processors/context/special_ops.py +1 -1
- digitalhub/entities/_processors/utils.py +2 -1
- digitalhub/entities/artifact/crud.py +37 -17
- digitalhub/entities/dataitem/crud.py +37 -13
- digitalhub/entities/dataitem/table/entity.py +3 -0
- digitalhub/entities/function/crud.py +39 -19
- digitalhub/entities/model/crud.py +37 -17
- digitalhub/entities/project/_base/entity.py +5 -5
- digitalhub/entities/project/crud.py +6 -20
- digitalhub/entities/run/_base/entity.py +1 -1
- digitalhub/entities/run/crud.py +54 -21
- digitalhub/entities/secret/crud.py +6 -20
- digitalhub/entities/task/crud.py +40 -25
- digitalhub/entities/trigger/crud.py +43 -19
- digitalhub/entities/workflow/crud.py +39 -16
- 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 -55
- 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/data/s3/store.py +8 -5
- {digitalhub-0.14.0b3.dist-info → digitalhub-0.14.0b5.dist-info}/METADATA +1 -1
- {digitalhub-0.14.0b3.dist-info → digitalhub-0.14.0b5.dist-info}/RECORD +39 -37
- {digitalhub-0.14.0b3.dist-info → digitalhub-0.14.0b5.dist-info}/WHEEL +0 -0
- {digitalhub-0.14.0b3.dist-info → digitalhub-0.14.0b5.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.14.0b3.dist-info → digitalhub-0.14.0b5.dist-info}/licenses/LICENSE +0 -0
digitalhub/context/context.py
CHANGED
|
@@ -8,7 +8,10 @@ import os
|
|
|
8
8
|
import typing
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
|
|
11
|
+
from digitalhub.entities._commons.enums import EntityTypes
|
|
11
12
|
from digitalhub.runtimes.enums import RuntimeEnvVar
|
|
13
|
+
from digitalhub.stores.client._base.enums import ApiCategories, BackendOperations
|
|
14
|
+
from digitalhub.utils.exceptions import BackendError
|
|
12
15
|
|
|
13
16
|
if typing.TYPE_CHECKING:
|
|
14
17
|
from digitalhub.entities.project._base.entity import Project
|
|
@@ -58,7 +61,18 @@ class Context:
|
|
|
58
61
|
"""
|
|
59
62
|
run_id = os.getenv(RuntimeEnvVar.RUN_ID.value)
|
|
60
63
|
if run_id is not None:
|
|
61
|
-
|
|
64
|
+
try:
|
|
65
|
+
api = self.client.build_api(
|
|
66
|
+
category=ApiCategories.CONTEXT.value,
|
|
67
|
+
operation=BackendOperations.READ.value,
|
|
68
|
+
project=self.name,
|
|
69
|
+
entity_type=EntityTypes.RUN.value,
|
|
70
|
+
entity_id=run_id,
|
|
71
|
+
)
|
|
72
|
+
run_key = self.client.read_object(api=api)["key"]
|
|
73
|
+
self.set_run(run_key)
|
|
74
|
+
except BackendError:
|
|
75
|
+
pass
|
|
62
76
|
|
|
63
77
|
def set_run(self, run_ctx: str) -> None:
|
|
64
78
|
"""
|
|
@@ -179,21 +179,62 @@ class ExecutableEntity(VersionedEntity):
|
|
|
179
179
|
self._tasks[kind] = resp[0]
|
|
180
180
|
return self._tasks[kind]
|
|
181
181
|
|
|
182
|
-
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]:
|
|
183
192
|
"""
|
|
184
|
-
List tasks.
|
|
193
|
+
List tasks of the executable entity from backend.
|
|
185
194
|
|
|
186
195
|
Parameters
|
|
187
196
|
----------
|
|
188
|
-
|
|
189
|
-
|
|
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.
|
|
190
211
|
|
|
191
212
|
Returns
|
|
192
213
|
-------
|
|
193
|
-
list
|
|
194
|
-
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]:
|
|
229
|
+
"""
|
|
230
|
+
List all tasks of the executable entity from backend.
|
|
231
|
+
|
|
232
|
+
Returns
|
|
233
|
+
-------
|
|
234
|
+
list[Task]
|
|
235
|
+
List of object instances.
|
|
195
236
|
"""
|
|
196
|
-
kwargs[
|
|
237
|
+
kwargs[self.ENTITY_TYPE] = self._get_executable_string()
|
|
197
238
|
return list_tasks(self.project, **kwargs)
|
|
198
239
|
|
|
199
240
|
def update_task(self, kind: str, **kwargs) -> Task:
|
|
@@ -261,7 +302,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
261
302
|
Response from backend.
|
|
262
303
|
"""
|
|
263
304
|
params = {self.ENTITY_TYPE: self._get_executable_string(), "kind": kind}
|
|
264
|
-
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)
|
|
265
306
|
|
|
266
307
|
def _check_task_in_backend(self, kind: str) -> bool:
|
|
267
308
|
"""
|
|
@@ -326,35 +367,21 @@ class ExecutableEntity(VersionedEntity):
|
|
|
326
367
|
Create and execute a new run.
|
|
327
368
|
"""
|
|
328
369
|
|
|
329
|
-
def get_run(
|
|
330
|
-
self,
|
|
331
|
-
identifier: str,
|
|
332
|
-
**kwargs,
|
|
333
|
-
) -> Run:
|
|
370
|
+
def get_run(self, identifier: str) -> Run:
|
|
334
371
|
"""
|
|
335
|
-
Get object from backend.
|
|
372
|
+
Get specific run object of the executable from backend.
|
|
336
373
|
|
|
337
374
|
Parameters
|
|
338
375
|
----------
|
|
339
376
|
identifier : str
|
|
340
377
|
Entity key (store://...) or entity ID.
|
|
341
|
-
**kwargs : dict
|
|
342
|
-
Parameters to pass to the API call.
|
|
343
378
|
|
|
344
379
|
Returns
|
|
345
380
|
-------
|
|
346
381
|
Run
|
|
347
382
|
Object instance.
|
|
348
|
-
|
|
349
|
-
Examples
|
|
350
|
-
--------
|
|
351
|
-
Using entity key:
|
|
352
|
-
>>> obj = executable.get_run("store://my-secret-key")
|
|
353
|
-
|
|
354
|
-
Using entity ID:
|
|
355
|
-
>>> obj = executable.get_run("123")
|
|
356
383
|
"""
|
|
357
|
-
entities = self.
|
|
384
|
+
entities = self._list_runs()
|
|
358
385
|
for entity in entities:
|
|
359
386
|
if getattr(entity.spec, self.ENTITY_TYPE) == self._get_executable_string():
|
|
360
387
|
if entity.id == identifier:
|
|
@@ -363,25 +390,69 @@ class ExecutableEntity(VersionedEntity):
|
|
|
363
390
|
return entity
|
|
364
391
|
raise EntityError(f"Run '{identifier}' does not exist or does not belong to this executable.")
|
|
365
392
|
|
|
366
|
-
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]:
|
|
367
405
|
"""
|
|
368
|
-
List
|
|
406
|
+
List runs of the executable entity from backend.
|
|
369
407
|
|
|
370
408
|
Parameters
|
|
371
409
|
----------
|
|
372
|
-
|
|
373
|
-
|
|
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.
|
|
374
428
|
|
|
375
429
|
Returns
|
|
376
430
|
-------
|
|
377
431
|
list[Run]
|
|
378
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
|
+
)
|
|
445
|
+
|
|
446
|
+
def _list_runs(self, **kwargs) -> list[Run]:
|
|
447
|
+
"""
|
|
448
|
+
List all runs of the executable entity from backend.
|
|
379
449
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
450
|
+
Returns
|
|
451
|
+
-------
|
|
452
|
+
list[Run]
|
|
453
|
+
List of object instances.
|
|
383
454
|
"""
|
|
384
|
-
kwargs[
|
|
455
|
+
kwargs[self.ENTITY_TYPE] = self._get_executable_string()
|
|
385
456
|
return list_runs(self.project, **kwargs)
|
|
386
457
|
|
|
387
458
|
##############################
|
|
@@ -409,8 +480,8 @@ class ExecutableEntity(VersionedEntity):
|
|
|
409
480
|
|
|
410
481
|
Returns
|
|
411
482
|
-------
|
|
412
|
-
|
|
413
|
-
|
|
483
|
+
Trigger
|
|
484
|
+
Object instance.
|
|
414
485
|
"""
|
|
415
486
|
# Get task
|
|
416
487
|
task_kind = entity_factory.get_task_kind_from_action(self.kind, action)
|
|
@@ -433,11 +504,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
433
504
|
trigger.save()
|
|
434
505
|
return trigger
|
|
435
506
|
|
|
436
|
-
def get_trigger(
|
|
437
|
-
self,
|
|
438
|
-
identifier: str,
|
|
439
|
-
**kwargs,
|
|
440
|
-
) -> Trigger:
|
|
507
|
+
def get_trigger(self, identifier: str) -> Trigger:
|
|
441
508
|
"""
|
|
442
509
|
Get object from backend.
|
|
443
510
|
|
|
@@ -445,23 +512,13 @@ class ExecutableEntity(VersionedEntity):
|
|
|
445
512
|
----------
|
|
446
513
|
identifier : str
|
|
447
514
|
Entity key (store://...) or entity ID.
|
|
448
|
-
**kwargs : dict
|
|
449
|
-
Parameters to pass to the API call.
|
|
450
515
|
|
|
451
516
|
Returns
|
|
452
517
|
-------
|
|
453
518
|
Trigger
|
|
454
519
|
Object instance.
|
|
455
|
-
|
|
456
|
-
Examples
|
|
457
|
-
--------
|
|
458
|
-
Using entity key:
|
|
459
|
-
>>> obj = executable.get_trigger("store://my-trigger-key")
|
|
460
|
-
|
|
461
|
-
Using entity ID:
|
|
462
|
-
>>> obj = executable.get_trigger("123")
|
|
463
520
|
"""
|
|
464
|
-
entities = self.
|
|
521
|
+
entities = self._list_triggers()
|
|
465
522
|
for entity in entities:
|
|
466
523
|
if getattr(entity.spec, self.ENTITY_TYPE) == self._get_executable_string():
|
|
467
524
|
if entity.id == identifier:
|
|
@@ -470,9 +527,58 @@ class ExecutableEntity(VersionedEntity):
|
|
|
470
527
|
return entity
|
|
471
528
|
raise EntityError(f"Trigger '{identifier}' does not exist or does not belong to this executable.")
|
|
472
529
|
|
|
473
|
-
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]:
|
|
474
541
|
"""
|
|
475
|
-
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.
|
|
476
582
|
|
|
477
583
|
Parameters
|
|
478
584
|
----------
|
|
@@ -483,10 +589,6 @@ class ExecutableEntity(VersionedEntity):
|
|
|
483
589
|
-------
|
|
484
590
|
list[Trigger]
|
|
485
591
|
List of object instances.
|
|
486
|
-
|
|
487
|
-
Examples
|
|
488
|
-
--------
|
|
489
|
-
>>> objs = executable.list_triggers()
|
|
490
592
|
"""
|
|
491
|
-
kwargs[
|
|
593
|
+
kwargs[self.ENTITY_TYPE] = self._get_executable_string()
|
|
492
594
|
return list_triggers(self.project, **kwargs)
|
|
@@ -7,6 +7,7 @@ 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
12
|
from digitalhub.entities._processors.processors import context_processor
|
|
12
13
|
from digitalhub.stores.data.api import get_store
|
|
@@ -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.
|
|
@@ -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
|
|
@@ -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.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
ANIMALS = [
|
|
8
|
+
"ant",
|
|
9
|
+
"bear",
|
|
10
|
+
"bee",
|
|
11
|
+
"bison",
|
|
12
|
+
"cat",
|
|
13
|
+
"cheetah",
|
|
14
|
+
"cougar",
|
|
15
|
+
"crane",
|
|
16
|
+
"deer",
|
|
17
|
+
"dolphin",
|
|
18
|
+
"duck",
|
|
19
|
+
"eagle",
|
|
20
|
+
"falcon",
|
|
21
|
+
"finch",
|
|
22
|
+
"fox",
|
|
23
|
+
"frog",
|
|
24
|
+
"gecko",
|
|
25
|
+
"hawk",
|
|
26
|
+
"heron",
|
|
27
|
+
"horse",
|
|
28
|
+
"jaguar",
|
|
29
|
+
"koala",
|
|
30
|
+
"leopard",
|
|
31
|
+
"lion",
|
|
32
|
+
"llama",
|
|
33
|
+
"lynx",
|
|
34
|
+
"mole",
|
|
35
|
+
"moose",
|
|
36
|
+
"otter",
|
|
37
|
+
"owl",
|
|
38
|
+
"panda",
|
|
39
|
+
"penguin",
|
|
40
|
+
"rabbit",
|
|
41
|
+
"robin",
|
|
42
|
+
"seal",
|
|
43
|
+
"shark",
|
|
44
|
+
"sparrow",
|
|
45
|
+
"tiger",
|
|
46
|
+
"tortoise",
|
|
47
|
+
"wolf",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
ADJECTIVES = [
|
|
51
|
+
"able",
|
|
52
|
+
"agile",
|
|
53
|
+
"alert",
|
|
54
|
+
"alpha",
|
|
55
|
+
"amber",
|
|
56
|
+
"apex",
|
|
57
|
+
"arctic",
|
|
58
|
+
"atomic",
|
|
59
|
+
"balanced",
|
|
60
|
+
"basic",
|
|
61
|
+
"bold",
|
|
62
|
+
"bright",
|
|
63
|
+
"brisk",
|
|
64
|
+
"calm",
|
|
65
|
+
"clever",
|
|
66
|
+
"clear",
|
|
67
|
+
"cloudy",
|
|
68
|
+
"crisp",
|
|
69
|
+
"curious",
|
|
70
|
+
"cyber",
|
|
71
|
+
"daring",
|
|
72
|
+
"deep",
|
|
73
|
+
"delta",
|
|
74
|
+
"digital",
|
|
75
|
+
"dynamic",
|
|
76
|
+
"early",
|
|
77
|
+
"easy",
|
|
78
|
+
"electric",
|
|
79
|
+
"epic",
|
|
80
|
+
"fast",
|
|
81
|
+
"firm",
|
|
82
|
+
"fluent",
|
|
83
|
+
"focused",
|
|
84
|
+
"fresh",
|
|
85
|
+
"friendly",
|
|
86
|
+
"full",
|
|
87
|
+
"future",
|
|
88
|
+
"gentle",
|
|
89
|
+
"global",
|
|
90
|
+
"golden",
|
|
91
|
+
"grand",
|
|
92
|
+
"great",
|
|
93
|
+
"green",
|
|
94
|
+
"happy",
|
|
95
|
+
"high",
|
|
96
|
+
"honest",
|
|
97
|
+
"hyper",
|
|
98
|
+
"ideal",
|
|
99
|
+
"infinite",
|
|
100
|
+
"inner",
|
|
101
|
+
"instant",
|
|
102
|
+
"keen",
|
|
103
|
+
"kind",
|
|
104
|
+
"known",
|
|
105
|
+
"large",
|
|
106
|
+
"light",
|
|
107
|
+
"linear",
|
|
108
|
+
"logical",
|
|
109
|
+
"lucky",
|
|
110
|
+
"lunar",
|
|
111
|
+
"magic",
|
|
112
|
+
"major",
|
|
113
|
+
"mega",
|
|
114
|
+
"mild",
|
|
115
|
+
"modern",
|
|
116
|
+
"neat",
|
|
117
|
+
"noble",
|
|
118
|
+
"open",
|
|
119
|
+
"outer",
|
|
120
|
+
"peak",
|
|
121
|
+
"perfect",
|
|
122
|
+
"plain",
|
|
123
|
+
"prime",
|
|
124
|
+
"pure",
|
|
125
|
+
"quick",
|
|
126
|
+
"quiet",
|
|
127
|
+
"rapid",
|
|
128
|
+
"rare",
|
|
129
|
+
"ready",
|
|
130
|
+
"real",
|
|
131
|
+
"red",
|
|
132
|
+
"right",
|
|
133
|
+
"safe",
|
|
134
|
+
"sharp",
|
|
135
|
+
"silent",
|
|
136
|
+
"simple",
|
|
137
|
+
"smart",
|
|
138
|
+
"solid",
|
|
139
|
+
"solar",
|
|
140
|
+
"speedy",
|
|
141
|
+
"stable",
|
|
142
|
+
"steady",
|
|
143
|
+
"stellar",
|
|
144
|
+
"strong",
|
|
145
|
+
"swift",
|
|
146
|
+
"true",
|
|
147
|
+
"ultra",
|
|
148
|
+
"vast",
|
|
149
|
+
"vital",
|
|
150
|
+
"wise",
|
|
151
|
+
]
|
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
+
import random
|
|
8
|
+
|
|
7
9
|
from pydantic import BaseModel, Field
|
|
8
10
|
|
|
11
|
+
from digitalhub.entities._constructors._resources import ADJECTIVES, ANIMALS
|
|
12
|
+
|
|
9
13
|
NAME_REGEX = r"^[a-zA-Z0-9._+-]+$"
|
|
10
14
|
|
|
11
15
|
|
|
@@ -33,3 +37,17 @@ def build_name(name: str) -> str:
|
|
|
33
37
|
"""
|
|
34
38
|
NameValidator(name=name)
|
|
35
39
|
return name
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def random_name() -> str:
|
|
43
|
+
"""
|
|
44
|
+
Generate a random name.
|
|
45
|
+
|
|
46
|
+
Returns
|
|
47
|
+
-------
|
|
48
|
+
str
|
|
49
|
+
The random name.
|
|
50
|
+
"""
|
|
51
|
+
adjective = random.choice(ADJECTIVES)
|
|
52
|
+
animal = random.choice(ANIMALS)
|
|
53
|
+
return f"{adjective}-{animal}"
|
|
@@ -7,8 +7,8 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
9
|
from digitalhub.context.api import delete_context
|
|
10
|
-
from digitalhub.entities._commons.enums import ApiCategories, BackendOperations
|
|
11
10
|
from digitalhub.factory.entity import entity_factory
|
|
11
|
+
from digitalhub.stores.client._base.enums import ApiCategories, BackendOperations
|
|
12
12
|
from digitalhub.stores.client.api import get_client
|
|
13
13
|
|
|
14
14
|
if typing.TYPE_CHECKING:
|
|
@@ -6,7 +6,7 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
|
-
from digitalhub.
|
|
9
|
+
from digitalhub.stores.client._base.enums import ApiCategories, BackendOperations
|
|
10
10
|
from digitalhub.stores.client.api import get_client
|
|
11
11
|
|
|
12
12
|
if typing.TYPE_CHECKING:
|