digitalhub 0.13.3__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 +15 -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.3.dist-info → digitalhub-0.14.0.dist-info}/METADATA +3 -2
  103. {digitalhub-0.13.3.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.3.dist-info → digitalhub-0.14.0.dist-info}/WHEEL +0 -0
  115. {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/licenses/AUTHORS +0 -0
  116. {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/licenses/LICENSE +0 -0
@@ -9,7 +9,7 @@ import pkgutil
9
9
  import re
10
10
  from types import ModuleType
11
11
 
12
- from digitalhub.factory.factory import factory
12
+ from digitalhub.factory.enums import FactoryEnum
13
13
 
14
14
 
15
15
  def import_module(package: str) -> ModuleType:
@@ -58,62 +58,11 @@ def list_runtimes() -> list[str]:
58
58
  RuntimeError
59
59
  If an error occurs while scanning for runtime packages.
60
60
  """
61
- pattern = r"digitalhub_runtime_.*"
62
- runtimes: list[str] = []
63
61
  try:
62
+ runtimes: list[str] = []
64
63
  for _, name, _ in pkgutil.iter_modules():
65
- if re.match(pattern, name):
64
+ if re.match(FactoryEnum.RGX_RUNTIMES.value, name):
66
65
  runtimes.append(name)
67
66
  return runtimes
68
67
  except Exception as e:
69
68
  raise RuntimeError("Error listing installed runtimes.") from e
70
-
71
-
72
- def register_runtimes_entities() -> None:
73
- """
74
- Register all runtime builders and their entities into the factory.
75
-
76
- Imports each runtime package and registers its entity and runtime
77
- builders with the global factory instance.
78
-
79
- Returns
80
- -------
81
- None
82
- """
83
- for package in list_runtimes():
84
- module = import_module(package)
85
- entity_builders = getattr(module, "entity_builders")
86
- for entity_builder_tuple in entity_builders:
87
- kind, builder = entity_builder_tuple
88
- factory.add_entity_builder(kind, builder)
89
-
90
- runtime_builders = getattr(module, "runtime_builders")
91
- for runtime_builder_tuple in runtime_builders:
92
- kind, builder = runtime_builder_tuple
93
- factory.add_runtime_builder(kind, builder)
94
-
95
-
96
- def register_entities() -> None:
97
- """
98
- Register core entity builders into the factory.
99
-
100
- Imports the core entities module and registers all entity
101
- builders with the global factory instance.
102
-
103
- Returns
104
- -------
105
- None
106
-
107
- Raises
108
- ------
109
- RuntimeError
110
- If registration of core entities fails.
111
- """
112
- try:
113
- module = import_module("digitalhub.entities.builders")
114
- entities_builders_list = getattr(module, "entity_builders")
115
- for entity_builder_tuple in entities_builders_list:
116
- kind, builder = entity_builder_tuple
117
- factory.add_entity_builder(kind, builder)
118
- except Exception as e:
119
- raise RuntimeError("Error registering entities.") from e
@@ -7,7 +7,7 @@ from __future__ import annotations
7
7
  from abc import abstractmethod
8
8
  from typing import Any, Callable
9
9
 
10
- from digitalhub.factory.factory import factory
10
+ from digitalhub.factory.entity import entity_factory
11
11
  from digitalhub.utils.exceptions import EntityError
12
12
  from digitalhub.utils.logger import LOGGER
13
13
 
@@ -72,7 +72,7 @@ class Runtime:
72
72
  raise RuntimeError(msg)
73
73
 
74
74
  try:
75
- return factory.get_action_from_task_kind(task_kind, task_kind)
75
+ return entity_factory.get_action_from_task_kind(task_kind, task_kind)
76
76
  except EntityError:
77
77
  msg = f"Task {task_kind} not allowed."
78
78
  LOGGER.exception(msg)
@@ -0,0 +1,39 @@
1
+ # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ from __future__ import annotations
6
+
7
+ from enum import Enum
8
+
9
+
10
+ class ApiCategories(Enum):
11
+ """
12
+ API categories.
13
+ """
14
+
15
+ BASE = "base"
16
+ CONTEXT = "context"
17
+
18
+
19
+ class BackendOperations(Enum):
20
+ """
21
+ Backend operations.
22
+ """
23
+
24
+ CREATE = "create"
25
+ READ = "read"
26
+ READ_ALL_VERSIONS = "read_all_versions"
27
+ UPDATE = "update"
28
+ DELETE = "delete"
29
+ DELETE_ALL_VERSIONS = "delete_all_versions"
30
+ LIST = "list"
31
+ LIST_FIRST = "list_first"
32
+ STOP = "stop"
33
+ RESUME = "resume"
34
+ DATA = "data"
35
+ FILES = "files"
36
+ LOGS = "logs"
37
+ SEARCH = "search"
38
+ SHARE = "share"
39
+ METRICS = "metrics"
@@ -6,7 +6,7 @@ from __future__ import annotations
6
6
 
7
7
  from abc import abstractmethod
8
8
 
9
- from digitalhub.entities._commons.enums import ApiCategories
9
+ from digitalhub.stores.client._base.enums import ApiCategories
10
10
 
11
11
 
12
12
  class ClientKeyBuilder:
@@ -74,7 +74,7 @@ class ClientKeyBuilder:
74
74
  The entity kind.
75
75
  entity_name : str
76
76
  The entity name.
77
- entity_id : str, optional
77
+ entity_id : str
78
78
  The entity identifier. If None, key will not include version.
79
79
 
80
80
  Returns
@@ -5,6 +5,7 @@
5
5
  from __future__ import annotations
6
6
 
7
7
  from abc import abstractmethod
8
+ from typing import Any
8
9
 
9
10
 
10
11
  class ClientParametersBuilder:
@@ -32,3 +33,50 @@ class ClientParametersBuilder:
32
33
  dict
33
34
  The formatted parameters for the client call.
34
35
  """
36
+
37
+ @staticmethod
38
+ def _ensure_params(**kwargs) -> dict:
39
+ """
40
+ Initialize parameter dictionary with query parameters structure.
41
+
42
+ Ensures parameter dictionary has 'params' key for HTTP query parameters,
43
+ guaranteeing consistent structure for all parameter building methods.
44
+
45
+ Parameters
46
+ ----------
47
+ **kwargs : dict
48
+ Keyword arguments to format. May be empty or contain various
49
+ parameters for API operations.
50
+
51
+ Returns
52
+ -------
53
+ dict
54
+ Parameters dictionary with guaranteed 'params' key containing
55
+ empty dict if not already present.
56
+ """
57
+ if "params" not in kwargs:
58
+ kwargs["params"] = {}
59
+ return kwargs
60
+
61
+ @staticmethod
62
+ def _add_param(key: str, value: Any | None, **kwargs) -> dict:
63
+ """
64
+ Add a single query parameter to kwargs.
65
+
66
+ Parameters
67
+ ----------
68
+ key : str
69
+ Parameter key.
70
+ value : Any
71
+ Parameter value.
72
+ **kwargs : dict
73
+ Keyword arguments to format. May be empty or contain various
74
+ parameters for API operations.
75
+
76
+ Returns
77
+ -------
78
+ dict
79
+ Parameters dictionary with added key-value pair in 'params'.
80
+ """
81
+ kwargs["params"][key] = value
82
+ return kwargs
@@ -9,10 +9,11 @@ import typing
9
9
  from digitalhub.stores.client.builder import client_builder
10
10
 
11
11
  if typing.TYPE_CHECKING:
12
- from digitalhub.stores.client._base.client import Client
12
+ from digitalhub.stores.client.dhcore.client import ClientDHCore
13
+ from digitalhub.stores.client.local.client import ClientLocal
13
14
 
14
15
 
15
- def get_client(local: bool = False, config: dict | None = None) -> Client:
16
+ def get_client(local: bool = False) -> ClientLocal | ClientDHCore:
16
17
  """
17
18
  Wrapper around ClientBuilder.build.
18
19
 
@@ -22,15 +23,10 @@ def get_client(local: bool = False, config: dict | None = None) -> Client:
22
23
  Whether to create a local client or not. If True, creates a
23
24
  ClientLocal instance that operates in-memory. If False, creates
24
25
  a ClientDHCore instance that communicates with a remote backend.
25
- config : dict, optional
26
- DHCore environment configuration. Only used when local=False.
27
- If None, configuration will be loaded from environment variables
28
- and configuration files.
29
26
 
30
27
  Returns
31
28
  -------
32
- Client
33
- The client instance. Either ClientLocal or ClientDHCore depending
34
- on the local parameter.
29
+ ClientLocal | ClientDHCore
30
+ The client instance.
35
31
  """
36
- return client_builder.build(local, config)
32
+ return client_builder.build(local)
@@ -10,7 +10,7 @@ from digitalhub.stores.client.dhcore.client import ClientDHCore
10
10
  from digitalhub.stores.client.local.client import ClientLocal
11
11
 
12
12
  if typing.TYPE_CHECKING:
13
- from digitalhub.stores.client._base.client import Client
13
+ pass
14
14
 
15
15
 
16
16
  class ClientBuilder:
@@ -27,7 +27,7 @@ class ClientBuilder:
27
27
  self._local = None
28
28
  self._dhcore = None
29
29
 
30
- def build(self, local: bool = False, config: dict | None = None) -> Client:
30
+ def build(self, local: bool = False, config: dict | None = None) -> ClientLocal | ClientDHCore:
31
31
  """
32
32
  Method to create a client instance.
33
33
 
@@ -35,12 +35,12 @@ class ClientBuilder:
35
35
  ----------
36
36
  local : bool, default False
37
37
  Whether to create a local client or not.
38
- config : dict, optional
38
+ config : dict
39
39
  DHCore environment configuration.
40
40
 
41
41
  Returns
42
42
  -------
43
- Client
43
+ ClientLocal | ClientDHCore
44
44
  Returns the client instance.
45
45
  """
46
46
  if local:
@@ -4,8 +4,8 @@
4
4
 
5
5
  from __future__ import annotations
6
6
 
7
- from digitalhub.entities._commons.enums import ApiCategories, BackendOperations
8
7
  from digitalhub.stores.client._base.api_builder import ClientApiBuilder
8
+ from digitalhub.stores.client._base.enums import ApiCategories, BackendOperations
9
9
  from digitalhub.utils.exceptions import BackendError
10
10
 
11
11
  API_BASE = "/api/v1"
@@ -100,6 +100,7 @@ class ClientDHCoreApiBuilder(ClientApiBuilder):
100
100
  if operation in (
101
101
  BackendOperations.CREATE.value,
102
102
  BackendOperations.LIST.value,
103
+ BackendOperations.DELETE_ALL_VERSIONS.value,
103
104
  ):
104
105
  return f"{API_CONTEXT}/{project}/{entity_type}"
105
106
  elif operation in (