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.

Files changed (75) hide show
  1. digitalhub/context/builder.py +0 -4
  2. digitalhub/context/context.py +12 -8
  3. digitalhub/entities/_base/_base/entity.py +0 -4
  4. digitalhub/entities/_base/context/entity.py +1 -1
  5. digitalhub/entities/_base/entity/entity.py +0 -8
  6. digitalhub/entities/_base/executable/entity.py +161 -79
  7. digitalhub/entities/_base/material/entity.py +7 -23
  8. digitalhub/entities/_base/material/utils.py +28 -0
  9. digitalhub/entities/_base/unversioned/entity.py +1 -1
  10. digitalhub/entities/_base/versioned/entity.py +1 -1
  11. digitalhub/entities/_commons/enums.py +0 -31
  12. digitalhub/entities/_constructors/_resources.py +151 -0
  13. digitalhub/entities/_constructors/name.py +18 -0
  14. digitalhub/entities/_processors/base/__init__.py +3 -0
  15. digitalhub/entities/_processors/{base.py → base/crud.py} +7 -227
  16. digitalhub/entities/_processors/base/import_export.py +122 -0
  17. digitalhub/entities/_processors/base/processor.py +302 -0
  18. digitalhub/entities/_processors/base/special_ops.py +108 -0
  19. digitalhub/entities/_processors/context/__init__.py +3 -0
  20. digitalhub/entities/_processors/context/crud.py +654 -0
  21. digitalhub/entities/_processors/context/import_export.py +242 -0
  22. digitalhub/entities/_processors/context/material.py +123 -0
  23. digitalhub/entities/_processors/context/processor.py +400 -0
  24. digitalhub/entities/_processors/context/special_ops.py +476 -0
  25. digitalhub/entities/_processors/processors.py +12 -0
  26. digitalhub/entities/_processors/utils.py +2 -1
  27. digitalhub/entities/artifact/crud.py +45 -41
  28. digitalhub/entities/dataitem/crud.py +45 -37
  29. digitalhub/entities/dataitem/table/entity.py +5 -6
  30. digitalhub/entities/function/crud.py +47 -43
  31. digitalhub/entities/model/_base/entity.py +3 -23
  32. digitalhub/entities/model/crud.py +45 -39
  33. digitalhub/entities/project/_base/entity.py +45 -134
  34. digitalhub/entities/project/crud.py +13 -42
  35. digitalhub/entities/run/_base/builder.py +0 -4
  36. digitalhub/entities/run/_base/entity.py +4 -60
  37. digitalhub/entities/run/crud.py +61 -40
  38. digitalhub/entities/secret/_base/entity.py +1 -5
  39. digitalhub/entities/secret/crud.py +14 -42
  40. digitalhub/entities/task/_base/builder.py +0 -4
  41. digitalhub/entities/task/_base/entity.py +1 -1
  42. digitalhub/entities/task/crud.py +47 -44
  43. digitalhub/entities/trigger/_base/entity.py +1 -5
  44. digitalhub/entities/trigger/crud.py +51 -43
  45. digitalhub/entities/workflow/crud.py +47 -40
  46. digitalhub/factory/registry.py +0 -24
  47. digitalhub/stores/client/_base/enums.py +39 -0
  48. digitalhub/stores/client/_base/key_builder.py +1 -1
  49. digitalhub/stores/client/_base/params_builder.py +48 -0
  50. digitalhub/stores/client/dhcore/api_builder.py +2 -1
  51. digitalhub/stores/client/dhcore/client.py +67 -73
  52. digitalhub/stores/client/dhcore/configurator.py +5 -28
  53. digitalhub/stores/client/dhcore/error_parser.py +0 -4
  54. digitalhub/stores/client/dhcore/params_builder.py +130 -75
  55. digitalhub/stores/client/local/api_builder.py +1 -1
  56. digitalhub/stores/client/local/params_builder.py +18 -41
  57. digitalhub/stores/credentials/configurator.py +0 -24
  58. digitalhub/stores/credentials/handler.py +0 -12
  59. digitalhub/stores/credentials/store.py +0 -4
  60. digitalhub/stores/data/_base/store.py +0 -16
  61. digitalhub/stores/data/builder.py +0 -4
  62. digitalhub/stores/data/remote/store.py +0 -4
  63. digitalhub/stores/data/s3/configurator.py +0 -8
  64. digitalhub/stores/data/s3/store.py +8 -17
  65. digitalhub/stores/data/sql/configurator.py +0 -8
  66. digitalhub/stores/data/sql/store.py +0 -4
  67. digitalhub/stores/readers/data/factory.py +0 -8
  68. digitalhub/stores/readers/data/pandas/reader.py +0 -16
  69. digitalhub/utils/io_utils.py +0 -4
  70. {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b4.dist-info}/METADATA +1 -1
  71. {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b4.dist-info}/RECORD +74 -62
  72. digitalhub/entities/_processors/context.py +0 -1499
  73. {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b4.dist-info}/WHEEL +0 -0
  74. {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b4.dist-info}/licenses/AUTHORS +0 -0
  75. {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b4.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
 
@@ -59,9 +58,7 @@ def new_project(
59
58
 
60
59
  Examples
61
60
  --------
62
- >>> obj = new_project(
63
- ... "my-project"
64
- ... )
61
+ >>> obj = new_project("my-project")
65
62
  """
66
63
  if context is None:
67
64
  context = "./"
@@ -82,7 +79,6 @@ def get_project(
82
79
  name: str,
83
80
  local: bool = False,
84
81
  setup_kwargs: dict | None = None,
85
- **kwargs,
86
82
  ) -> Project:
87
83
  """
88
84
  Retrieves project details from backend.
@@ -95,8 +91,6 @@ def get_project(
95
91
  Flag to determine if backend is local.
96
92
  setup_kwargs : dict
97
93
  Setup keyword arguments passed to setup_project() function.
98
- **kwargs : dict
99
- Parameters to pass to the API call.
100
94
 
101
95
  Returns
102
96
  -------
@@ -105,15 +99,12 @@ def get_project(
105
99
 
106
100
  Examples
107
101
  --------
108
- >>> obj = get_project(
109
- ... "my-project"
110
- ... )
102
+ >>> obj = get_project("my-project")
111
103
  """
112
104
  obj = base_processor.read_project_entity(
113
105
  entity_type=ENTITY_TYPE,
114
106
  entity_name=name,
115
107
  local=local,
116
- **kwargs,
117
108
  )
118
109
  return setup_project(obj, setup_kwargs)
119
110
 
@@ -145,9 +136,7 @@ def import_project(
145
136
 
146
137
  Examples
147
138
  --------
148
- >>> obj = import_project(
149
- ... "my-project.yaml"
150
- ... )
139
+ >>> obj = import_project("my-project.yaml")
151
140
  """
152
141
  obj = base_processor.import_project_entity(
153
142
  file=file,
@@ -181,15 +170,13 @@ def load_project(
181
170
 
182
171
  Examples
183
172
  --------
184
- >>> obj = load_project(
185
- ... "my-project.yaml"
186
- ... )
173
+ >>> obj = load_project("my-project.yaml")
187
174
  """
188
175
  obj = base_processor.load_project_entity(file=file, local=local)
189
176
  return setup_project(obj, setup_kwargs)
190
177
 
191
178
 
192
- def list_projects(local: bool = False, **kwargs) -> list[Project]:
179
+ def list_projects(local: bool = False) -> list[Project]:
193
180
  """
194
181
  List projects in backend.
195
182
 
@@ -197,15 +184,13 @@ def list_projects(local: bool = False, **kwargs) -> list[Project]:
197
184
  ----------
198
185
  local : bool
199
186
  Flag to determine if backend is local.
200
- **kwargs : dict
201
- Parameters to pass to the API call.
202
187
 
203
188
  Returns
204
189
  -------
205
190
  list
206
191
  List of objects.
207
192
  """
208
- return base_processor.list_project_entities(local=local, **kwargs)
193
+ return base_processor.list_project_entities(local=local)
209
194
 
210
195
 
211
196
  def get_or_create_project(
@@ -275,11 +260,7 @@ def update_project(entity: Project, **kwargs) -> Project:
275
260
 
276
261
  Examples
277
262
  --------
278
- >>> obj = (
279
- ... update_project(
280
- ... obj
281
- ... )
282
- ... )
263
+ >>> obj = update_project(obj)
283
264
  """
284
265
  return base_processor.update_project_entity(
285
266
  entity_type=entity.ENTITY_TYPE,
@@ -295,7 +276,6 @@ def delete_project(
295
276
  cascade: bool = True,
296
277
  clean_context: bool = True,
297
278
  local: bool = False,
298
- **kwargs,
299
279
  ) -> dict:
300
280
  """
301
281
  Delete a project.
@@ -310,8 +290,6 @@ def delete_project(
310
290
  Flag to determine if context will be deleted.
311
291
  local : bool
312
292
  Flag to determine if backend is local.
313
- **kwargs : dict
314
- Parameters to pass to the API call.
315
293
 
316
294
  Returns
317
295
  -------
@@ -320,9 +298,7 @@ def delete_project(
320
298
 
321
299
  Examples
322
300
  --------
323
- >>> delete_project(
324
- ... "my-project"
325
- ... )
301
+ >>> delete_project("my-project")
326
302
  """
327
303
  return base_processor.delete_project_entity(
328
304
  entity_type=ENTITY_TYPE,
@@ -330,7 +306,6 @@ def delete_project(
330
306
  local=local,
331
307
  cascade=cascade,
332
308
  clean_context=clean_context,
333
- **kwargs,
334
309
  )
335
310
 
336
311
 
@@ -344,7 +319,6 @@ def search_entity(
344
319
  updated: str | None = None,
345
320
  description: str | None = None,
346
321
  labels: list[str] | None = None,
347
- **kwargs,
348
322
  ) -> list[ContextEntity]:
349
323
  """
350
324
  Search objects from backend.
@@ -369,13 +343,11 @@ def search_entity(
369
343
  Entity description.
370
344
  labels : list[str]
371
345
  Entity labels.
372
- **kwargs : dict
373
- Parameters to pass to the API call.
374
346
 
375
- Returns
376
- -------
377
- list[ContextEntity]
378
- List of object instances.
347
+ Returns
348
+ -------
349
+ list[ContextEntity]
350
+ List of object instances.
379
351
  """
380
352
  return context_processor.search_entity(
381
353
  project_name,
@@ -387,5 +359,4 @@ def search_entity(
387
359
  updated=updated,
388
360
  description=description,
389
361
  labels=labels,
390
- **kwargs,
391
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,7 +10,7 @@ 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
13
+ from digitalhub.entities._processors.processors import context_processor
14
14
  from digitalhub.factory.entity import entity_factory
15
15
  from digitalhub.factory.runtime import runtime_factory
16
16
  from digitalhub.utils.exceptions import EntityError
@@ -52,10 +52,6 @@ class Run(UnversionedEntity):
52
52
  def build(self) -> None:
53
53
  """
54
54
  Build run.
55
-
56
- Returns
57
- -------
58
- None
59
55
  """
60
56
  executable = self._get_executable()
61
57
  task = self._get_task()
@@ -142,10 +138,6 @@ class Run(UnversionedEntity):
142
138
  def stop(self) -> None:
143
139
  """
144
140
  Stop run.
145
-
146
- Returns
147
- -------
148
- None
149
141
  """
150
142
  if not self.spec.local_execution:
151
143
  return context_processor.stop_entity(self.project, self.ENTITY_TYPE, self.id)
@@ -153,10 +145,6 @@ class Run(UnversionedEntity):
153
145
  def resume(self) -> None:
154
146
  """
155
147
  Resume run.
156
-
157
- Returns
158
- -------
159
- None
160
148
  """
161
149
  if not self.spec.local_execution:
162
150
  return context_processor.resume_entity(self.project, self.ENTITY_TYPE, self.id)
@@ -185,21 +173,13 @@ class Run(UnversionedEntity):
185
173
  single_value : bool
186
174
  If True, value is a single value.
187
175
 
188
- Returns
189
- -------
190
- None
191
-
192
176
  Examples
193
177
  --------
194
178
  Log a new value in a list
195
- >>> entity.log_metric(
196
- ... "loss", 0.002
197
- ... )
179
+ >>> entity.log_metric("loss", 0.002)
198
180
 
199
181
  Append a new value in a list
200
- >>> entity.log_metric(
201
- ... "loss", 0.0019
202
- ... )
182
+ >>> entity.log_metric("loss", 0.0019)
203
183
 
204
184
  Log a list of values and append them to existing metric:
205
185
  >>> entity.log_metric(
@@ -243,10 +223,6 @@ class Run(UnversionedEntity):
243
223
  overwrite : bool
244
224
  If True, overwrite existing metrics.
245
225
 
246
- Returns
247
- -------
248
- None
249
-
250
226
  Examples
251
227
  --------
252
228
  Log multiple metrics at once
@@ -308,19 +284,11 @@ class Run(UnversionedEntity):
308
284
  def _setup_execution(self) -> None:
309
285
  """
310
286
  Setup run execution.
311
-
312
- Returns
313
- -------
314
- None
315
287
  """
316
288
 
317
289
  def _start_execution(self) -> None:
318
290
  """
319
291
  Start run execution.
320
-
321
- Returns
322
- -------
323
- None
324
292
  """
325
293
  self._context().set_run(f"{self.key}:{self.id}")
326
294
  if self.spec.local_execution:
@@ -332,10 +300,6 @@ class Run(UnversionedEntity):
332
300
  def _finish_execution(self) -> None:
333
301
  """
334
302
  Finish run execution.
335
-
336
- Returns
337
- -------
338
- None
339
303
  """
340
304
  self._context().unset_run()
341
305
 
@@ -348,7 +312,7 @@ class Run(UnversionedEntity):
348
312
  bool
349
313
  True if run is in runnable state, False otherwise.
350
314
  """
351
- 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)
352
316
 
353
317
  def _set_status(self, status: dict) -> None:
354
318
  """
@@ -358,10 +322,6 @@ class Run(UnversionedEntity):
358
322
  ----------
359
323
  status : dict
360
324
  Status to set.
361
-
362
- Returns
363
- -------
364
- None
365
325
  """
366
326
  self.status: RunStatus = entity_factory.build_status(self.kind, **status)
367
327
 
@@ -373,10 +333,6 @@ class Run(UnversionedEntity):
373
333
  ----------
374
334
  state : str
375
335
  State to set.
376
-
377
- Returns
378
- -------
379
- None
380
336
  """
381
337
  self.status.state = state
382
338
 
@@ -388,10 +344,6 @@ class Run(UnversionedEntity):
388
344
  ----------
389
345
  message : str
390
346
  Message to set.
391
-
392
- Returns
393
- -------
394
- None
395
347
  """
396
348
  self.status.message = message
397
349
 
@@ -447,10 +399,6 @@ class Run(UnversionedEntity):
447
399
  def _get_metrics(self) -> None:
448
400
  """
449
401
  Get model metrics from backend.
450
-
451
- Returns
452
- -------
453
- None
454
402
  """
455
403
  self.status.metrics = context_processor.read_metrics(
456
404
  project=self.project,
@@ -478,10 +426,6 @@ class Run(UnversionedEntity):
478
426
  If True, overwrite existing metric.
479
427
  single_value : bool
480
428
  If True, value is a single value.
481
-
482
- Returns
483
- -------
484
- None
485
429
  """
486
430
  value = validate_metric_value(value)
487
431
  self.status.metrics = set_metrics(
@@ -7,9 +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._commons.utils import is_valid_key
11
- from digitalhub.entities._processors.context import context_processor
12
- from digitalhub.utils.exceptions import EntityError
10
+ from digitalhub.entities._processors.processors import context_processor
13
11
 
14
12
  if typing.TYPE_CHECKING:
15
13
  from digitalhub.entities.run._base.entity import Run
@@ -72,7 +70,6 @@ def new_run(
72
70
  def get_run(
73
71
  identifier: str,
74
72
  project: str | None = None,
75
- **kwargs,
76
73
  ) -> Run:
77
74
  """
78
75
  Get object from backend.
@@ -83,8 +80,6 @@ def get_run(
83
80
  Entity key (store://...) or entity ID.
84
81
  project : str
85
82
  Project name.
86
- **kwargs : dict
87
- Parameters to pass to the API call.
88
83
 
89
84
  Returns
90
85
  -------
@@ -94,23 +89,33 @@ def get_run(
94
89
  Examples
95
90
  --------
96
91
  Using entity key:
97
- >>> obj = get_run(
98
- ... "store://my-run-key"
99
- ... )
92
+ >>> obj = get_run("store://my-run-key")
100
93
 
101
94
  Using entity ID:
102
95
  >>> obj = get_run("my-run-id"
103
96
  >>> project="my-project")
104
97
  """
105
98
  return context_processor.read_unversioned_entity(
106
- identifier,
99
+ identifier=identifier,
107
100
  entity_type=ENTITY_TYPE,
108
101
  project=project,
109
- **kwargs,
110
102
  )
111
103
 
112
104
 
113
- 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]:
114
119
  """
115
120
  List all latest version objects from backend.
116
121
 
@@ -118,25 +123,52 @@ def list_runs(project: str, **kwargs) -> list[Run]:
118
123
  ----------
119
124
  project : str
120
125
  Project name.
121
- **kwargs : dict
122
- 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.
123
148
 
124
149
  Returns
125
150
  -------
126
- list[Run]
151
+ list[Model]
127
152
  List of object instances.
128
153
 
129
154
  Examples
130
155
  --------
131
- >>> objs = list_runs(
132
- ... project="my-project"
133
- ... )
156
+ >>> objs = list_runs(project="my-project")
134
157
  """
135
- # TODO more examples: search by function, latest for task and function
136
158
  return context_processor.list_context_entities(
137
159
  project=project,
138
160
  entity_type=ENTITY_TYPE,
139
- **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,
140
172
  )
141
173
 
142
174
 
@@ -167,9 +199,7 @@ def import_run(
167
199
 
168
200
  Example
169
201
  -------
170
- >>> obj = import_run(
171
- ... "my-run.yaml"
172
- ... )
202
+ >>> obj = import_run("my-run.yaml")
173
203
  """
174
204
  return context_processor.import_context_entity(
175
205
  file,
@@ -195,9 +225,7 @@ def load_run(file: str) -> Run:
195
225
 
196
226
  Examples
197
227
  --------
198
- >>> obj = load_run(
199
- ... "my-run.yaml"
200
- ... )
228
+ >>> obj = load_run("my-run.yaml")
201
229
  """
202
230
  return context_processor.load_context_entity(file)
203
231
 
@@ -218,9 +246,7 @@ def update_run(entity: Run) -> Run:
218
246
 
219
247
  Examples
220
248
  --------
221
- >>> obj = update_run(
222
- ... obj
223
- ... )
249
+ >>> obj = update_run(obj)
224
250
  """
225
251
  return context_processor.update_context_entity(
226
252
  project=entity.project,
@@ -233,7 +259,7 @@ def update_run(entity: Run) -> Run:
233
259
  def delete_run(
234
260
  identifier: str,
235
261
  project: str | None = None,
236
- **kwargs,
262
+ entity_id: str | None = None,
237
263
  ) -> dict:
238
264
  """
239
265
  Delete object from backend.
@@ -241,11 +267,11 @@ def delete_run(
241
267
  Parameters
242
268
  ----------
243
269
  identifier : str
244
- Entity key (store://...) or entity ID.
270
+ Entity key (store://...) or entity name.
245
271
  project : str
246
272
  Project name.
247
- **kwargs : dict
248
- Parameters to pass to the API call.
273
+ entity_id : str
274
+ Entity ID.
249
275
 
250
276
  Returns
251
277
  -------
@@ -254,20 +280,15 @@ def delete_run(
254
280
 
255
281
  Examples
256
282
  --------
257
- >>> obj = delete_run(
258
- ... "store://my-run-key"
259
- ... )
283
+ >>> obj = delete_run("store://my-run-key")
260
284
  >>> obj = delete_run(
261
285
  ... "my-run-id",
262
286
  ... project="my-project",
263
287
  ... )
264
288
  """
265
- if not is_valid_key(identifier) and project is None:
266
- raise EntityError("Specify entity key or entity ID combined with project")
267
289
  return context_processor.delete_context_entity(
268
290
  identifier=identifier,
269
291
  entity_type=ENTITY_TYPE,
270
292
  project=project,
271
- entity_id=identifier,
272
- **kwargs,
293
+ entity_id=entity_id,
273
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)