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
@@ -8,7 +8,7 @@ import typing
8
8
  from typing import Any
9
9
 
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
  from digitalhub.entities.dataitem.utils import clean_tmp_path, eval_data, eval_source, post_process, process_kwargs
13
13
  from digitalhub.utils.types import SourcesOrListOfSources
14
14
 
@@ -161,7 +161,6 @@ def get_dataitem(
161
161
  identifier: str,
162
162
  project: str | None = None,
163
163
  entity_id: str | None = None,
164
- **kwargs,
165
164
  ) -> Dataitem:
166
165
  """
167
166
  Get object from backend.
@@ -174,8 +173,6 @@ def get_dataitem(
174
173
  Project name.
175
174
  entity_id : str
176
175
  Entity ID.
177
- **kwargs : dict
178
- Parameters to pass to the API call.
179
176
 
180
177
  Returns
181
178
  -------
@@ -185,9 +182,7 @@ def get_dataitem(
185
182
  Examples
186
183
  --------
187
184
  Using entity key:
188
- >>> obj = get_dataitem(
189
- ... "store://my-dataitem-key"
190
- ... )
185
+ >>> obj = get_dataitem("store://my-dataitem-key")
191
186
 
192
187
  Using entity name:
193
188
  >>> obj = get_dataitem("my-dataitem-name"
@@ -199,14 +194,12 @@ def get_dataitem(
199
194
  entity_type=ENTITY_TYPE,
200
195
  project=project,
201
196
  entity_id=entity_id,
202
- **kwargs,
203
197
  )
204
198
 
205
199
 
206
200
  def get_dataitem_versions(
207
201
  identifier: str,
208
202
  project: str | None = None,
209
- **kwargs,
210
203
  ) -> list[Dataitem]:
211
204
  """
212
205
  Get object versions from backend.
@@ -217,8 +210,6 @@ def get_dataitem_versions(
217
210
  Entity key (store://...) or entity name.
218
211
  project : str
219
212
  Project name.
220
- **kwargs : dict
221
- Parameters to pass to the API call.
222
213
 
223
214
  Returns
224
215
  -------
@@ -228,9 +219,7 @@ def get_dataitem_versions(
228
219
  Examples
229
220
  --------
230
221
  Using entity key:
231
- >>> objs = get_dataitem_versions(
232
- ... "store://my-dataitem-key"
233
- ... )
222
+ >>> objs = get_dataitem_versions("store://my-dataitem-key")
234
223
 
235
224
  Using entity name:
236
225
  >>> objs = get_dataitem_versions("my-dataitem-name",
@@ -240,11 +229,20 @@ def get_dataitem_versions(
240
229
  identifier=identifier,
241
230
  entity_type=ENTITY_TYPE,
242
231
  project=project,
243
- **kwargs,
244
232
  )
245
233
 
246
234
 
247
- def list_dataitems(project: str, **kwargs) -> list[Dataitem]:
235
+ def list_dataitems(
236
+ project: str,
237
+ q: str | None = None,
238
+ name: str | None = None,
239
+ kind: str | None = None,
240
+ user: str | None = None,
241
+ state: str | None = None,
242
+ created: str | None = None,
243
+ updated: str | None = None,
244
+ version: str | None = None,
245
+ ) -> list[Dataitem]:
248
246
  """
249
247
  List all latest version objects from backend.
250
248
 
@@ -252,8 +250,22 @@ def list_dataitems(project: str, **kwargs) -> list[Dataitem]:
252
250
  ----------
253
251
  project : str
254
252
  Project name.
255
- **kwargs : dict
256
- Parameters to pass to the API call.
253
+ q : str
254
+ Query string to filter objects.
255
+ name : str
256
+ Object name.
257
+ kind : str
258
+ Kind of the object.
259
+ user : str
260
+ User that created the object.
261
+ state : str
262
+ Object state.
263
+ created : str
264
+ Creation date filter.
265
+ updated : str
266
+ Update date filter.
267
+ version : str
268
+ Object version, default is latest.
257
269
 
258
270
  Returns
259
271
  -------
@@ -262,14 +274,19 @@ def list_dataitems(project: str, **kwargs) -> list[Dataitem]:
262
274
 
263
275
  Examples
264
276
  --------
265
- >>> objs = list_dataitems(
266
- ... project="my-project"
267
- ... )
277
+ >>> objs = list_dataitems(project="my-project")
268
278
  """
269
279
  return context_processor.list_context_entities(
270
280
  project=project,
271
281
  entity_type=ENTITY_TYPE,
272
- **kwargs,
282
+ q=q,
283
+ name=name,
284
+ kind=kind,
285
+ user=user,
286
+ state=state,
287
+ created=created,
288
+ updated=updated,
289
+ version=version,
273
290
  )
274
291
 
275
292
 
@@ -300,9 +317,7 @@ def import_dataitem(
300
317
 
301
318
  Examples
302
319
  --------
303
- >>> obj = import_dataitem(
304
- ... "my-dataitem.yaml"
305
- ... )
320
+ >>> obj = import_dataitem("my-dataitem.yaml")
306
321
  """
307
322
  return context_processor.import_context_entity(
308
323
  file,
@@ -328,9 +343,7 @@ def load_dataitem(file: str) -> Dataitem:
328
343
 
329
344
  Examples
330
345
  --------
331
- >>> obj = load_dataitem(
332
- ... "my-dataitem.yaml"
333
- ... )
346
+ >>> obj = load_dataitem("my-dataitem.yaml")
334
347
  """
335
348
  return context_processor.load_context_entity(file)
336
349
 
@@ -351,11 +364,7 @@ def update_dataitem(entity: Dataitem) -> Dataitem:
351
364
 
352
365
  Examples
353
366
  --------
354
- >>> obj = (
355
- ... update_dataitem(
356
- ... obj
357
- ... )
358
- ... )
367
+ >>> obj = update_dataitem(obj)
359
368
  """
360
369
  return context_processor.update_context_entity(
361
370
  project=entity.project,
@@ -385,7 +394,8 @@ def delete_dataitem(
385
394
  entity_id : str
386
395
  Entity ID.
387
396
  delete_all_versions : bool
388
- Delete all versions of the named entity. If True, use entity name instead of entity key as identifier.
397
+ Delete all versions of the named entity.
398
+ If True, use entity name instead of entity key as identifier.
389
399
  cascade : bool
390
400
  Cascade delete.
391
401
  **kwargs : dict
@@ -399,9 +409,7 @@ def delete_dataitem(
399
409
  Examples
400
410
  --------
401
411
  If delete_all_versions is False:
402
- >>> obj = delete_dataitem(
403
- ... "store://my-dataitem-key"
404
- ... )
412
+ >>> obj = delete_dataitem("store://my-dataitem-key")
405
413
 
406
414
  Otherwise:
407
415
  >>> obj = delete_dataitem("my-dataitem-name",
@@ -7,6 +7,7 @@ from __future__ import annotations
7
7
  import typing
8
8
  from typing import Any
9
9
 
10
+ from digitalhub.entities._base.material.utils import refresh_decorator
10
11
  from digitalhub.entities.dataitem._base.entity import Dataitem
11
12
  from digitalhub.stores.data.api import get_store
12
13
  from digitalhub.utils.uri_utils import has_sql_scheme
@@ -63,6 +64,7 @@ class DataitemTable(Dataitem):
63
64
  self._query = query
64
65
  return self
65
66
 
67
+ @refresh_decorator
66
68
  def as_df(
67
69
  self,
68
70
  file_format: str | None = None,
@@ -105,6 +107,7 @@ class DataitemTable(Dataitem):
105
107
  **kwargs,
106
108
  )
107
109
 
110
+ @refresh_decorator
108
111
  def write_df(
109
112
  self,
110
113
  df: Any,
@@ -139,12 +142,8 @@ class DataitemTable(Dataitem):
139
142
  >>> import digitalhub as dh
140
143
  >>> import pandas as pd
141
144
  >>>
142
- >>> p = dh.get_project(
143
- ... "my_project"
144
- ... )
145
- >>> df = pd.read_df(
146
- ... "data/my_data.csv"
147
- ... )
145
+ >>> p = dh.get_project("my_project")
146
+ >>> df = pd.read_df("data/my_data.csv")
148
147
  >>> di = p.new_dataitem(
149
148
  ... name="my_dataitem",
150
149
  ... kind="table",
@@ -7,7 +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
10
+ from digitalhub.entities._processors.processors import context_processor
11
11
 
12
12
  if typing.TYPE_CHECKING:
13
13
  from digitalhub.entities.function._base.entity import Function
@@ -76,7 +76,6 @@ def get_function(
76
76
  identifier: str,
77
77
  project: str | None = None,
78
78
  entity_id: str | None = None,
79
- **kwargs,
80
79
  ) -> Function:
81
80
  """
82
81
  Get object from backend.
@@ -89,8 +88,6 @@ def get_function(
89
88
  Project name.
90
89
  entity_id : str
91
90
  Entity ID.
92
- **kwargs : dict
93
- Parameters to pass to the API call.
94
91
 
95
92
  Returns
96
93
  -------
@@ -100,9 +97,7 @@ def get_function(
100
97
  Examples
101
98
  --------
102
99
  Using entity key:
103
- >>> obj = get_function(
104
- ... "store://my-function-key"
105
- ... )
100
+ >>> obj = get_function("store://my-function-key")
106
101
 
107
102
  Using entity name:
108
103
  >>> obj = get_function("my-function-name"
@@ -110,18 +105,16 @@ def get_function(
110
105
  >>> entity_id="my-function-id")
111
106
  """
112
107
  return context_processor.read_context_entity(
113
- identifier,
108
+ identifier=identifier,
114
109
  entity_type=ENTITY_TYPE,
115
110
  project=project,
116
111
  entity_id=entity_id,
117
- **kwargs,
118
112
  )
119
113
 
120
114
 
121
115
  def get_function_versions(
122
116
  identifier: str,
123
117
  project: str | None = None,
124
- **kwargs,
125
118
  ) -> list[Function]:
126
119
  """
127
120
  Get object versions from backend.
@@ -132,8 +125,6 @@ def get_function_versions(
132
125
  Entity key (store://...) or entity name.
133
126
  project : str
134
127
  Project name.
135
- **kwargs : dict
136
- Parameters to pass to the API call.
137
128
 
138
129
  Returns
139
130
  -------
@@ -143,23 +134,30 @@ def get_function_versions(
143
134
  Examples
144
135
  --------
145
136
  Using entity key:
146
- >>> obj = get_function_versions(
147
- ... "store://my-function-key"
148
- ... )
137
+ >>> obj = get_function_versions("store://my-function-key")
149
138
 
150
139
  Using entity name:
151
140
  >>> obj = get_function_versions("my-function-name"
152
141
  >>> project="my-project")
153
142
  """
154
143
  return context_processor.read_context_entity_versions(
155
- identifier,
144
+ identifier=identifier,
156
145
  entity_type=ENTITY_TYPE,
157
146
  project=project,
158
- **kwargs,
159
147
  )
160
148
 
161
149
 
162
- def list_functions(project: str, **kwargs) -> list[Function]:
150
+ def list_functions(
151
+ project: str,
152
+ q: str | None = None,
153
+ name: str | None = None,
154
+ kind: str | None = None,
155
+ user: str | None = None,
156
+ state: str | None = None,
157
+ created: str | None = None,
158
+ updated: str | None = None,
159
+ version: str | None = None,
160
+ ) -> list[Function]:
163
161
  """
164
162
  List all latest version objects from backend.
165
163
 
@@ -167,8 +165,22 @@ def list_functions(project: str, **kwargs) -> list[Function]:
167
165
  ----------
168
166
  project : str
169
167
  Project name.
170
- **kwargs : dict
171
- Parameters to pass to the API call.
168
+ q : str
169
+ Query string to filter objects.
170
+ name : str
171
+ Object name.
172
+ kind : str
173
+ Kind of the object.
174
+ user : str
175
+ User that created the object.
176
+ state : str
177
+ Object state.
178
+ created : str
179
+ Creation date filter.
180
+ updated : str
181
+ Update date filter.
182
+ version : str
183
+ Object version, default is latest.
172
184
 
173
185
  Returns
174
186
  -------
@@ -177,14 +189,19 @@ def list_functions(project: str, **kwargs) -> list[Function]:
177
189
 
178
190
  Examples
179
191
  --------
180
- >>> objs = list_functions(
181
- ... project="my-project"
182
- ... )
192
+ >>> objs = list_functions(project="my-project")
183
193
  """
184
194
  return context_processor.list_context_entities(
185
195
  project=project,
186
196
  entity_type=ENTITY_TYPE,
187
- **kwargs,
197
+ q=q,
198
+ name=name,
199
+ kind=kind,
200
+ user=user,
201
+ state=state,
202
+ created=created,
203
+ updated=updated,
204
+ version=version,
188
205
  )
189
206
 
190
207
 
@@ -215,9 +232,7 @@ def import_function(
215
232
 
216
233
  Examples
217
234
  --------
218
- >>> obj = import_function(
219
- ... "my-function.yaml"
220
- ... )
235
+ >>> obj = import_function("my-function.yaml")
221
236
  """
222
237
  return context_processor.import_executable_entity(file, key, reset_id, context)
223
238
 
@@ -238,9 +253,7 @@ def load_function(file: str) -> Function:
238
253
 
239
254
  Examples
240
255
  --------
241
- >>> obj = load_function(
242
- ... "my-function.yaml"
243
- ... )
256
+ >>> obj = load_function("my-function.yaml")
244
257
  """
245
258
  return context_processor.load_executable_entity(file)
246
259
 
@@ -261,11 +274,7 @@ def update_function(entity: Function) -> Function:
261
274
 
262
275
  Examples
263
276
  --------
264
- >>> obj = (
265
- ... update_function(
266
- ... obj
267
- ... )
268
- ... )
277
+ >>> obj = update_function(obj)
269
278
  """
270
279
  return context_processor.update_context_entity(
271
280
  project=entity.project,
@@ -281,7 +290,6 @@ def delete_function(
281
290
  entity_id: str | None = None,
282
291
  delete_all_versions: bool = False,
283
292
  cascade: bool = True,
284
- **kwargs,
285
293
  ) -> dict:
286
294
  """
287
295
  Delete object from backend.
@@ -295,11 +303,10 @@ def delete_function(
295
303
  entity_id : str
296
304
  Entity ID.
297
305
  delete_all_versions : bool
298
- Delete all versions of the named entity. If True, use entity name instead of entity key as identifier.
306
+ Delete all versions of the named entity.
307
+ If True, use entity name instead of entity key as identifier.
299
308
  cascade : bool
300
309
  Cascade delete.
301
- **kwargs : dict
302
- Parameters to pass to the API call.
303
310
 
304
311
  Returns
305
312
  -------
@@ -309,9 +316,7 @@ def delete_function(
309
316
  Examples
310
317
  --------
311
318
  If delete_all_versions is False:
312
- >>> obj = delete_function(
313
- ... "store://my-function-key"
314
- ... )
319
+ >>> obj = delete_function("store://my-function-key")
315
320
 
316
321
  Otherwise:
317
322
  >>> obj = delete_function("function-name",
@@ -325,5 +330,4 @@ def delete_function(
325
330
  entity_id=entity_id,
326
331
  delete_all_versions=delete_all_versions,
327
332
  cascade=cascade,
328
- **kwargs,
329
333
  )
@@ -9,7 +9,7 @@ import typing
9
9
  from digitalhub.entities._base.material.entity import MaterialEntity
10
10
  from digitalhub.entities._commons.enums import EntityTypes
11
11
  from digitalhub.entities._commons.metrics import MetricType, set_metrics, validate_metric_value
12
- from digitalhub.entities._processors.context import context_processor
12
+ from digitalhub.entities._processors.processors import context_processor
13
13
 
14
14
  if typing.TYPE_CHECKING:
15
15
  from digitalhub.entities._base.entity.metadata import Metadata
@@ -81,21 +81,13 @@ class Model(MaterialEntity):
81
81
  single_value : bool
82
82
  If True, value is a single value.
83
83
 
84
- Returns
85
- -------
86
- None
87
-
88
84
  Examples
89
85
  --------
90
86
  Log a new value in a list
91
- >>> entity.log_metric(
92
- ... "loss", 0.002
93
- ... )
87
+ >>> entity.log_metric("loss", 0.002)
94
88
 
95
89
  Append a new value in a list
96
- >>> entity.log_metric(
97
- ... "loss", 0.0019
98
- ... )
90
+ >>> entity.log_metric("loss", 0.0019)
99
91
 
100
92
  Log a list of values and append them to existing metric:
101
93
  >>> entity.log_metric(
@@ -139,10 +131,6 @@ class Model(MaterialEntity):
139
131
  overwrite : bool
140
132
  If True, overwrite existing metrics.
141
133
 
142
- Returns
143
- -------
144
- None
145
-
146
134
  Examples
147
135
  --------
148
136
  Log multiple metrics at once
@@ -204,10 +192,6 @@ class Model(MaterialEntity):
204
192
  def _get_metrics(self) -> None:
205
193
  """
206
194
  Get model metrics from backend.
207
-
208
- Returns
209
- -------
210
- None
211
195
  """
212
196
  self.status.metrics = context_processor.read_metrics(
213
197
  project=self.project,
@@ -235,10 +219,6 @@ class Model(MaterialEntity):
235
219
  If True, overwrite existing metric.
236
220
  single_value : bool
237
221
  If True, value is a single value.
238
-
239
- Returns
240
- -------
241
- None
242
222
  """
243
223
  value = validate_metric_value(value)
244
224
  self.status.metrics = set_metrics(