digitalhub 0.14.0b1__py3-none-any.whl → 0.14.0b2__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 (37) hide show
  1. digitalhub/entities/_base/executable/entity.py +20 -12
  2. digitalhub/entities/_base/material/entity.py +8 -4
  3. digitalhub/entities/_processors/base.py +8 -8
  4. digitalhub/entities/_processors/context.py +15 -15
  5. digitalhub/entities/_processors/utils.py +2 -2
  6. digitalhub/entities/artifact/crud.py +23 -7
  7. digitalhub/entities/dataitem/crud.py +28 -9
  8. digitalhub/entities/dataitem/table/entity.py +28 -1
  9. digitalhub/entities/dataitem/utils.py +4 -0
  10. digitalhub/entities/function/_base/entity.py +3 -3
  11. digitalhub/entities/function/crud.py +23 -7
  12. digitalhub/entities/model/_base/entity.py +51 -9
  13. digitalhub/entities/model/crud.py +21 -7
  14. digitalhub/entities/project/_base/entity.py +121 -41
  15. digitalhub/entities/project/crud.py +20 -6
  16. digitalhub/entities/run/_base/entity.py +58 -15
  17. digitalhub/entities/run/crud.py +22 -7
  18. digitalhub/entities/secret/crud.py +21 -7
  19. digitalhub/entities/task/_base/entity.py +4 -4
  20. digitalhub/entities/task/crud.py +18 -6
  21. digitalhub/entities/trigger/crud.py +23 -7
  22. digitalhub/entities/workflow/_base/entity.py +3 -3
  23. digitalhub/entities/workflow/crud.py +23 -7
  24. digitalhub/factory/entity.py +283 -0
  25. digitalhub/factory/registry.py +221 -0
  26. digitalhub/factory/runtime.py +44 -0
  27. digitalhub/runtimes/_base.py +2 -2
  28. digitalhub/stores/client/dhcore/client.py +6 -2
  29. digitalhub/stores/credentials/configurator.py +4 -5
  30. digitalhub/stores/data/s3/configurator.py +2 -2
  31. digitalhub/stores/readers/data/pandas/reader.py +9 -3
  32. {digitalhub-0.14.0b1.dist-info → digitalhub-0.14.0b2.dist-info}/METADATA +1 -1
  33. {digitalhub-0.14.0b1.dist-info → digitalhub-0.14.0b2.dist-info}/RECORD +36 -34
  34. digitalhub/factory/factory.py +0 -460
  35. {digitalhub-0.14.0b1.dist-info → digitalhub-0.14.0b2.dist-info}/WHEEL +0 -0
  36. {digitalhub-0.14.0b1.dist-info → digitalhub-0.14.0b2.dist-info}/licenses/AUTHORS +0 -0
  37. {digitalhub-0.14.0b1.dist-info → digitalhub-0.14.0b2.dist-info}/licenses/LICENSE +0 -0
@@ -11,7 +11,8 @@ 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
13
  from digitalhub.entities._processors.context import context_processor
14
- from digitalhub.factory.factory import factory
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
 
@@ -59,7 +60,7 @@ class Run(UnversionedEntity):
59
60
  executable = self._get_executable()
60
61
  task = self._get_task()
61
62
  new_spec = self._get_runtime().build(executable, task, self.to_dict())
62
- self.spec = factory.build_spec(self.kind, **new_spec)
63
+ self.spec = entity_factory.build_spec(self.kind, **new_spec)
63
64
  self._set_state(State.BUILT.value)
64
65
  self.save(update=True)
65
66
 
@@ -191,19 +192,37 @@ class Run(UnversionedEntity):
191
192
  Examples
192
193
  --------
193
194
  Log a new value in a list
194
- >>> entity.log_metric("loss", 0.002)
195
+ >>> entity.log_metric(
196
+ ... "loss", 0.002
197
+ ... )
195
198
 
196
199
  Append a new value in a list
197
- >>> entity.log_metric("loss", 0.0019)
200
+ >>> entity.log_metric(
201
+ ... "loss", 0.0019
202
+ ... )
198
203
 
199
204
  Log a list of values and append them to existing metric:
200
- >>> entity.log_metric("loss", [0.0018, 0.0015])
205
+ >>> entity.log_metric(
206
+ ... "loss",
207
+ ... [
208
+ ... 0.0018,
209
+ ... 0.0015,
210
+ ... ],
211
+ ... )
201
212
 
202
213
  Log a single value (not represented as list):
203
- >>> entity.log_metric("accuracy", 0.9, single_value=True)
214
+ >>> entity.log_metric(
215
+ ... "accuracy",
216
+ ... 0.9,
217
+ ... single_value=True,
218
+ ... )
204
219
 
205
220
  Log a list of values and overwrite existing metric:
206
- >>> entity.log_metric("accuracy", [0.8, 0.9], overwrite=True)
221
+ >>> entity.log_metric(
222
+ ... "accuracy",
223
+ ... [0.8, 0.9],
224
+ ... overwrite=True,
225
+ ... )
207
226
  """
208
227
  self._set_metrics(key, value, overwrite, single_value)
209
228
  context_processor.update_metric(self.project, self.ENTITY_TYPE, self.id, key, self.status.metrics[key])
@@ -231,16 +250,40 @@ class Run(UnversionedEntity):
231
250
  Examples
232
251
  --------
233
252
  Log multiple metrics at once
234
- >>> entity.log_metrics({"loss": 0.002, "accuracy": 0.95})
253
+ >>> entity.log_metrics(
254
+ ... {
255
+ ... "loss": 0.002,
256
+ ... "accuracy": 0.95,
257
+ ... }
258
+ ... )
235
259
 
236
260
  Log metrics with lists and single values
237
- >>> entity.log_metrics({"loss": [0.1, 0.05], "epoch": 10})
261
+ >>> entity.log_metrics(
262
+ ... {
263
+ ... "loss": [
264
+ ... 0.1,
265
+ ... 0.05,
266
+ ... ],
267
+ ... "epoch": 10,
268
+ ... }
269
+ ... )
238
270
 
239
271
  Append to existing metrics (default behavior)
240
- >>> entity.log_metrics({"loss": 0.001, "accuracy": 0.96}) # Appends to existing
272
+ >>> entity.log_metrics(
273
+ ... {
274
+ ... "loss": 0.001,
275
+ ... "accuracy": 0.96,
276
+ ... }
277
+ ... ) # Appends to existing
241
278
 
242
279
  Overwrite existing metrics
243
- >>> entity.log_metrics({"loss": 0.0005, "accuracy": 0.98}, overwrite=True)
280
+ >>> entity.log_metrics(
281
+ ... {
282
+ ... "loss": 0.0005,
283
+ ... "accuracy": 0.98,
284
+ ... },
285
+ ... overwrite=True,
286
+ ... )
244
287
 
245
288
  See also
246
289
  --------
@@ -320,7 +363,7 @@ class Run(UnversionedEntity):
320
363
  -------
321
364
  None
322
365
  """
323
- self.status: RunStatus = factory.build_status(self.kind, **status)
366
+ self.status: RunStatus = entity_factory.build_status(self.kind, **status)
324
367
 
325
368
  def _set_state(self, state: str) -> None:
326
369
  """
@@ -361,7 +404,7 @@ class Run(UnversionedEntity):
361
404
  Runtime
362
405
  Runtime object.
363
406
  """
364
- return factory.build_runtime(self.kind, self.project)
407
+ return runtime_factory.build_runtime(self.kind, self.project)
365
408
 
366
409
  def _get_executable(self) -> dict:
367
410
  """
@@ -373,8 +416,8 @@ class Run(UnversionedEntity):
373
416
  dict
374
417
  Executable (function or workflow) from backend.
375
418
  """
376
- exec_kind = factory.get_executable_kind(self.kind)
377
- exec_type = factory.get_entity_type_from_kind(exec_kind)
419
+ exec_kind = entity_factory.get_executable_kind(self.kind)
420
+ exec_type = entity_factory.get_entity_type_from_kind(exec_kind)
378
421
  string_to_split = getattr(self.spec, exec_type)
379
422
  exec_name, exec_id = string_to_split.split("://")[-1].split("/")[-1].split(":")
380
423
  return context_processor.read_context_entity(
@@ -94,7 +94,9 @@ def get_run(
94
94
  Examples
95
95
  --------
96
96
  Using entity key:
97
- >>> obj = get_run("store://my-run-key")
97
+ >>> obj = get_run(
98
+ ... "store://my-run-key"
99
+ ... )
98
100
 
99
101
  Using entity ID:
100
102
  >>> obj = get_run("my-run-id"
@@ -126,7 +128,9 @@ def list_runs(project: str, **kwargs) -> list[Run]:
126
128
 
127
129
  Examples
128
130
  --------
129
- >>> objs = list_runs(project="my-project")
131
+ >>> objs = list_runs(
132
+ ... project="my-project"
133
+ ... )
130
134
  """
131
135
  # TODO more examples: search by function, latest for task and function
132
136
  return context_processor.list_context_entities(
@@ -163,7 +167,9 @@ def import_run(
163
167
 
164
168
  Example
165
169
  -------
166
- >>> obj = import_run("my-run.yaml")
170
+ >>> obj = import_run(
171
+ ... "my-run.yaml"
172
+ ... )
167
173
  """
168
174
  return context_processor.import_context_entity(
169
175
  file,
@@ -189,7 +195,9 @@ def load_run(file: str) -> Run:
189
195
 
190
196
  Examples
191
197
  --------
192
- >>> obj = load_run("my-run.yaml")
198
+ >>> obj = load_run(
199
+ ... "my-run.yaml"
200
+ ... )
193
201
  """
194
202
  return context_processor.load_context_entity(file)
195
203
 
@@ -210,7 +218,9 @@ def update_run(entity: Run) -> Run:
210
218
 
211
219
  Examples
212
220
  --------
213
- >>> obj = update_run(obj)
221
+ >>> obj = update_run(
222
+ ... obj
223
+ ... )
214
224
  """
215
225
  return context_processor.update_context_entity(
216
226
  project=entity.project,
@@ -244,8 +254,13 @@ def delete_run(
244
254
 
245
255
  Examples
246
256
  --------
247
- >>> obj = delete_run("store://my-run-key")
248
- >>> obj = delete_run("my-run-id", project="my-project")
257
+ >>> obj = delete_run(
258
+ ... "store://my-run-key"
259
+ ... )
260
+ >>> obj = delete_run(
261
+ ... "my-run-id",
262
+ ... project="my-project",
263
+ ... )
249
264
  """
250
265
  if not is_valid_key(identifier) and project is None:
251
266
  raise EntityError("Specify entity key or entity ID combined with project")
@@ -105,7 +105,9 @@ def get_secret(
105
105
  Examples
106
106
  --------
107
107
  Using entity key:
108
- >>> obj = get_secret("store://my-secret-key")
108
+ >>> obj = get_secret(
109
+ ... "store://my-secret-key"
110
+ ... )
109
111
 
110
112
  Using entity name:
111
113
  >>> obj = get_secret("my-secret-name"
@@ -155,7 +157,9 @@ def get_secret_versions(
155
157
  Examples
156
158
  --------
157
159
  Using entity key:
158
- >>> objs = get_secret_versions("store://my-secret-key")
160
+ >>> objs = get_secret_versions(
161
+ ... "store://my-secret-key"
162
+ ... )
159
163
 
160
164
  Using entity name:
161
165
  >>> objs = get_secret_versions("my-secret-name",
@@ -187,7 +191,9 @@ def list_secrets(project: str, **kwargs) -> list[Secret]:
187
191
 
188
192
  Examples
189
193
  --------
190
- >>> objs = list_secrets(project="my-project")
194
+ >>> objs = list_secrets(
195
+ ... project="my-project"
196
+ ... )
191
197
  """
192
198
  return context_processor.list_context_entities(
193
199
  project=project,
@@ -223,7 +229,9 @@ def import_secret(
223
229
 
224
230
  Examples
225
231
  --------
226
- >>> obj = import_secret("my-secret.yaml")
232
+ >>> obj = import_secret(
233
+ ... "my-secret.yaml"
234
+ ... )
227
235
  """
228
236
  return context_processor.import_context_entity(
229
237
  file,
@@ -249,7 +257,9 @@ def load_secret(file: str) -> Secret:
249
257
 
250
258
  Examples
251
259
  --------
252
- >>> obj = load_secret("my-secret.yaml")
260
+ >>> obj = load_secret(
261
+ ... "my-secret.yaml"
262
+ ... )
253
263
  """
254
264
  return context_processor.load_context_entity(file)
255
265
 
@@ -270,7 +280,9 @@ def update_secret(entity: Secret) -> Secret:
270
280
 
271
281
  Examples
272
282
  --------
273
- >>> obj = update_secret(obj)
283
+ >>> obj = update_secret(
284
+ ... obj
285
+ ... )
274
286
  """
275
287
  return context_processor.update_context_entity(
276
288
  project=entity.project,
@@ -311,7 +323,9 @@ def delete_secret(
311
323
  Examples
312
324
  --------
313
325
  If delete_all_versions is False:
314
- >>> obj = delete_secret("store://my-secret-key")
326
+ >>> obj = delete_secret(
327
+ ... "store://my-secret-key"
328
+ ... )
315
329
 
316
330
  Otherwise:
317
331
  >>> obj = delete_secret("my-secret-name"
@@ -9,7 +9,7 @@ import typing
9
9
  from digitalhub.entities._base.unversioned.entity import UnversionedEntity
10
10
  from digitalhub.entities._commons.enums import EntityTypes
11
11
  from digitalhub.entities._processors.context import context_processor
12
- from digitalhub.factory.factory import factory
12
+ from digitalhub.factory.entity import entity_factory
13
13
 
14
14
  if typing.TYPE_CHECKING:
15
15
  from digitalhub.entities._base.entity.metadata import Metadata
@@ -67,8 +67,8 @@ class Task(UnversionedEntity):
67
67
  Run
68
68
  Run object.
69
69
  """
70
- exec_kind = factory.get_executable_kind(self.kind)
71
- exec_type = factory.get_entity_type_from_kind(exec_kind)
70
+ exec_kind = entity_factory.get_executable_kind(self.kind)
71
+ exec_type = entity_factory.get_entity_type_from_kind(exec_kind)
72
72
  kwargs[exec_type] = getattr(self.spec, exec_type)
73
73
  return self.new_run(
74
74
  save=save,
@@ -112,7 +112,7 @@ class Task(UnversionedEntity):
112
112
  """
113
113
  if save:
114
114
  return context_processor.create_context_entity(**kwargs)
115
- return factory.build_entity_from_params(**kwargs)
115
+ return entity_factory.build_entity_from_params(**kwargs)
116
116
 
117
117
  def get_run(self, entity_key: str) -> Run:
118
118
  """
@@ -94,7 +94,9 @@ def get_task(
94
94
  Examples
95
95
  --------
96
96
  Using entity key:
97
- >>> obj = get_task("store://my-task-key")
97
+ >>> obj = get_task(
98
+ ... "store://my-task-key"
99
+ ... )
98
100
 
99
101
  Using entity ID:
100
102
  >>> obj = get_task("my-task-id"
@@ -126,7 +128,9 @@ def list_tasks(project: str, **kwargs) -> list[Task]:
126
128
 
127
129
  Examples
128
130
  --------
129
- >>> objs = list_tasks(project="my-project")
131
+ >>> objs = list_tasks(
132
+ ... project="my-project"
133
+ ... )
130
134
  """
131
135
  return context_processor.list_context_entities(
132
136
  project=project,
@@ -162,7 +166,9 @@ def import_task(
162
166
 
163
167
  Example
164
168
  -------
165
- >>> obj = import_task("my-task.yaml")
169
+ >>> obj = import_task(
170
+ ... "my-task.yaml"
171
+ ... )
166
172
  """
167
173
  return context_processor.import_context_entity(
168
174
  file,
@@ -188,7 +194,9 @@ def load_task(file: str) -> Task:
188
194
 
189
195
  Examples
190
196
  --------
191
- >>> obj = load_task("my-task.yaml")
197
+ >>> obj = load_task(
198
+ ... "my-task.yaml"
199
+ ... )
192
200
  """
193
201
  return context_processor.load_context_entity(file)
194
202
 
@@ -209,7 +217,9 @@ def update_task(entity: Task) -> Task:
209
217
 
210
218
  Examples
211
219
  --------
212
- >>> obj = update_task(obj)
220
+ >>> obj = update_task(
221
+ ... obj
222
+ ... )
213
223
  """
214
224
  return context_processor.update_context_entity(
215
225
  project=entity.project,
@@ -253,7 +263,9 @@ def delete_task(
253
263
  Examples
254
264
  --------
255
265
  If delete_all_versions is False:
256
- >>> obj = delete_task("store://my-task-key")
266
+ >>> obj = delete_task(
267
+ ... "store://my-task-key"
268
+ ... )
257
269
 
258
270
  Otherwise:
259
271
  >>> obj = delete_task("task-name",
@@ -115,7 +115,9 @@ def get_trigger(
115
115
  Examples
116
116
  --------
117
117
  Using entity key:
118
- >>> obj = get_trigger("store://my-trigger-key")
118
+ >>> obj = get_trigger(
119
+ ... "store://my-trigger-key"
120
+ ... )
119
121
 
120
122
  Using entity name:
121
123
  >>> obj = get_trigger("my-trigger-name"
@@ -156,7 +158,9 @@ def get_trigger_versions(
156
158
  Examples
157
159
  --------
158
160
  Using entity key:
159
- >>> objs = get_trigger_versions("store://my-trigger-key")
161
+ >>> objs = get_trigger_versions(
162
+ ... "store://my-trigger-key"
163
+ ... )
160
164
 
161
165
  Using entity name:
162
166
  >>> objs = get_trigger_versions("my-trigger-name",
@@ -188,7 +192,9 @@ def list_triggers(project: str, **kwargs) -> list[Trigger]:
188
192
 
189
193
  Examples
190
194
  --------
191
- >>> objs = list_triggers(project="my-project")
195
+ >>> objs = list_triggers(
196
+ ... project="my-project"
197
+ ... )
192
198
  """
193
199
  return context_processor.list_context_entities(
194
200
  project=project,
@@ -224,7 +230,9 @@ def import_trigger(
224
230
 
225
231
  Examples
226
232
  --------
227
- >>> obj = import_trigger("my-trigger.yaml")
233
+ >>> obj = import_trigger(
234
+ ... "my-trigger.yaml"
235
+ ... )
228
236
  """
229
237
  return context_processor.import_context_entity(
230
238
  file,
@@ -250,7 +258,9 @@ def load_trigger(file: str) -> Trigger:
250
258
 
251
259
  Examples
252
260
  --------
253
- >>> obj = load_trigger("my-trigger.yaml")
261
+ >>> obj = load_trigger(
262
+ ... "my-trigger.yaml"
263
+ ... )
254
264
  """
255
265
  return context_processor.load_context_entity(file)
256
266
 
@@ -271,7 +281,11 @@ def update_trigger(entity: Trigger) -> Trigger:
271
281
 
272
282
  Examples
273
283
  --------
274
- >>> obj = update_trigger(obj)
284
+ >>> obj = (
285
+ ... update_trigger(
286
+ ... obj
287
+ ... )
288
+ ... )
275
289
  """
276
290
  return context_processor.update_context_entity(
277
291
  project=entity.project,
@@ -312,7 +326,9 @@ def delete_trigger(
312
326
  Examples
313
327
  --------
314
328
  If delete_all_versions is False:
315
- >>> obj = delete_trigger("store://my-trigger-key")
329
+ >>> obj = delete_trigger(
330
+ ... "store://my-trigger-key"
331
+ ... )
316
332
 
317
333
  Otherwise:
318
334
  >>> obj = delete_trigger("my-trigger-name"
@@ -8,7 +8,7 @@ import typing
8
8
 
9
9
  from digitalhub.entities._base.executable.entity import ExecutableEntity
10
10
  from digitalhub.entities._commons.enums import EntityTypes, Relationship
11
- from digitalhub.factory.factory import factory
11
+ from digitalhub.factory.entity import entity_factory
12
12
  from digitalhub.utils.exceptions import BackendError
13
13
 
14
14
  if typing.TYPE_CHECKING:
@@ -72,8 +72,8 @@ class Workflow(ExecutableEntity):
72
72
  Run instance.
73
73
  """
74
74
  # Get task and run kind
75
- task_kind = factory.get_task_kind_from_action(self.kind, action)
76
- run_kind = factory.get_run_kind_from_action(self.kind, action)
75
+ task_kind = entity_factory.get_task_kind_from_action(self.kind, action)
76
+ run_kind = entity_factory.get_run_kind_from_action(self.kind, action)
77
77
 
78
78
  # Create or update new task
79
79
  task = self._get_or_create_task(task_kind)
@@ -99,7 +99,9 @@ def get_workflow(
99
99
  Examples
100
100
  --------
101
101
  Using entity key:
102
- >>> obj = get_workflow("store://my-workflow-key")
102
+ >>> obj = get_workflow(
103
+ ... "store://my-workflow-key"
104
+ ... )
103
105
 
104
106
  Using entity name:
105
107
  >>> obj = get_workflow("my-workflow-name"
@@ -140,7 +142,9 @@ def get_workflow_versions(
140
142
  Examples
141
143
  --------
142
144
  Using entity key:
143
- >>> obj = get_workflow_versions("store://my-workflow-key")
145
+ >>> obj = get_workflow_versions(
146
+ ... "store://my-workflow-key"
147
+ ... )
144
148
 
145
149
  Using entity name:
146
150
  >>> obj = get_workflow_versions("my-workflow-name"
@@ -172,7 +176,9 @@ def list_workflows(project: str, **kwargs) -> list[Workflow]:
172
176
 
173
177
  Examples
174
178
  --------
175
- >>> objs = list_workflows(project="my-project")
179
+ >>> objs = list_workflows(
180
+ ... project="my-project"
181
+ ... )
176
182
  """
177
183
  return context_processor.list_context_entities(
178
184
  project=project,
@@ -208,7 +214,9 @@ def import_workflow(
208
214
 
209
215
  Examples
210
216
  --------
211
- >>> obj = import_workflow("my-workflow.yaml")
217
+ >>> obj = import_workflow(
218
+ ... "my-workflow.yaml"
219
+ ... )
212
220
  """
213
221
  return context_processor.import_executable_entity(file, key, reset_id, context)
214
222
 
@@ -229,7 +237,9 @@ def load_workflow(file: str) -> Workflow:
229
237
 
230
238
  Examples
231
239
  --------
232
- >>> obj = load_workflow("my-workflow.yaml")
240
+ >>> obj = load_workflow(
241
+ ... "my-workflow.yaml"
242
+ ... )
233
243
  """
234
244
  return context_processor.load_executable_entity(file)
235
245
 
@@ -250,7 +260,11 @@ def update_workflow(entity: Workflow) -> Workflow:
250
260
 
251
261
  Examples
252
262
  --------
253
- >>> obj = update_workflow(obj)
263
+ >>> obj = (
264
+ ... update_workflow(
265
+ ... obj
266
+ ... )
267
+ ... )
254
268
  """
255
269
  return context_processor.update_context_entity(
256
270
  project=entity.project,
@@ -294,7 +308,9 @@ def delete_workflow(
294
308
  Examples
295
309
  --------
296
310
  If delete_all_versions is False:
297
- >>> obj = delete_workflow("store://my-workflow-key")
311
+ >>> obj = delete_workflow(
312
+ ... "store://my-workflow-key"
313
+ ... )
298
314
 
299
315
  Otherwise:
300
316
  >>> obj = delete_workflow("workflow-name",