digitalhub 0.13.4__py3-none-any.whl → 0.14.0__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.

Files changed (116) hide show
  1. digitalhub/__init__.py +3 -8
  2. digitalhub/context/api.py +1 -5
  3. digitalhub/context/builder.py +1 -5
  4. digitalhub/context/context.py +2 -9
  5. digitalhub/entities/_base/_base/entity.py +0 -15
  6. digitalhub/entities/_base/context/entity.py +1 -1
  7. digitalhub/entities/_base/entity/builder.py +5 -5
  8. digitalhub/entities/_base/entity/entity.py +0 -8
  9. digitalhub/entities/_base/executable/entity.py +169 -79
  10. digitalhub/entities/_base/material/entity.py +6 -22
  11. digitalhub/entities/_base/material/utils.py +1 -4
  12. digitalhub/entities/_base/runtime_entity/builder.py +53 -18
  13. digitalhub/entities/_base/unversioned/entity.py +1 -1
  14. digitalhub/entities/_base/versioned/entity.py +1 -1
  15. digitalhub/entities/_commons/enums.py +1 -31
  16. digitalhub/entities/_commons/utils.py +83 -21
  17. digitalhub/entities/_constructors/_resources.py +151 -0
  18. digitalhub/entities/{_base/entity/_constructors → _constructors}/name.py +18 -0
  19. digitalhub/entities/_processors/base/__init__.py +3 -0
  20. digitalhub/entities/_processors/{base.py → base/crud.py} +14 -226
  21. digitalhub/entities/_processors/base/import_export.py +123 -0
  22. digitalhub/entities/_processors/base/processor.py +302 -0
  23. digitalhub/entities/_processors/base/special_ops.py +108 -0
  24. digitalhub/entities/_processors/context/__init__.py +3 -0
  25. digitalhub/entities/_processors/context/crud.py +652 -0
  26. digitalhub/entities/_processors/context/import_export.py +242 -0
  27. digitalhub/entities/_processors/context/material.py +123 -0
  28. digitalhub/entities/_processors/context/processor.py +400 -0
  29. digitalhub/entities/_processors/context/special_ops.py +476 -0
  30. digitalhub/entities/_processors/processors.py +12 -0
  31. digitalhub/entities/_processors/utils.py +12 -11
  32. digitalhub/entities/artifact/crud.py +58 -22
  33. digitalhub/entities/artifact/utils.py +3 -3
  34. digitalhub/entities/dataitem/crud.py +63 -20
  35. digitalhub/entities/dataitem/table/entity.py +24 -22
  36. digitalhub/entities/dataitem/utils.py +15 -15
  37. digitalhub/entities/function/_base/entity.py +3 -3
  38. digitalhub/entities/function/crud.py +55 -24
  39. digitalhub/entities/model/_base/entity.py +62 -20
  40. digitalhub/entities/model/crud.py +58 -22
  41. digitalhub/entities/model/utils.py +3 -3
  42. digitalhub/entities/project/_base/entity.py +321 -152
  43. digitalhub/entities/project/crud.py +15 -23
  44. digitalhub/entities/run/_base/builder.py +0 -4
  45. digitalhub/entities/run/_base/entity.py +70 -63
  46. digitalhub/entities/run/crud.py +79 -26
  47. digitalhub/entities/secret/_base/entity.py +1 -5
  48. digitalhub/entities/secret/crud.py +29 -26
  49. digitalhub/entities/task/_base/builder.py +0 -4
  50. digitalhub/entities/task/_base/entity.py +5 -5
  51. digitalhub/entities/task/_base/models.py +13 -16
  52. digitalhub/entities/task/crud.py +61 -29
  53. digitalhub/entities/trigger/_base/entity.py +1 -5
  54. digitalhub/entities/trigger/crud.py +64 -24
  55. digitalhub/entities/workflow/_base/entity.py +3 -3
  56. digitalhub/entities/workflow/crud.py +55 -21
  57. digitalhub/factory/entity.py +283 -0
  58. digitalhub/factory/enums.py +18 -0
  59. digitalhub/factory/registry.py +197 -0
  60. digitalhub/factory/runtime.py +44 -0
  61. digitalhub/factory/utils.py +3 -54
  62. digitalhub/runtimes/_base.py +2 -2
  63. digitalhub/stores/client/_base/enums.py +39 -0
  64. digitalhub/stores/client/_base/key_builder.py +2 -2
  65. digitalhub/stores/client/_base/params_builder.py +48 -0
  66. digitalhub/stores/client/api.py +6 -10
  67. digitalhub/stores/client/builder.py +4 -4
  68. digitalhub/stores/client/dhcore/api_builder.py +2 -1
  69. digitalhub/stores/client/dhcore/client.py +85 -429
  70. digitalhub/stores/client/dhcore/configurator.py +109 -328
  71. digitalhub/stores/client/dhcore/enums.py +0 -16
  72. digitalhub/stores/client/dhcore/error_parser.py +0 -4
  73. digitalhub/stores/client/dhcore/header_manager.py +61 -0
  74. digitalhub/stores/client/dhcore/http_handler.py +133 -0
  75. digitalhub/stores/client/dhcore/params_builder.py +147 -134
  76. digitalhub/stores/client/dhcore/response_processor.py +102 -0
  77. digitalhub/stores/client/dhcore/utils.py +6 -72
  78. digitalhub/stores/client/local/api_builder.py +1 -1
  79. digitalhub/stores/client/local/client.py +79 -47
  80. digitalhub/stores/client/local/params_builder.py +18 -41
  81. digitalhub/stores/credentials/api.py +0 -4
  82. digitalhub/stores/credentials/configurator.py +2 -28
  83. digitalhub/stores/credentials/enums.py +3 -0
  84. digitalhub/stores/credentials/handler.py +0 -12
  85. digitalhub/stores/credentials/ini_module.py +0 -22
  86. digitalhub/stores/credentials/store.py +0 -4
  87. digitalhub/stores/data/_base/store.py +0 -16
  88. digitalhub/stores/data/builder.py +1 -5
  89. digitalhub/stores/data/local/store.py +0 -103
  90. digitalhub/stores/data/remote/store.py +0 -4
  91. digitalhub/stores/data/s3/configurator.py +60 -14
  92. digitalhub/stores/data/s3/store.py +49 -16
  93. digitalhub/stores/data/sql/configurator.py +0 -8
  94. digitalhub/stores/data/sql/store.py +21 -10
  95. digitalhub/stores/readers/data/factory.py +0 -8
  96. digitalhub/stores/readers/data/pandas/reader.py +0 -16
  97. digitalhub/utils/file_utils.py +0 -17
  98. digitalhub/utils/generic_utils.py +0 -12
  99. digitalhub/utils/git_utils.py +0 -8
  100. digitalhub/utils/io_utils.py +0 -12
  101. digitalhub/utils/store_utils.py +44 -0
  102. {digitalhub-0.13.4.dist-info → digitalhub-0.14.0.dist-info}/METADATA +3 -2
  103. {digitalhub-0.13.4.dist-info → digitalhub-0.14.0.dist-info}/RECORD +111 -95
  104. digitalhub/entities/_processors/context.py +0 -1450
  105. digitalhub/entities/task/_base/utils.py +0 -22
  106. digitalhub/factory/factory.py +0 -381
  107. digitalhub/stores/client/dhcore/models.py +0 -40
  108. digitalhub/stores/data/s3/utils.py +0 -78
  109. /digitalhub/entities/{_base/entity/_constructors → _constructors}/__init__.py +0 -0
  110. /digitalhub/entities/{_base/entity/_constructors → _constructors}/metadata.py +0 -0
  111. /digitalhub/entities/{_base/entity/_constructors → _constructors}/spec.py +0 -0
  112. /digitalhub/entities/{_base/entity/_constructors → _constructors}/status.py +0 -0
  113. /digitalhub/entities/{_base/entity/_constructors → _constructors}/uuid.py +0 -0
  114. {digitalhub-0.13.4.dist-info → digitalhub-0.14.0.dist-info}/WHEEL +0 -0
  115. {digitalhub-0.13.4.dist-info → digitalhub-0.14.0.dist-info}/licenses/AUTHORS +0 -0
  116. {digitalhub-0.13.4.dist-info → digitalhub-0.14.0.dist-info}/licenses/LICENSE +0 -0
@@ -7,8 +7,7 @@ from __future__ import annotations
7
7
  import typing
8
8
 
9
9
  from digitalhub.entities._commons.enums import EntityTypes
10
- from digitalhub.entities._processors.base import base_processor
11
- from digitalhub.entities._processors.context import context_processor
10
+ from digitalhub.entities._processors.processors import base_processor, context_processor
12
11
  from digitalhub.entities.project.utils import setup_project
13
12
  from digitalhub.utils.exceptions import BackendError
14
13
 
@@ -80,7 +79,6 @@ def get_project(
80
79
  name: str,
81
80
  local: bool = False,
82
81
  setup_kwargs: dict | None = None,
83
- **kwargs,
84
82
  ) -> Project:
85
83
  """
86
84
  Retrieves project details from backend.
@@ -93,8 +91,6 @@ def get_project(
93
91
  Flag to determine if backend is local.
94
92
  setup_kwargs : dict
95
93
  Setup keyword arguments passed to setup_project() function.
96
- **kwargs : dict
97
- Parameters to pass to the API call.
98
94
 
99
95
  Returns
100
96
  -------
@@ -109,7 +105,6 @@ def get_project(
109
105
  entity_type=ENTITY_TYPE,
110
106
  entity_name=name,
111
107
  local=local,
112
- **kwargs,
113
108
  )
114
109
  return setup_project(obj, setup_kwargs)
115
110
 
@@ -118,6 +113,7 @@ def import_project(
118
113
  file: str,
119
114
  local: bool = False,
120
115
  setup_kwargs: dict | None = None,
116
+ reset_id: bool = False,
121
117
  ) -> Project:
122
118
  """
123
119
  Import object from a YAML file and create a new object into the backend.
@@ -130,6 +126,8 @@ def import_project(
130
126
  Flag to determine if backend is local.
131
127
  setup_kwargs : dict
132
128
  Setup keyword arguments passed to setup_project() function.
129
+ reset_id : bool
130
+ Flag to determine if the ID of project entities should be reset.
133
131
 
134
132
  Returns
135
133
  -------
@@ -140,7 +138,11 @@ def import_project(
140
138
  --------
141
139
  >>> obj = import_project("my-project.yaml")
142
140
  """
143
- obj = base_processor.import_project_entity(file=file, local=local)
141
+ obj = base_processor.import_project_entity(
142
+ file=file,
143
+ local=local,
144
+ reset_id=reset_id,
145
+ )
144
146
  return setup_project(obj, setup_kwargs)
145
147
 
146
148
 
@@ -174,7 +176,7 @@ def load_project(
174
176
  return setup_project(obj, setup_kwargs)
175
177
 
176
178
 
177
- def list_projects(local: bool = False, **kwargs) -> list[Project]:
179
+ def list_projects(local: bool = False) -> list[Project]:
178
180
  """
179
181
  List projects in backend.
180
182
 
@@ -182,15 +184,13 @@ def list_projects(local: bool = False, **kwargs) -> list[Project]:
182
184
  ----------
183
185
  local : bool
184
186
  Flag to determine if backend is local.
185
- **kwargs : dict
186
- Parameters to pass to the API call.
187
187
 
188
188
  Returns
189
189
  -------
190
190
  list
191
191
  List of objects.
192
192
  """
193
- return base_processor.list_project_entities(local=local, **kwargs)
193
+ return base_processor.list_project_entities(local=local)
194
194
 
195
195
 
196
196
  def get_or_create_project(
@@ -276,7 +276,6 @@ def delete_project(
276
276
  cascade: bool = True,
277
277
  clean_context: bool = True,
278
278
  local: bool = False,
279
- **kwargs,
280
279
  ) -> dict:
281
280
  """
282
281
  Delete a project.
@@ -291,8 +290,6 @@ def delete_project(
291
290
  Flag to determine if context will be deleted.
292
291
  local : bool
293
292
  Flag to determine if backend is local.
294
- **kwargs : dict
295
- Parameters to pass to the API call.
296
293
 
297
294
  Returns
298
295
  -------
@@ -309,7 +306,6 @@ def delete_project(
309
306
  local=local,
310
307
  cascade=cascade,
311
308
  clean_context=clean_context,
312
- **kwargs,
313
309
  )
314
310
 
315
311
 
@@ -323,7 +319,6 @@ def search_entity(
323
319
  updated: str | None = None,
324
320
  description: str | None = None,
325
321
  labels: list[str] | None = None,
326
- **kwargs,
327
322
  ) -> list[ContextEntity]:
328
323
  """
329
324
  Search objects from backend.
@@ -348,13 +343,11 @@ def search_entity(
348
343
  Entity description.
349
344
  labels : list[str]
350
345
  Entity labels.
351
- **kwargs : dict
352
- Parameters to pass to the API call.
353
346
 
354
- Returns
355
- -------
356
- list[ContextEntity]
357
- List of object instances.
347
+ Returns
348
+ -------
349
+ list[ContextEntity]
350
+ List of object instances.
358
351
  """
359
352
  return context_processor.search_entity(
360
353
  project_name,
@@ -366,5 +359,4 @@ def search_entity(
366
359
  updated=updated,
367
360
  description=description,
368
361
  labels=labels,
369
- **kwargs,
370
362
  )
@@ -90,10 +90,6 @@ class RunBuilder(UnversionedBuilder, RuntimeEntityBuilder):
90
90
  ----------
91
91
  task : str
92
92
  Task string.
93
-
94
- Returns
95
- -------
96
- None
97
93
  """
98
94
  task_kind = task.split("://")[0]
99
95
  if task_kind not in self.get_all_kinds():
@@ -10,8 +10,9 @@ import typing
10
10
  from digitalhub.entities._base.unversioned.entity import UnversionedEntity
11
11
  from digitalhub.entities._commons.enums import EntityTypes, State
12
12
  from digitalhub.entities._commons.metrics import MetricType, set_metrics, validate_metric_value
13
- from digitalhub.entities._processors.context import context_processor
14
- from digitalhub.factory.factory import factory
13
+ from digitalhub.entities._processors.processors import context_processor
14
+ from digitalhub.factory.entity import entity_factory
15
+ from digitalhub.factory.runtime import runtime_factory
15
16
  from digitalhub.utils.exceptions import EntityError
16
17
  from digitalhub.utils.logger import LOGGER
17
18
 
@@ -51,15 +52,11 @@ class Run(UnversionedEntity):
51
52
  def build(self) -> None:
52
53
  """
53
54
  Build run.
54
-
55
- Returns
56
- -------
57
- None
58
55
  """
59
56
  executable = self._get_executable()
60
57
  task = self._get_task()
61
58
  new_spec = self._get_runtime().build(executable, task, self.to_dict())
62
- self.spec = factory.build_spec(self.kind, **new_spec)
59
+ self.spec = entity_factory.build_spec(self.kind, **new_spec)
63
60
  self._set_state(State.BUILT.value)
64
61
  self.save(update=True)
65
62
 
@@ -141,10 +138,6 @@ class Run(UnversionedEntity):
141
138
  def stop(self) -> None:
142
139
  """
143
140
  Stop run.
144
-
145
- Returns
146
- -------
147
- None
148
141
  """
149
142
  if not self.spec.local_execution:
150
143
  return context_processor.stop_entity(self.project, self.ENTITY_TYPE, self.id)
@@ -152,10 +145,6 @@ class Run(UnversionedEntity):
152
145
  def resume(self) -> None:
153
146
  """
154
147
  Resume run.
155
-
156
- Returns
157
- -------
158
- None
159
148
  """
160
149
  if not self.spec.local_execution:
161
150
  return context_processor.resume_entity(self.project, self.ENTITY_TYPE, self.id)
@@ -184,10 +173,6 @@ class Run(UnversionedEntity):
184
173
  single_value : bool
185
174
  If True, value is a single value.
186
175
 
187
- Returns
188
- -------
189
- None
190
-
191
176
  Examples
192
177
  --------
193
178
  Log a new value in a list
@@ -197,13 +182,27 @@ class Run(UnversionedEntity):
197
182
  >>> entity.log_metric("loss", 0.0019)
198
183
 
199
184
  Log a list of values and append them to existing metric:
200
- >>> entity.log_metric("loss", [0.0018, 0.0015])
185
+ >>> entity.log_metric(
186
+ ... "loss",
187
+ ... [
188
+ ... 0.0018,
189
+ ... 0.0015,
190
+ ... ],
191
+ ... )
201
192
 
202
193
  Log a single value (not represented as list):
203
- >>> entity.log_metric("accuracy", 0.9, single_value=True)
194
+ >>> entity.log_metric(
195
+ ... "accuracy",
196
+ ... 0.9,
197
+ ... single_value=True,
198
+ ... )
204
199
 
205
200
  Log a list of values and overwrite existing metric:
206
- >>> entity.log_metric("accuracy", [0.8, 0.9], overwrite=True)
201
+ >>> entity.log_metric(
202
+ ... "accuracy",
203
+ ... [0.8, 0.9],
204
+ ... overwrite=True,
205
+ ... )
207
206
  """
208
207
  self._set_metrics(key, value, overwrite, single_value)
209
208
  context_processor.update_metric(self.project, self.ENTITY_TYPE, self.id, key, self.status.metrics[key])
@@ -224,19 +223,59 @@ class Run(UnversionedEntity):
224
223
  overwrite : bool
225
224
  If True, overwrite existing metrics.
226
225
 
227
- Returns
228
- -------
229
- None
226
+ Examples
227
+ --------
228
+ Log multiple metrics at once
229
+ >>> entity.log_metrics(
230
+ ... {
231
+ ... "loss": 0.002,
232
+ ... "accuracy": 0.95,
233
+ ... }
234
+ ... )
235
+
236
+ Log metrics with lists and single values
237
+ >>> entity.log_metrics(
238
+ ... {
239
+ ... "loss": [
240
+ ... 0.1,
241
+ ... 0.05,
242
+ ... ],
243
+ ... "epoch": 10,
244
+ ... }
245
+ ... )
246
+
247
+ Append to existing metrics (default behavior)
248
+ >>> entity.log_metrics(
249
+ ... {
250
+ ... "loss": 0.001,
251
+ ... "accuracy": 0.96,
252
+ ... }
253
+ ... ) # Appends to existing
254
+
255
+ Overwrite existing metrics
256
+ >>> entity.log_metrics(
257
+ ... {
258
+ ... "loss": 0.0005,
259
+ ... "accuracy": 0.98,
260
+ ... },
261
+ ... overwrite=True,
262
+ ... )
230
263
 
231
264
  See also
232
265
  --------
233
266
  log_metric
234
267
  """
235
268
  for key, value in metrics.items():
269
+ # For lists, use log_metric which handles appending correctly
236
270
  if isinstance(value, list):
237
271
  self.log_metric(key, value, overwrite)
272
+
273
+ # For single values, check if we should append or create new
238
274
  else:
239
- self.log_metric(key, value, overwrite, single_value=True)
275
+ if not overwrite and key in self.status.metrics:
276
+ self.log_metric(key, value)
277
+ else:
278
+ self.log_metric(key, value, overwrite, single_value=True)
240
279
 
241
280
  ##############################
242
281
  # Helpers
@@ -245,19 +284,11 @@ class Run(UnversionedEntity):
245
284
  def _setup_execution(self) -> None:
246
285
  """
247
286
  Setup run execution.
248
-
249
- Returns
250
- -------
251
- None
252
287
  """
253
288
 
254
289
  def _start_execution(self) -> None:
255
290
  """
256
291
  Start run execution.
257
-
258
- Returns
259
- -------
260
- None
261
292
  """
262
293
  self._context().set_run(f"{self.key}:{self.id}")
263
294
  if self.spec.local_execution:
@@ -269,10 +300,6 @@ class Run(UnversionedEntity):
269
300
  def _finish_execution(self) -> None:
270
301
  """
271
302
  Finish run execution.
272
-
273
- Returns
274
- -------
275
- None
276
303
  """
277
304
  self._context().unset_run()
278
305
 
@@ -285,7 +312,7 @@ class Run(UnversionedEntity):
285
312
  bool
286
313
  True if run is in runnable state, False otherwise.
287
314
  """
288
- return (self.status.state == State.BUILT.value) or (self.status.state == State.STOPPED.value)
315
+ return self.status.state in (State.BUILT.value, State.STOPPED.value)
289
316
 
290
317
  def _set_status(self, status: dict) -> None:
291
318
  """
@@ -295,12 +322,8 @@ class Run(UnversionedEntity):
295
322
  ----------
296
323
  status : dict
297
324
  Status to set.
298
-
299
- Returns
300
- -------
301
- None
302
325
  """
303
- self.status: RunStatus = factory.build_status(self.kind, **status)
326
+ self.status: RunStatus = entity_factory.build_status(self.kind, **status)
304
327
 
305
328
  def _set_state(self, state: str) -> None:
306
329
  """
@@ -310,10 +333,6 @@ class Run(UnversionedEntity):
310
333
  ----------
311
334
  state : str
312
335
  State to set.
313
-
314
- Returns
315
- -------
316
- None
317
336
  """
318
337
  self.status.state = state
319
338
 
@@ -325,10 +344,6 @@ class Run(UnversionedEntity):
325
344
  ----------
326
345
  message : str
327
346
  Message to set.
328
-
329
- Returns
330
- -------
331
- None
332
347
  """
333
348
  self.status.message = message
334
349
 
@@ -341,7 +356,7 @@ class Run(UnversionedEntity):
341
356
  Runtime
342
357
  Runtime object.
343
358
  """
344
- return factory.build_runtime(self.kind, self.project)
359
+ return runtime_factory.build_runtime(self.kind, self.project)
345
360
 
346
361
  def _get_executable(self) -> dict:
347
362
  """
@@ -353,8 +368,8 @@ class Run(UnversionedEntity):
353
368
  dict
354
369
  Executable (function or workflow) from backend.
355
370
  """
356
- exec_kind = factory.get_executable_kind(self.kind)
357
- exec_type = factory.get_entity_type_from_kind(exec_kind)
371
+ exec_kind = entity_factory.get_executable_kind(self.kind)
372
+ exec_type = entity_factory.get_entity_type_from_kind(exec_kind)
358
373
  string_to_split = getattr(self.spec, exec_type)
359
374
  exec_name, exec_id = string_to_split.split("://")[-1].split("/")[-1].split(":")
360
375
  return context_processor.read_context_entity(
@@ -384,10 +399,6 @@ class Run(UnversionedEntity):
384
399
  def _get_metrics(self) -> None:
385
400
  """
386
401
  Get model metrics from backend.
387
-
388
- Returns
389
- -------
390
- None
391
402
  """
392
403
  self.status.metrics = context_processor.read_metrics(
393
404
  project=self.project,
@@ -415,10 +426,6 @@ class Run(UnversionedEntity):
415
426
  If True, overwrite existing metric.
416
427
  single_value : bool
417
428
  If True, value is a single value.
418
-
419
- Returns
420
- -------
421
- None
422
429
  """
423
430
  value = validate_metric_value(value)
424
431
  self.status.metrics = set_metrics(
@@ -7,8 +7,7 @@ from __future__ import annotations
7
7
  import typing
8
8
 
9
9
  from digitalhub.entities._commons.enums import EntityTypes
10
- from digitalhub.entities._processors.context import context_processor
11
- from digitalhub.utils.exceptions import EntityError
10
+ from digitalhub.entities._processors.processors import context_processor
12
11
 
13
12
  if typing.TYPE_CHECKING:
14
13
  from digitalhub.entities.run._base.entity import Run
@@ -71,7 +70,6 @@ def new_run(
71
70
  def get_run(
72
71
  identifier: str,
73
72
  project: str | None = None,
74
- **kwargs,
75
73
  ) -> Run:
76
74
  """
77
75
  Get object from backend.
@@ -82,8 +80,6 @@ def get_run(
82
80
  Entity key (store://...) or entity ID.
83
81
  project : str
84
82
  Project name.
85
- **kwargs : dict
86
- Parameters to pass to the API call.
87
83
 
88
84
  Returns
89
85
  -------
@@ -100,14 +96,26 @@ def get_run(
100
96
  >>> project="my-project")
101
97
  """
102
98
  return context_processor.read_unversioned_entity(
103
- identifier,
99
+ identifier=identifier,
104
100
  entity_type=ENTITY_TYPE,
105
101
  project=project,
106
- **kwargs,
107
102
  )
108
103
 
109
104
 
110
- def list_runs(project: str, **kwargs) -> list[Run]:
105
+ def list_runs(
106
+ project: str,
107
+ q: str | None = None,
108
+ name: str | None = None,
109
+ kind: str | None = None,
110
+ user: str | None = None,
111
+ state: str | None = None,
112
+ created: str | None = None,
113
+ updated: str | None = None,
114
+ function: str | None = None,
115
+ workflow: str | None = None,
116
+ task: str | None = None,
117
+ action: str | None = None,
118
+ ) -> list[Run]:
111
119
  """
112
120
  List all latest version objects from backend.
113
121
 
@@ -115,34 +123,74 @@ def list_runs(project: str, **kwargs) -> list[Run]:
115
123
  ----------
116
124
  project : str
117
125
  Project name.
118
- **kwargs : dict
119
- Parameters to pass to the API call.
126
+ q : str
127
+ Query string to filter objects.
128
+ name : str
129
+ Object name.
130
+ kind : str
131
+ Kind of the object.
132
+ user : str
133
+ User that created the object.
134
+ state : str
135
+ Object state.
136
+ created : str
137
+ Creation date filter.
138
+ updated : str
139
+ Update date filter.
140
+ function : str
141
+ Function key filter.
142
+ workflow : str
143
+ Workflow key filter.
144
+ task : str
145
+ Task string filter.
146
+ action : str
147
+ Action name filter.
120
148
 
121
149
  Returns
122
150
  -------
123
- list[Run]
151
+ list[Model]
124
152
  List of object instances.
125
153
 
126
154
  Examples
127
155
  --------
128
156
  >>> objs = list_runs(project="my-project")
129
157
  """
130
- # TODO more examples: search by function, latest for task and function
131
158
  return context_processor.list_context_entities(
132
159
  project=project,
133
160
  entity_type=ENTITY_TYPE,
134
- **kwargs,
161
+ q=q,
162
+ name=name,
163
+ kind=kind,
164
+ user=user,
165
+ state=state,
166
+ created=created,
167
+ updated=updated,
168
+ function=function,
169
+ workflow=workflow,
170
+ task=task,
171
+ action=action,
135
172
  )
136
173
 
137
174
 
138
- def import_run(file: str) -> Run:
175
+ def import_run(
176
+ file: str | None = None,
177
+ key: str | None = None,
178
+ reset_id: bool = False,
179
+ context: str | None = None,
180
+ ) -> Run:
139
181
  """
140
- Import object from a YAML file and create a new object into the backend.
182
+ Import an object from a YAML file or from a storage key.
141
183
 
142
184
  Parameters
143
185
  ----------
144
186
  file : str
145
- Path to YAML file.
187
+ Path to the YAML file.
188
+ key : str
189
+ Entity key (store://...).
190
+ reset_id : bool
191
+ Flag to determine if the ID of executable entities should be reset.
192
+ context : str
193
+ Project name to use for context resolution.
146
194
 
147
195
  Returns
148
196
  -------
@@ -153,7 +201,12 @@ def import_run(file: str) -> Run:
153
201
  -------
154
202
  >>> obj = import_run("my-run.yaml")
155
203
  """
156
- return context_processor.import_context_entity(file)
204
+ return context_processor.import_context_entity(
205
+ file,
206
+ key,
207
+ reset_id,
208
+ context,
209
+ )
157
210
 
158
211
 
159
212
  def load_run(file: str) -> Run:
@@ -206,7 +259,7 @@ def update_run(entity: Run) -> Run:
206
259
  def delete_run(
207
260
  identifier: str,
208
261
  project: str | None = None,
209
- **kwargs,
262
+ entity_id: str | None = None,
210
263
  ) -> dict:
211
264
  """
212
265
  Delete object from backend.
@@ -214,11 +267,11 @@ def delete_run(
214
267
  Parameters
215
268
  ----------
216
269
  identifier : str
217
- Entity key (store://...) or entity ID.
270
+ Entity key (store://...) or entity name.
218
271
  project : str
219
272
  Project name.
220
- **kwargs : dict
221
- Parameters to pass to the API call.
273
+ entity_id : str
274
+ Entity ID.
222
275
 
223
276
  Returns
224
277
  -------
@@ -228,14 +281,14 @@ def delete_run(
228
281
  Examples
229
282
  --------
230
283
  >>> obj = delete_run("store://my-run-key")
231
- >>> obj = delete_run("my-run-id", project="my-project")
284
+ >>> obj = delete_run(
285
+ ... "my-run-id",
286
+ ... project="my-project",
287
+ ... )
232
288
  """
233
- if not identifier.startswith("store://") and project is None:
234
- raise EntityError("Specify entity key or entity ID combined with project")
235
289
  return context_processor.delete_context_entity(
236
290
  identifier=identifier,
237
291
  entity_type=ENTITY_TYPE,
238
292
  project=project,
239
- entity_id=identifier,
240
- **kwargs,
293
+ entity_id=entity_id,
241
294
  )
@@ -8,7 +8,7 @@ import typing
8
8
 
9
9
  from digitalhub.entities._base.versioned.entity import VersionedEntity
10
10
  from digitalhub.entities._commons.enums import EntityTypes
11
- from digitalhub.entities._processors.context import context_processor
11
+ from digitalhub.entities._processors.processors import context_processor
12
12
 
13
13
  if typing.TYPE_CHECKING:
14
14
  from digitalhub.entities._base.entity.metadata import Metadata
@@ -50,10 +50,6 @@ class Secret(VersionedEntity):
50
50
  ----------
51
51
  value : str
52
52
  Value of the secret.
53
-
54
- Returns
55
- -------
56
- None
57
53
  """
58
54
  obj = {self.name: value}
59
55
  context_processor.update_secret_data(self.project, self.ENTITY_TYPE, obj)