digitalhub 0.13.0b4__py3-none-any.whl → 0.14.0b0__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 (61) hide show
  1. digitalhub/__init__.py +3 -8
  2. digitalhub/entities/_base/_base/entity.py +0 -11
  3. digitalhub/entities/_base/entity/builder.py +5 -5
  4. digitalhub/entities/_base/executable/entity.py +1 -1
  5. digitalhub/entities/_base/runtime_entity/builder.py +53 -18
  6. digitalhub/entities/_commons/utils.py +64 -21
  7. digitalhub/entities/_processors/base.py +11 -3
  8. digitalhub/entities/_processors/context.py +71 -22
  9. digitalhub/entities/_processors/utils.py +3 -3
  10. digitalhub/entities/artifact/crud.py +20 -4
  11. digitalhub/entities/artifact/utils.py +1 -1
  12. digitalhub/entities/dataitem/crud.py +20 -4
  13. digitalhub/entities/dataitem/table/entity.py +0 -21
  14. digitalhub/entities/dataitem/utils.py +1 -1
  15. digitalhub/entities/function/_base/entity.py +1 -1
  16. digitalhub/entities/function/crud.py +15 -4
  17. digitalhub/entities/model/_base/entity.py +21 -1
  18. digitalhub/entities/model/crud.py +21 -5
  19. digitalhub/entities/model/utils.py +1 -1
  20. digitalhub/entities/project/_base/entity.py +65 -33
  21. digitalhub/entities/project/crud.py +8 -1
  22. digitalhub/entities/run/_base/entity.py +21 -1
  23. digitalhub/entities/run/crud.py +22 -5
  24. digitalhub/entities/secret/crud.py +22 -5
  25. digitalhub/entities/task/crud.py +22 -5
  26. digitalhub/entities/trigger/crud.py +20 -4
  27. digitalhub/entities/workflow/_base/entity.py +1 -1
  28. digitalhub/entities/workflow/crud.py +15 -4
  29. digitalhub/factory/enums.py +18 -0
  30. digitalhub/factory/factory.py +136 -57
  31. digitalhub/factory/utils.py +3 -54
  32. digitalhub/stores/client/api.py +6 -10
  33. digitalhub/stores/client/builder.py +3 -3
  34. digitalhub/stores/client/dhcore/client.py +104 -162
  35. digitalhub/stores/client/dhcore/configurator.py +92 -289
  36. digitalhub/stores/client/dhcore/enums.py +0 -16
  37. digitalhub/stores/client/dhcore/params_builder.py +41 -83
  38. digitalhub/stores/client/dhcore/utils.py +14 -22
  39. digitalhub/stores/client/local/client.py +77 -45
  40. digitalhub/stores/credentials/ini_module.py +0 -16
  41. digitalhub/stores/data/local/store.py +0 -103
  42. digitalhub/stores/data/s3/configurator.py +60 -6
  43. digitalhub/stores/data/s3/store.py +44 -2
  44. digitalhub/stores/data/sql/store.py +15 -0
  45. digitalhub/utils/file_utils.py +0 -17
  46. digitalhub/utils/generic_utils.py +1 -2
  47. digitalhub/utils/store_utils.py +44 -0
  48. {digitalhub-0.13.0b4.dist-info → digitalhub-0.14.0b0.dist-info}/METADATA +3 -2
  49. {digitalhub-0.13.0b4.dist-info → digitalhub-0.14.0b0.dist-info}/RECORD +58 -59
  50. digitalhub/entities/task/_base/utils.py +0 -22
  51. digitalhub/stores/client/dhcore/models.py +0 -40
  52. digitalhub/stores/data/s3/utils.py +0 -78
  53. /digitalhub/entities/{_base/entity/_constructors → _constructors}/__init__.py +0 -0
  54. /digitalhub/entities/{_base/entity/_constructors → _constructors}/metadata.py +0 -0
  55. /digitalhub/entities/{_base/entity/_constructors → _constructors}/name.py +0 -0
  56. /digitalhub/entities/{_base/entity/_constructors → _constructors}/spec.py +0 -0
  57. /digitalhub/entities/{_base/entity/_constructors → _constructors}/status.py +0 -0
  58. /digitalhub/entities/{_base/entity/_constructors → _constructors}/uuid.py +0 -0
  59. {digitalhub-0.13.0b4.dist-info → digitalhub-0.14.0b0.dist-info}/WHEEL +0 -0
  60. {digitalhub-0.13.0b4.dist-info → digitalhub-0.14.0b0.dist-info}/licenses/AUTHORS +0 -0
  61. {digitalhub-0.13.0b4.dist-info → digitalhub-0.14.0b0.dist-info}/licenses/LICENSE +0 -0
@@ -26,7 +26,7 @@ if typing.TYPE_CHECKING:
26
26
 
27
27
  # API levels that are supported
28
28
  MAX_API_LEVEL = 20
29
- MIN_API_LEVEL = 13
29
+ MIN_API_LEVEL = 11
30
30
  LIB_VERSION = 13
31
31
 
32
32
 
@@ -34,30 +34,17 @@ class ClientDHCore(Client):
34
34
  """
35
35
  DHCore client for remote DigitalHub Core backend communication.
36
36
 
37
- The DHCore client is used to communicate with the DigitalHub Core
38
- backend API via REST. The client supports multiple authentication methods:
39
- - Basic authentication (username/password)
40
- - OAuth2 token authentication with automatic token refresh
41
- - Personal access token exchange
42
-
43
- At initialization, the client attempts to load endpoint and authentication
44
- parameters from environment variables and the .dhcore configuration file.
45
- If authentication or endpoint errors occur during client creation, users
46
- can update the configuration using the `set_dhcore_env` function from
47
- the utils module.
48
-
49
- The client automatically handles:
50
- - API version compatibility checking
51
- - Pagination for list operations
52
- - Token refresh on authentication errors
53
- - Error parsing and exception mapping
54
- - JSON serialization/deserialization
37
+ Provides REST API communication with DigitalHub Core backend supporting
38
+ multiple authentication methods: Basic (username/password), OAuth2 (token
39
+ with refresh), and Personal Access Token exchange. Automatically handles
40
+ API version compatibility, pagination, token refresh, error parsing, and
41
+ JSON serialization. Supports API versions {MIN_API_LEVEL} to {MAX_API_LEVEL}.
55
42
 
56
43
  Parameters
57
44
  ----------
58
45
  config : dict, optional
59
- DHCore environment configuration. If None, configuration will
60
- be loaded from environment variables and configuration files.
46
+ DHCore environment configuration. If None, loads from environment
47
+ variables and configuration files.
61
48
 
62
49
  Attributes
63
50
  ----------
@@ -72,11 +59,6 @@ class ClientDHCore(Client):
72
59
  _configurator : ClientDHCoreConfigurator
73
60
  Manages client configuration and authentication.
74
61
 
75
- Notes
76
- -----
77
- Supported DHCore API versions: {MIN_API_LEVEL} to {MAX_API_LEVEL}
78
- Current library API version: {LIB_VERSION}
79
-
80
62
  Examples
81
63
  --------
82
64
  >>> from digitalhub.stores.client.api import get_client
@@ -86,17 +68,13 @@ class ClientDHCore(Client):
86
68
 
87
69
  def __init__(self, config: dict | None = None) -> None:
88
70
  """
89
- Initialize DHCore client.
90
-
91
- Creates a new DHCore client instance with all necessary components
92
- for communicating with the DigitalHub Core backend. Sets up API
93
- builders, configurators, and error handling.
71
+ Initialize DHCore client with API builders and configurators.
94
72
 
95
73
  Parameters
96
74
  ----------
97
75
  config : dict, optional
98
- DHCore environment configuration. If None, configuration will
99
- be loaded from environment variables and configuration files.
76
+ DHCore environment configuration. If None, loads from environment
77
+ variables and configuration files.
100
78
 
101
79
  Returns
102
80
  -------
@@ -125,26 +103,23 @@ class ClientDHCore(Client):
125
103
 
126
104
  def create_object(self, api: str, obj: Any, **kwargs) -> dict:
127
105
  """
128
- Create an object in DHCore.
106
+ Create an object in DHCore via POST request.
129
107
 
130
- Sends a POST request to the DHCore backend to create a new object.
131
- Automatically sets the appropriate Content-Type header and serializes
132
- the object to JSON format.
108
+ Automatically sets Content-Type header and serializes object to JSON.
133
109
 
134
110
  Parameters
135
111
  ----------
136
112
  api : str
137
- The API endpoint path for creating the object.
113
+ API endpoint path for creating the object.
138
114
  obj : Any
139
- The object to create. Will be serialized to JSON.
115
+ Object to create. Will be serialized to JSON.
140
116
  **kwargs : dict
141
- Additional keyword arguments to pass to the HTTP request,
142
- such as headers, params, etc.
117
+ Additional HTTP request arguments.
143
118
 
144
119
  Returns
145
120
  -------
146
121
  dict
147
- The created object as returned by the backend.
122
+ Created object as returned by the backend.
148
123
 
149
124
  Raises
150
125
  ------
@@ -168,15 +143,14 @@ class ClientDHCore(Client):
168
143
  Parameters
169
144
  ----------
170
145
  api : str
171
- The API endpoint path for reading the object.
146
+ API endpoint path for reading the object.
172
147
  **kwargs : dict
173
- Additional keyword arguments to pass to the HTTP request,
174
- such as headers, params, etc.
148
+ Additional HTTP request arguments.
175
149
 
176
150
  Returns
177
151
  -------
178
152
  dict
179
- The retrieved object as returned by the backend.
153
+ Retrieved object as returned by the backend.
180
154
 
181
155
  Raises
182
156
  ------
@@ -189,26 +163,23 @@ class ClientDHCore(Client):
189
163
 
190
164
  def update_object(self, api: str, obj: Any, **kwargs) -> dict:
191
165
  """
192
- Update an object in DHCore.
166
+ Update an object in DHCore via PUT request.
193
167
 
194
- Sends a PUT request to the DHCore backend to update an existing object.
195
- Automatically sets the appropriate Content-Type header and serializes
196
- the object to JSON format.
168
+ Automatically sets Content-Type header and serializes object to JSON.
197
169
 
198
170
  Parameters
199
171
  ----------
200
172
  api : str
201
- The API endpoint path for updating the object.
173
+ API endpoint path for updating the object.
202
174
  obj : Any
203
- The updated object data. Will be serialized to JSON.
175
+ Updated object data. Will be serialized to JSON.
204
176
  **kwargs : dict
205
- Additional keyword arguments to pass to the HTTP request,
206
- such as headers, params, etc.
177
+ Additional HTTP request arguments.
207
178
 
208
179
  Returns
209
180
  -------
210
181
  dict
211
- The updated object as returned by the backend.
182
+ Updated object as returned by the backend.
212
183
 
213
184
  Raises
214
185
  ------
@@ -227,23 +198,20 @@ class ClientDHCore(Client):
227
198
  """
228
199
  Delete an object from DHCore.
229
200
 
230
- Sends a DELETE request to the DHCore backend to remove an object.
231
- If the backend returns a boolean response, it will be wrapped in
232
- a dictionary with a "deleted" key.
201
+ Sends DELETE request to remove an object. Wraps boolean responses
202
+ in {"deleted": True/False} dictionary.
233
203
 
234
204
  Parameters
235
205
  ----------
236
206
  api : str
237
- The API endpoint path for deleting the object.
207
+ API endpoint path for deleting the object.
238
208
  **kwargs : dict
239
- Additional keyword arguments to pass to the HTTP request,
240
- such as headers, params, cascade options, etc.
209
+ Additional HTTP request arguments.
241
210
 
242
211
  Returns
243
212
  -------
244
213
  dict
245
- The deletion result. Either the backend response or
246
- {"deleted": True/False} if backend returns a boolean.
214
+ Deletion result from backend or {"deleted": bool} wrapper.
247
215
 
248
216
  Raises
249
217
  ------
@@ -259,34 +227,28 @@ class ClientDHCore(Client):
259
227
 
260
228
  def list_objects(self, api: str, **kwargs) -> list[dict]:
261
229
  """
262
- List objects from DHCore.
230
+ List objects from DHCore with automatic pagination.
263
231
 
264
- Sends GET requests to the DHCore backend to retrieve a paginated list
265
- of objects. Automatically handles pagination by making multiple requests
266
- until all objects are retrieved.
232
+ Sends GET requests to retrieve paginated objects, automatically handling
233
+ pagination (starting from page 0) until all objects are retrieved.
267
234
 
268
235
  Parameters
269
236
  ----------
270
237
  api : str
271
- The API endpoint path for listing objects.
238
+ API endpoint path for listing objects.
272
239
  **kwargs : dict
273
- Additional keyword arguments to pass to the HTTP request.
274
- Can include 'params' dict with pagination parameters.
240
+ Additional HTTP request arguments. Can include 'params' dict
241
+ with pagination parameters.
275
242
 
276
243
  Returns
277
244
  -------
278
245
  list[dict]
279
- A list containing all objects from all pages.
246
+ List containing all objects from all pages.
280
247
 
281
248
  Raises
282
249
  ------
283
250
  BackendError
284
251
  If the backend returns an error response.
285
-
286
- Notes
287
- -----
288
- This method automatically handles pagination starting from page 0
289
- and continues until all pages are retrieved.
290
252
  """
291
253
  if "params" not in kwargs:
292
254
  kwargs["params"] = {}
@@ -309,27 +271,27 @@ class ClientDHCore(Client):
309
271
 
310
272
  def list_first_object(self, api: str, **kwargs) -> dict:
311
273
  """
312
- Get the first object from a list in DHCore.
274
+ Get the first object from a DHCore list.
313
275
 
314
- Retrieves the first object from a paginated list by calling
315
- list_objects and returning the first item.
276
+ Retrieves the first object by calling list_objects and returning
277
+ the first item.
316
278
 
317
279
  Parameters
318
280
  ----------
319
281
  api : str
320
- The API endpoint path for listing objects.
282
+ API endpoint path for listing objects.
321
283
  **kwargs : dict
322
- Additional keyword arguments to pass to the HTTP request.
284
+ Additional HTTP request arguments.
323
285
 
324
286
  Returns
325
287
  -------
326
288
  dict
327
- The first object from the list.
289
+ First object from the list.
328
290
 
329
291
  Raises
330
292
  ------
331
293
  BackendError
332
- If no objects are found or if the backend returns an error.
294
+ If no objects found or backend returns an error.
333
295
  """
334
296
  try:
335
297
  return self.list_objects(api, **kwargs)[0]
@@ -338,36 +300,29 @@ class ClientDHCore(Client):
338
300
 
339
301
  def search_objects(self, api: str, **kwargs) -> list[dict]:
340
302
  """
341
- Search objects from DHCore.
303
+ Search objects from DHCore using Solr capabilities.
342
304
 
343
- Performs a search query against the DHCore backend using Solr search
344
- capabilities. Handles pagination and removes search highlights from
345
- the returned objects.
305
+ Performs search query with pagination and removes search highlights.
306
+ Sets default pagination (page=0, size=10) and sorting (metadata.updated DESC)
307
+ if not provided.
346
308
 
347
309
  Parameters
348
310
  ----------
349
311
  api : str
350
- The API endpoint path for searching objects (usually Solr search).
312
+ API endpoint path for searching objects (usually Solr search).
351
313
  **kwargs : dict
352
- Additional keyword arguments to pass to the HTTP request.
353
- Can include search parameters, filters, pagination options, etc.
314
+ Additional HTTP request arguments including search parameters,
315
+ filters, and pagination options.
354
316
 
355
317
  Returns
356
318
  -------
357
319
  list[dict]
358
- A list of objects matching the search criteria, with search
359
- highlights removed.
320
+ List of matching objects with search highlights removed.
360
321
 
361
322
  Raises
362
323
  ------
363
324
  BackendError
364
325
  If the backend returns an error response.
365
-
366
- Notes
367
- -----
368
- This method sets default values for pagination (page=0, size=10)
369
- and sorting (by metadata.updated descending) if not provided.
370
- Search highlights are automatically removed from results.
371
326
  """
372
327
  if "params" not in kwargs:
373
328
  kwargs["params"] = {}
@@ -406,31 +361,30 @@ class ClientDHCore(Client):
406
361
 
407
362
  def _prepare_call(self, call_type: str, api: str, **kwargs) -> dict:
408
363
  """
409
- Prepare a call to the DHCore API.
364
+ Prepare DHCore API call with configuration and authentication.
410
365
 
411
- Handles the preparation of an API call by checking configuration,
412
- building the URL, and adding authentication parameters.
366
+ Checks configuration, builds URL, and adds authentication parameters.
413
367
 
414
368
  Parameters
415
369
  ----------
416
370
  call_type : str
417
- The HTTP method type (GET, POST, PUT, DELETE, etc.).
371
+ HTTP method type (GET, POST, PUT, DELETE, etc.).
418
372
  api : str
419
- The API endpoint path to call.
373
+ API endpoint path to call.
420
374
  **kwargs : dict
421
- Additional keyword arguments to pass to the HTTP request.
375
+ Additional HTTP request arguments.
422
376
 
423
377
  Returns
424
378
  -------
425
379
  dict
426
- The response from the API call.
380
+ Response from the API call.
427
381
 
428
382
  Raises
429
383
  ------
430
384
  ClientError
431
- If the client configuration is invalid.
385
+ If client configuration is invalid.
432
386
  BackendError
433
- If the backend returns an error response.
387
+ If backend returns an error response.
434
388
  """
435
389
  self._configurator.check_config()
436
390
  url = self._build_url(api)
@@ -442,7 +396,8 @@ class ClientDHCore(Client):
442
396
  Build the complete URL for an API call.
443
397
 
444
398
  Combines the configured endpoint with the API path to create
445
- the full URL for the HTTP request.
399
+ the full URL for the HTTP request. Automatically removes leading
400
+ slashes from the API path to ensure proper URL construction.
446
401
 
447
402
  Parameters
448
403
  ----------
@@ -453,56 +408,60 @@ class ClientDHCore(Client):
453
408
  -------
454
409
  str
455
410
  The complete URL for the API call.
411
+ """
412
+
413
+ def _build_url(self, api: str) -> str:
414
+ """
415
+ Build complete URL for API call.
416
+
417
+ Combines configured endpoint with API path, automatically removing
418
+ leading slashes for proper URL construction.
456
419
 
457
- Notes
458
- -----
459
- This method automatically removes leading slashes from the API path
460
- to ensure proper URL construction.
420
+ Parameters
421
+ ----------
422
+ api : str
423
+ API endpoint path. Leading slashes are automatically handled.
424
+
425
+ Returns
426
+ -------
427
+ str
428
+ Complete URL for the API call.
461
429
  """
462
430
  endpoint = self._configurator.get_endpoint()
463
431
  return f"{endpoint}/{api.removeprefix('/')}"
464
432
 
465
433
  def _make_call(self, call_type: str, url: str, refresh: bool = True, **kwargs) -> dict:
466
434
  """
467
- Make a call to the DHCore API.
435
+ Execute HTTP request to DHCore API with automatic handling.
468
436
 
469
- Executes the actual HTTP request to the DHCore backend, handles
470
- API version checking, automatic token refresh on 401 errors,
471
- and error parsing.
437
+ Handles API version checking, token refresh on 401 errors, response parsing,
438
+ and error handling with 60-second timeout.
472
439
 
473
440
  Parameters
474
441
  ----------
475
442
  call_type : str
476
- The HTTP method type (GET, POST, PUT, DELETE, etc.).
443
+ HTTP method type (GET, POST, PUT, DELETE, etc.).
477
444
  url : str
478
- The complete URL to call.
445
+ Complete URL to call.
479
446
  refresh : bool, default True
480
447
  Whether to attempt token refresh on authentication errors.
481
448
  Set to False to prevent infinite recursion during refresh.
482
449
  **kwargs : dict
483
- Additional keyword arguments to pass to the HTTP request.
450
+ Additional HTTP request arguments.
484
451
 
485
452
  Returns
486
453
  -------
487
454
  dict
488
- The parsed response from the backend as a dictionary.
455
+ Parsed response from backend as dictionary.
489
456
 
490
457
  Raises
491
458
  ------
492
459
  ClientError
493
- If the backend API version is not supported.
460
+ If backend API version is not supported.
494
461
  BackendError
495
- If the backend returns an error response or response parsing fails.
462
+ If backend returns error response or response parsing fails.
496
463
  UnauthorizedError
497
- If authentication fails and token refresh is not possible.
498
-
499
- Notes
500
- -----
501
- This method automatically handles:
502
- - API version compatibility checking
503
- - OAuth2 token refresh on 401 errors
504
- - Response parsing and error handling
505
- - 60-second timeout for all requests
464
+ If authentication fails and token refresh not possible.
506
465
  """
507
466
  # Call the API
508
467
  response = request(call_type, url, timeout=60, **kwargs)
@@ -521,16 +480,15 @@ class ClientDHCore(Client):
521
480
 
522
481
  def _check_core_version(self, response: Response) -> None:
523
482
  """
524
- Check DHCore API version compatibility.
483
+ Validate DHCore API version compatibility.
525
484
 
526
- Validates that the DHCore backend API version is compatible with
527
- this client library. Issues warnings if the backend version is
528
- newer than the library version.
485
+ Checks backend API version against supported range and warns if backend
486
+ version is newer than library. Supported: {MIN_API_LEVEL} to {MAX_API_LEVEL}.
529
487
 
530
488
  Parameters
531
489
  ----------
532
490
  response : Response
533
- The HTTP response object containing the X-Api-Level header.
491
+ HTTP response containing X-Api-Level header.
534
492
 
535
493
  Returns
536
494
  -------
@@ -539,12 +497,7 @@ class ClientDHCore(Client):
539
497
  Raises
540
498
  ------
541
499
  ClientError
542
- If the backend API level is not supported by this client.
543
-
544
- Notes
545
- -----
546
- Supported API levels: {MIN_API_LEVEL} to {MAX_API_LEVEL}
547
- Current library version: {LIB_VERSION}
500
+ If backend API level is not supported by this client.
548
501
  """
549
502
  if "X-Api-Level" in response.headers:
550
503
  core_api_level = int(response.headers["X-Api-Level"])
@@ -555,30 +508,25 @@ class ClientDHCore(Client):
555
508
 
556
509
  def _dictify_response(self, response: Response) -> dict:
557
510
  """
558
- Parse HTTP response to dictionary.
511
+ Parse HTTP response body to dictionary.
559
512
 
560
- Converts the HTTP response body from JSON to a Python dictionary.
561
- Handles empty responses gracefully.
513
+ Converts JSON response to Python dictionary, treating empty responses
514
+ as valid and returning empty dict.
562
515
 
563
516
  Parameters
564
517
  ----------
565
518
  response : Response
566
- The HTTP response object to parse.
519
+ HTTP response object to parse.
567
520
 
568
521
  Returns
569
522
  -------
570
523
  dict
571
- The parsed response body as a dictionary. Returns empty dict
572
- if response body is empty.
524
+ Parsed response body as dictionary, or empty dict if body is empty.
573
525
 
574
526
  Raises
575
527
  ------
576
528
  BackendError
577
- If the response cannot be parsed as JSON.
578
-
579
- Notes
580
- -----
581
- Empty response bodies are treated as valid and return an empty dict.
529
+ If response cannot be parsed as JSON.
582
530
  """
583
531
  try:
584
532
  return response.json()
@@ -596,18 +544,12 @@ class ClientDHCore(Client):
596
544
  """
597
545
  Check if this client operates locally.
598
546
 
599
- Returns a flag indicating whether this client instance operates
600
- on local data or communicates with a remote backend.
547
+ Used to distinguish between ClientDHCore (remote) and ClientLocal
548
+ implementations.
601
549
 
602
550
  Returns
603
551
  -------
604
552
  bool
605
- False, indicating this client communicates with a remote
606
- DHCore backend, not local storage.
607
-
608
- Notes
609
- -----
610
- This method is used to distinguish between ClientDHCore (returns False)
611
- and ClientLocal (returns True) implementations.
553
+ False, indicating this client communicates with remote DHCore backend.
612
554
  """
613
555
  return False