digitalhub 0.8.0__py3-none-any.whl → 0.8.0b1__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 (248) hide show
  1. digitalhub/__init__.py +4 -5
  2. digitalhub/client/builder.py +58 -3
  3. digitalhub/client/{dhcore/client.py → objects/dhcore.py} +60 -48
  4. digitalhub/client/{local/client.py → objects/local.py} +2 -2
  5. digitalhub/context/builder.py +85 -1
  6. digitalhub/context/context.py +1 -1
  7. digitalhub/datastores/builder.py +37 -13
  8. digitalhub/datastores/{_base/datastore.py → objects/base.py} +3 -3
  9. digitalhub/datastores/{local/datastore.py → objects/local.py} +2 -10
  10. digitalhub/datastores/{remote/datastore.py → objects/remote.py} +1 -9
  11. digitalhub/datastores/{s3/datastore.py → objects/s3.py} +2 -10
  12. digitalhub/datastores/{sql/datastore.py → objects/sql.py} +2 -10
  13. digitalhub/entities/_base/{_base/entity.py → base.py} +1 -1
  14. digitalhub/entities/_base/crud.py +389 -247
  15. digitalhub/entities/_base/entity/{entity.py → base.py} +34 -8
  16. digitalhub/entities/_base/{context/entity.py → entity/context.py} +6 -6
  17. digitalhub/entities/_base/{executable/entity.py → entity/executable.py} +36 -61
  18. digitalhub/entities/_base/{material/entity.py → entity/material.py} +6 -6
  19. digitalhub/entities/_base/entity/unversioned.py +87 -0
  20. digitalhub/entities/_base/entity/versioned.py +94 -0
  21. digitalhub/entities/_base/{entity/metadata.py → metadata.py} +2 -2
  22. digitalhub/entities/_base/{entity/spec.py → spec/base.py} +11 -11
  23. digitalhub/entities/_base/{material/spec.py → spec/material.py} +3 -3
  24. digitalhub/entities/_base/{entity/status.py → status/base.py} +3 -14
  25. digitalhub/entities/_base/{material/status.py → status/material.py} +1 -1
  26. digitalhub/entities/_builders/metadata.py +60 -0
  27. digitalhub/entities/_builders/spec.py +43 -0
  28. digitalhub/entities/_builders/status.py +62 -0
  29. digitalhub/entities/{_base/entity/_constructors → _builders}/uuid.py +11 -4
  30. digitalhub/entities/artifact/builder.py +133 -0
  31. digitalhub/entities/artifact/crud.py +48 -22
  32. digitalhub/entities/artifact/{_base/entity.py → entity/_base.py} +5 -5
  33. digitalhub/entities/artifact/entity/artifact.py +9 -0
  34. digitalhub/entities/artifact/{artifact/spec.py → spec.py} +16 -4
  35. digitalhub/entities/artifact/{artifact/status.py → status.py} +1 -1
  36. digitalhub/entities/dataitem/builder.py +144 -0
  37. digitalhub/entities/dataitem/crud.py +52 -29
  38. digitalhub/entities/dataitem/{_base/entity.py → entity/_base.py} +5 -5
  39. digitalhub/entities/dataitem/entity/dataitem.py +9 -0
  40. digitalhub/entities/dataitem/entity/iceberg.py +7 -0
  41. digitalhub/entities/dataitem/{table/entity.py → entity/table.py} +4 -25
  42. digitalhub/entities/dataitem/spec.py +61 -0
  43. digitalhub/entities/dataitem/status.py +38 -0
  44. digitalhub/entities/function/builder.py +86 -0
  45. digitalhub/entities/function/crud.py +43 -17
  46. digitalhub/entities/function/{_base/entity.py → entity.py} +12 -9
  47. digitalhub/entities/function/{_base/models.py → models.py} +1 -1
  48. digitalhub/entities/function/spec.py +81 -0
  49. digitalhub/entities/function/status.py +9 -0
  50. digitalhub/entities/model/builder.py +152 -0
  51. digitalhub/entities/model/crud.py +48 -21
  52. digitalhub/entities/model/{_base/entity.py → entity/_base.py} +5 -5
  53. digitalhub/entities/model/entity/huggingface.py +9 -0
  54. digitalhub/entities/model/{mlflow/utils.py → entity/mlflow.py} +10 -1
  55. digitalhub/entities/model/entity/model.py +9 -0
  56. digitalhub/entities/model/entity/sklearn.py +9 -0
  57. digitalhub/entities/model/spec.py +146 -0
  58. digitalhub/entities/model/status.py +33 -0
  59. digitalhub/entities/project/builder.py +82 -0
  60. digitalhub/entities/project/crud.py +12 -19
  61. digitalhub/entities/project/{_base/entity.py → entity.py} +102 -120
  62. digitalhub/entities/project/{_base/spec.py → spec.py} +4 -4
  63. digitalhub/entities/project/status.py +9 -0
  64. digitalhub/entities/registries.py +48 -0
  65. digitalhub/entities/run/builder.py +77 -0
  66. digitalhub/entities/run/crud.py +33 -20
  67. digitalhub/entities/run/{_base/entity.py → entity.py} +189 -35
  68. digitalhub/entities/run/spec.py +153 -0
  69. digitalhub/entities/run/status.py +114 -0
  70. digitalhub/entities/secret/builder.py +93 -0
  71. digitalhub/entities/secret/crud.py +31 -27
  72. digitalhub/entities/secret/{_base/entity.py → entity.py} +7 -8
  73. digitalhub/entities/secret/{_base/spec.py → spec.py} +4 -4
  74. digitalhub/entities/secret/status.py +9 -0
  75. digitalhub/entities/task/builder.py +74 -0
  76. digitalhub/entities/task/crud.py +33 -20
  77. digitalhub/entities/task/{_base/entity.py → entity.py} +8 -9
  78. digitalhub/entities/task/{_base/models.py → models.py} +0 -9
  79. digitalhub/entities/task/{_base/spec.py → spec.py} +7 -9
  80. digitalhub/entities/task/status.py +9 -0
  81. digitalhub/entities/{utils/utils.py → utils.py} +2 -20
  82. digitalhub/entities/workflow/builder.py +91 -0
  83. digitalhub/entities/workflow/crud.py +43 -17
  84. digitalhub/entities/workflow/{_base/entity.py → entity.py} +12 -9
  85. digitalhub/entities/workflow/spec.py +15 -0
  86. digitalhub/entities/workflow/status.py +9 -0
  87. digitalhub/readers/builder.py +54 -0
  88. digitalhub/readers/{pandas/reader.py → objects/pandas.py} +1 -1
  89. digitalhub/readers/registry.py +15 -0
  90. digitalhub/registry/models.py +87 -0
  91. digitalhub/registry/registry.py +74 -0
  92. digitalhub/registry/utils.py +150 -0
  93. digitalhub/runtimes/{_base.py → base.py} +65 -3
  94. digitalhub/runtimes/builder.py +40 -19
  95. digitalhub/runtimes/kind_registry.py +170 -0
  96. digitalhub/stores/builder.py +52 -6
  97. digitalhub/stores/{local/store.py → objects/local.py} +1 -1
  98. digitalhub/stores/{remote/store.py → objects/remote.py} +1 -1
  99. digitalhub/stores/{s3/store.py → objects/s3.py} +1 -1
  100. digitalhub/stores/{sql/store.py → objects/sql.py} +1 -1
  101. digitalhub/{client/dhcore/utils.py → utils/env_utils.py} +14 -2
  102. digitalhub/utils/exceptions.py +0 -12
  103. digitalhub/utils/generic_utils.py +42 -18
  104. digitalhub/utils/io_utils.py +2 -39
  105. {digitalhub-0.8.0.dist-info → digitalhub-0.8.0b1.dist-info}/METADATA +2 -3
  106. digitalhub-0.8.0b1.dist-info/RECORD +161 -0
  107. {digitalhub-0.8.0.dist-info → digitalhub-0.8.0b1.dist-info}/WHEEL +1 -1
  108. test/test_crud_artifacts.py +96 -0
  109. test/test_crud_dataitems.py +96 -0
  110. test/test_crud_functions.py +1 -1
  111. test/test_crud_runs.py +1 -1
  112. test/test_crud_tasks.py +1 -1
  113. digitalhub/client/api.py +0 -63
  114. digitalhub/client/dhcore/env.py +0 -21
  115. digitalhub/client/dhcore/models.py +0 -46
  116. digitalhub/context/api.py +0 -93
  117. digitalhub/datastores/api.py +0 -37
  118. digitalhub/entities/_base/api_utils.py +0 -620
  119. digitalhub/entities/_base/entity/_constructors/metadata.py +0 -44
  120. digitalhub/entities/_base/entity/_constructors/spec.py +0 -33
  121. digitalhub/entities/_base/entity/_constructors/status.py +0 -52
  122. digitalhub/entities/_base/entity/builder.py +0 -175
  123. digitalhub/entities/_base/executable/__init__.py +0 -0
  124. digitalhub/entities/_base/material/__init__.py +0 -0
  125. digitalhub/entities/_base/runtime_entity/__init__.py +0 -0
  126. digitalhub/entities/_base/runtime_entity/builder.py +0 -106
  127. digitalhub/entities/_base/unversioned/__init__.py +0 -0
  128. digitalhub/entities/_base/unversioned/builder.py +0 -66
  129. digitalhub/entities/_base/unversioned/entity.py +0 -49
  130. digitalhub/entities/_base/versioned/__init__.py +0 -0
  131. digitalhub/entities/_base/versioned/builder.py +0 -68
  132. digitalhub/entities/_base/versioned/entity.py +0 -53
  133. digitalhub/entities/artifact/_base/__init__.py +0 -0
  134. digitalhub/entities/artifact/_base/builder.py +0 -86
  135. digitalhub/entities/artifact/_base/spec.py +0 -15
  136. digitalhub/entities/artifact/_base/status.py +0 -9
  137. digitalhub/entities/artifact/artifact/__init__.py +0 -0
  138. digitalhub/entities/artifact/artifact/builder.py +0 -18
  139. digitalhub/entities/artifact/artifact/entity.py +0 -32
  140. digitalhub/entities/builders.py +0 -63
  141. digitalhub/entities/dataitem/_base/__init__.py +0 -0
  142. digitalhub/entities/dataitem/_base/builder.py +0 -86
  143. digitalhub/entities/dataitem/_base/spec.py +0 -15
  144. digitalhub/entities/dataitem/_base/status.py +0 -20
  145. digitalhub/entities/dataitem/dataitem/__init__.py +0 -0
  146. digitalhub/entities/dataitem/dataitem/builder.py +0 -18
  147. digitalhub/entities/dataitem/dataitem/entity.py +0 -32
  148. digitalhub/entities/dataitem/dataitem/spec.py +0 -15
  149. digitalhub/entities/dataitem/dataitem/status.py +0 -9
  150. digitalhub/entities/dataitem/iceberg/__init__.py +0 -0
  151. digitalhub/entities/dataitem/iceberg/builder.py +0 -18
  152. digitalhub/entities/dataitem/iceberg/entity.py +0 -32
  153. digitalhub/entities/dataitem/iceberg/spec.py +0 -15
  154. digitalhub/entities/dataitem/iceberg/status.py +0 -9
  155. digitalhub/entities/dataitem/table/__init__.py +0 -0
  156. digitalhub/entities/dataitem/table/builder.py +0 -18
  157. digitalhub/entities/dataitem/table/spec.py +0 -25
  158. digitalhub/entities/dataitem/table/status.py +0 -9
  159. digitalhub/entities/function/_base/__init__.py +0 -0
  160. digitalhub/entities/function/_base/builder.py +0 -79
  161. digitalhub/entities/function/_base/spec.py +0 -15
  162. digitalhub/entities/function/_base/status.py +0 -9
  163. digitalhub/entities/model/_base/__init__.py +0 -0
  164. digitalhub/entities/model/_base/builder.py +0 -86
  165. digitalhub/entities/model/_base/spec.py +0 -49
  166. digitalhub/entities/model/_base/status.py +0 -9
  167. digitalhub/entities/model/huggingface/__init__.py +0 -0
  168. digitalhub/entities/model/huggingface/builder.py +0 -18
  169. digitalhub/entities/model/huggingface/entity.py +0 -32
  170. digitalhub/entities/model/huggingface/spec.py +0 -36
  171. digitalhub/entities/model/huggingface/status.py +0 -9
  172. digitalhub/entities/model/mlflow/__init__.py +0 -0
  173. digitalhub/entities/model/mlflow/builder.py +0 -18
  174. digitalhub/entities/model/mlflow/entity.py +0 -32
  175. digitalhub/entities/model/mlflow/spec.py +0 -44
  176. digitalhub/entities/model/mlflow/status.py +0 -9
  177. digitalhub/entities/model/model/__init__.py +0 -0
  178. digitalhub/entities/model/model/builder.py +0 -18
  179. digitalhub/entities/model/model/entity.py +0 -32
  180. digitalhub/entities/model/model/spec.py +0 -15
  181. digitalhub/entities/model/model/status.py +0 -9
  182. digitalhub/entities/model/sklearn/__init__.py +0 -0
  183. digitalhub/entities/model/sklearn/builder.py +0 -18
  184. digitalhub/entities/model/sklearn/entity.py +0 -32
  185. digitalhub/entities/model/sklearn/spec.py +0 -15
  186. digitalhub/entities/model/sklearn/status.py +0 -9
  187. digitalhub/entities/project/_base/__init__.py +0 -0
  188. digitalhub/entities/project/_base/builder.py +0 -128
  189. digitalhub/entities/project/_base/status.py +0 -9
  190. digitalhub/entities/run/_base/__init__.py +0 -0
  191. digitalhub/entities/run/_base/builder.py +0 -94
  192. digitalhub/entities/run/_base/spec.py +0 -50
  193. digitalhub/entities/run/_base/status.py +0 -9
  194. digitalhub/entities/secret/_base/__init__.py +0 -0
  195. digitalhub/entities/secret/_base/builder.py +0 -81
  196. digitalhub/entities/secret/_base/status.py +0 -9
  197. digitalhub/entities/task/_base/__init__.py +0 -0
  198. digitalhub/entities/task/_base/builder.py +0 -91
  199. digitalhub/entities/task/_base/status.py +0 -9
  200. digitalhub/entities/utils/__init__.py +0 -0
  201. digitalhub/entities/workflow/_base/__init__.py +0 -0
  202. digitalhub/entities/workflow/_base/builder.py +0 -79
  203. digitalhub/entities/workflow/_base/spec.py +0 -15
  204. digitalhub/entities/workflow/_base/status.py +0 -9
  205. digitalhub/factory/__init__.py +0 -0
  206. digitalhub/factory/api.py +0 -277
  207. digitalhub/factory/factory.py +0 -268
  208. digitalhub/factory/utils.py +0 -90
  209. digitalhub/readers/_base/__init__.py +0 -0
  210. digitalhub/readers/_base/builder.py +0 -26
  211. digitalhub/readers/api.py +0 -80
  212. digitalhub/readers/factory.py +0 -133
  213. digitalhub/readers/pandas/__init__.py +0 -0
  214. digitalhub/readers/pandas/builder.py +0 -29
  215. digitalhub/stores/_base/__init__.py +0 -0
  216. digitalhub/stores/api.py +0 -54
  217. digitalhub/stores/local/__init__.py +0 -0
  218. digitalhub/stores/remote/__init__.py +0 -0
  219. digitalhub/stores/s3/__init__.py +0 -0
  220. digitalhub/stores/sql/__init__.py +0 -0
  221. digitalhub/utils/s3_utils.py +0 -58
  222. digitalhub-0.8.0.dist-info/RECORD +0 -231
  223. test/local/CRUD/test_artifacts.py +0 -96
  224. test/local/CRUD/test_dataitems.py +0 -96
  225. test/local/CRUD/test_models.py +0 -95
  226. /digitalhub/client/{_base → objects}/__init__.py +0 -0
  227. /digitalhub/client/{_base/client.py → objects/base.py} +0 -0
  228. /digitalhub/{client/dhcore → datastores/objects}/__init__.py +0 -0
  229. /digitalhub/entities/{utils → _base}/api.py +0 -0
  230. /digitalhub/{client/local → entities/_base/spec}/__init__.py +0 -0
  231. /digitalhub/entities/{utils → _base}/state.py +0 -0
  232. /digitalhub/{datastores/_base → entities/_base/status}/__init__.py +0 -0
  233. /digitalhub/{datastores/local → entities/_builders}/__init__.py +0 -0
  234. /digitalhub/entities/{_base/entity/_constructors → _builders}/name.py +0 -0
  235. /digitalhub/{datastores/remote → entities/artifact/entity}/__init__.py +0 -0
  236. /digitalhub/{datastores/s3 → entities/dataitem/entity}/__init__.py +0 -0
  237. /digitalhub/entities/dataitem/{table/models.py → models.py} +0 -0
  238. /digitalhub/entities/{utils/entity_types.py → entity_types.py} +0 -0
  239. /digitalhub/{datastores/sql → entities/model/entity}/__init__.py +0 -0
  240. /digitalhub/entities/model/{mlflow/models.py → models.py} +0 -0
  241. /digitalhub/{entities/_base/_base → readers/objects}/__init__.py +0 -0
  242. /digitalhub/readers/{_base/reader.py → objects/base.py} +0 -0
  243. /digitalhub/{entities/_base/context → registry}/__init__.py +0 -0
  244. /digitalhub/{entities/_base/entity/_constructors → stores/objects}/__init__.py +0 -0
  245. /digitalhub/stores/{_base/store.py → objects/base.py} +0 -0
  246. {digitalhub-0.8.0.dist-info → digitalhub-0.8.0b1.dist-info}/LICENSE.txt +0 -0
  247. {digitalhub-0.8.0.dist-info → digitalhub-0.8.0b1.dist-info}/top_level.txt +0 -0
  248. /test/{local/imports/test_imports.py → test_imports.py} +0 -0
@@ -1,52 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import typing
4
-
5
- from digitalhub.entities.utils.state import State
6
-
7
- if typing.TYPE_CHECKING:
8
- from digitalhub.entities._base.entity.status import Status
9
-
10
-
11
- def build_status(status_cls: Status, **kwargs) -> Status:
12
- """
13
- Build entity status object. This method is used to build entity
14
- status.
15
-
16
- Parameters
17
- ----------
18
- status_cls : Status
19
- Entity status class.
20
- **kwargs : dict
21
- Keyword arguments.
22
-
23
- Returns
24
- -------
25
- Status
26
- Entity status object.
27
- """
28
- kwargs = parse_arguments(**kwargs)
29
- return status_cls(**kwargs)
30
-
31
-
32
- def parse_arguments(**kwargs) -> dict:
33
- """
34
- Parse keyword arguments and add default values if necessary.
35
-
36
- Parameters
37
- ----------
38
- **kwargs : dict
39
- Keyword arguments.
40
-
41
- Returns
42
- -------
43
- dict
44
- Keyword arguments with default values.
45
- """
46
- state = kwargs.get("state")
47
- if state is None:
48
- kwargs["state"] = State.CREATED.value
49
- else:
50
- if kwargs["state"] not in State.__members__:
51
- raise ValueError(f"Invalid state: {state}")
52
- return kwargs
@@ -1,175 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import typing
4
- from abc import abstractmethod
5
-
6
- from digitalhub.entities._base.entity._constructors.metadata import build_metadata
7
- from digitalhub.entities._base.entity._constructors.name import build_name
8
- from digitalhub.entities._base.entity._constructors.spec import build_spec
9
- from digitalhub.entities._base.entity._constructors.status import build_status
10
- from digitalhub.entities._base.entity._constructors.uuid import build_uuid
11
- from digitalhub.utils.exceptions import BuilderError
12
-
13
- if typing.TYPE_CHECKING:
14
- from digitalhub.entities._base.entity.entity import Entity
15
- from digitalhub.entities._base.entity.metadata import Metadata
16
- from digitalhub.entities._base.entity.spec import Spec, SpecValidator
17
- from digitalhub.entities._base.entity.status import Status
18
-
19
-
20
- class EntityBuilder:
21
- """
22
- Builder class for building entities.
23
- """
24
-
25
- # Class variables
26
- ENTITY_TYPE: str = None
27
- ENTITY_CLASS: Entity = None
28
- ENTITY_SPEC_CLASS: Spec = None
29
- ENTITY_SPEC_VALIDATOR: SpecValidator = None
30
- ENTITY_STATUS_CLASS: Status = None
31
- ENTITY_KIND: str = None
32
-
33
- def __init__(self) -> None:
34
- if self.ENTITY_TYPE is None:
35
- raise BuilderError("ENTITY_TYPE must be set")
36
- if self.ENTITY_CLASS is None:
37
- raise BuilderError("ENTITY_CLASS must be set")
38
- if self.ENTITY_SPEC_CLASS is None:
39
- raise BuilderError("ENTITY_SPEC_CLASS must be set")
40
- if self.ENTITY_SPEC_VALIDATOR is None:
41
- raise BuilderError("ENTITY_SPEC_VALIDATOR must be set")
42
- if self.ENTITY_STATUS_CLASS is None:
43
- raise BuilderError("ENTITY_STATUS_CLASS must be set")
44
- if self.ENTITY_KIND is None:
45
- raise BuilderError("ENTITY_KIND must be set")
46
-
47
- def build_name(self, name: str) -> str:
48
- """
49
- Build entity name.
50
-
51
- Parameters
52
- ----------
53
- name : str
54
- Entity name.
55
-
56
- Returns
57
- -------
58
- str
59
- Entity name.
60
- """
61
- return build_name(name)
62
-
63
- def build_uuid(self, uuid: str) -> str:
64
- """
65
- Build entity uuid.
66
-
67
- Parameters
68
- ----------
69
- uuid : str
70
- Entity uuid.
71
-
72
- Returns
73
- -------
74
- str
75
- Entity uuid.
76
- """
77
- return build_uuid(uuid)
78
-
79
- def build_metadata(self, **kwargs) -> Metadata:
80
- """
81
- Build entity metadata object.
82
-
83
- Parameters
84
- ----------
85
- **kwargs : dict
86
- Keyword arguments for the constructor.
87
-
88
- Returns
89
- -------
90
- Metadata
91
- Metadata object.
92
- """
93
- return build_metadata(**kwargs)
94
-
95
- def build_spec(self, validate: bool = True, **kwargs) -> Spec:
96
- """
97
- Build entity spec object.
98
-
99
- Parameters
100
- ----------
101
- **kwargs : dict
102
- Keyword arguments for the constructor.
103
-
104
- Returns
105
- -------
106
- Spec
107
- Spec object.
108
- """
109
- return build_spec(self.ENTITY_SPEC_CLASS, self.ENTITY_SPEC_VALIDATOR, validate=validate, **kwargs)
110
-
111
- def build_status(self, **kwargs) -> Status:
112
- """
113
- Build entity status object.
114
-
115
- Parameters
116
- ----------
117
- **kwargs : dict
118
- Keyword arguments for the constructor.
119
-
120
- Returns
121
- -------
122
- Status
123
- Status object.
124
- """
125
- return build_status(self.ENTITY_STATUS_CLASS, **kwargs)
126
-
127
- def build_entity(self, **kwargs) -> Entity:
128
- """
129
- Build entity object.
130
-
131
- Parameters
132
- ----------
133
- **kwargs : dict
134
- Keyword arguments for the constructor.
135
-
136
- Returns
137
- -------
138
- Entity
139
- Entity object.
140
- """
141
- return self.ENTITY_CLASS(**kwargs)
142
-
143
- @abstractmethod
144
- def build(self, *args, **kwargs) -> Entity:
145
- """
146
- Build entity object.
147
- """
148
-
149
- @abstractmethod
150
- def from_dict(self, obj: dict, validate: bool = True) -> Entity:
151
- """
152
- Build entity object from dictionary.
153
- """
154
-
155
- def get_entity_type(self) -> str:
156
- """
157
- Get entity type.
158
-
159
- Returns
160
- -------
161
- str
162
- Entity type.
163
- """
164
- return self.ENTITY_TYPE
165
-
166
- def get_kind(self) -> str:
167
- """
168
- Get entity kind.
169
-
170
- Returns
171
- -------
172
- str
173
- Entity kind.
174
- """
175
- return self.ENTITY_KIND
File without changes
File without changes
File without changes
@@ -1,106 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from digitalhub.utils.exceptions import EntityError
4
-
5
-
6
- class RuntimeEntityBuilder:
7
- """
8
- RuntimeEntity builder.
9
- """
10
-
11
- EXECUTABLE_KIND: str = None
12
- TASKS_KINDS: dict = None
13
- RUN_KIND: str = None
14
-
15
- def __init__(self) -> None:
16
- if self.EXECUTABLE_KIND is None:
17
- raise EntityError("EXECUTABLE_KIND must be set")
18
- if self.TASKS_KINDS is None:
19
- raise EntityError("TASKS_KINDS must be set")
20
- if self.RUN_KIND is None:
21
- raise EntityError("RUN_KIND must be set")
22
-
23
- def get_action_from_task_kind(self, task_kind: str) -> str:
24
- """
25
- Get action from task kind.
26
-
27
- Parameters
28
- ----------
29
- task_kind : str
30
- Task kind.
31
-
32
- Returns
33
- -------
34
- str
35
- Action.
36
- """
37
- for task in self.TASKS_KINDS:
38
- if task["kind"] == task_kind:
39
- return task["action"]
40
- msg = f"Task kind {task_kind} not allowed."
41
- raise EntityError(msg)
42
-
43
- def get_task_kind_from_action(self, action: str) -> list[str]:
44
- """
45
- Get task kinds from action.
46
-
47
- Parameters
48
- ----------
49
- action : str
50
- Action.
51
-
52
- Returns
53
- -------
54
- list[str]
55
- Task kinds.
56
- """
57
- for task in self.TASKS_KINDS:
58
- if task["action"] == action:
59
- return task["kind"]
60
- msg = f"Action {action} not allowed."
61
- raise EntityError(msg)
62
-
63
- def get_run_kind(self) -> str:
64
- """
65
- Get run kind.
66
-
67
- Returns
68
- -------
69
- str
70
- Run kind.
71
- """
72
- return self.RUN_KIND
73
-
74
- def get_executable_kind(self) -> str:
75
- """
76
- Get executable kind.
77
-
78
- Returns
79
- -------
80
- str
81
- Executable kind.
82
- """
83
- return self.EXECUTABLE_KIND
84
-
85
- def get_all_kinds(self) -> list[str]:
86
- """
87
- Get all kinds.
88
-
89
- Returns
90
- -------
91
- list[str]
92
- All kinds.
93
- """
94
- task_kinds = [i["kind"] for i in self.TASKS_KINDS]
95
- return [self.EXECUTABLE_KIND, self.RUN_KIND, *task_kinds]
96
-
97
- def get_all_actions(self) -> list[str]:
98
- """
99
- Get all actions.
100
-
101
- Returns
102
- -------
103
- list[str]
104
- All actions.
105
- """
106
- return [i["action"] for i in self.TASKS_KINDS]
File without changes
@@ -1,66 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import typing
4
-
5
- from digitalhub.entities._base.entity.builder import EntityBuilder
6
-
7
- if typing.TYPE_CHECKING:
8
- from digitalhub.entities._base.unversioned.entity import UnversionedEntity
9
-
10
-
11
- class UnversionedBuilder(EntityBuilder):
12
- """
13
- Unversioned builder.
14
- """
15
-
16
- def from_dict(self, obj: dict, validate: bool = True) -> UnversionedEntity:
17
- """
18
- Create a new object from dictionary.
19
-
20
- Parameters
21
- ----------
22
- obj : dict
23
- Dictionary to create object from.
24
- validate : bool
25
- Flag to indicate if arguments must be validated.
26
-
27
- Returns
28
- -------
29
- UnversionedEntity
30
- Object instance.
31
- """
32
- parsed_dict = self._parse_dict(obj, validate=validate)
33
- return self.build_entity(**parsed_dict)
34
-
35
- def _parse_dict(self, obj: dict, validate: bool = True) -> dict:
36
- """
37
- Get dictionary and parse it to a valid entity dictionary.
38
-
39
- Parameters
40
- ----------
41
- entity : str
42
- Entity type.
43
- obj : dict
44
- Dictionary to parse.
45
-
46
- Returns
47
- -------
48
- dict
49
- A dictionary containing the attributes of the entity instance.
50
- """
51
- project = obj.get("project")
52
- kind = obj.get("kind")
53
- uuid = self.build_uuid(obj.get("id"))
54
- metadata = self.build_metadata(**obj.get("metadata", {}))
55
- spec = self.build_spec(validate=validate, **obj.get("spec", {}))
56
- status = self.build_status(**obj.get("status", {}))
57
- user = obj.get("user")
58
- return {
59
- "project": project,
60
- "uuid": uuid,
61
- "kind": kind,
62
- "metadata": metadata,
63
- "spec": spec,
64
- "status": status,
65
- "user": user,
66
- }
@@ -1,49 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import typing
4
-
5
- from digitalhub.entities._base.context.entity import ContextEntity
6
- from digitalhub.utils.io_utils import write_yaml
7
-
8
- if typing.TYPE_CHECKING:
9
- from digitalhub.entities._base.entity.metadata import Metadata
10
- from digitalhub.entities._base.entity.spec import Spec
11
- from digitalhub.entities._base.entity.status import Status
12
-
13
-
14
- class UnversionedEntity(ContextEntity):
15
- def __init__(
16
- self,
17
- project: str,
18
- uuid: str,
19
- kind: str,
20
- metadata: Metadata,
21
- spec: Spec,
22
- status: Status,
23
- user: str | None = None,
24
- ) -> None:
25
- super().__init__(project, kind, metadata, spec, status, user)
26
- self.id = uuid
27
- self.key = f"store://{project}/{self.ENTITY_TYPE}/{kind}/{uuid}"
28
- self._obj_attr.extend(["id"])
29
-
30
- def export(self, filename: str | None = None) -> str:
31
- """
32
- Export object as a YAML file.
33
-
34
- Parameters
35
- ----------
36
- filename : str
37
- Name of the export YAML file. If not specified, the default value is used.
38
-
39
- Returns
40
- -------
41
- str
42
- Exported file.
43
- """
44
- obj = self.to_dict()
45
- if filename is None:
46
- filename = f"{self.ENTITY_TYPE}-{self.id}.yml"
47
- pth = self._context().root / filename
48
- write_yaml(pth, obj)
49
- return str(pth)
File without changes
@@ -1,68 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import typing
4
-
5
- from digitalhub.entities._base.entity.builder import EntityBuilder
6
-
7
- if typing.TYPE_CHECKING:
8
- from digitalhub.entities._base.versioned.entity import VersionedEntity
9
-
10
-
11
- class VersionedBuilder(EntityBuilder):
12
- """
13
- Versioned builder.
14
- """
15
-
16
- def from_dict(self, obj: dict, validate: bool = True) -> VersionedEntity:
17
- """
18
- Create a new object from dictionary.
19
-
20
- Parameters
21
- ----------
22
- obj : dict
23
- Dictionary to create object from.
24
- validate : bool
25
- Flag to indicate if arguments must be validated.
26
-
27
- Returns
28
- -------
29
- VersionedEntity
30
- Object instance.
31
- """
32
- parsed_dict = self._parse_dict(obj, validate=validate)
33
- return self.build_entity(**parsed_dict)
34
-
35
- def _parse_dict(self, obj: dict, validate: bool = True) -> dict:
36
- """
37
- Get dictionary and parse it to a valid entity dictionary.
38
-
39
- Parameters
40
- ----------
41
- entity : str
42
- Entity type.
43
- obj : dict
44
- Dictionary to parse.
45
-
46
- Returns
47
- -------
48
- dict
49
- A dictionary containing the attributes of the entity instance.
50
- """
51
- project = obj.get("project")
52
- kind = obj.get("kind")
53
- name = self.build_name(obj.get("name"))
54
- uuid = self.build_uuid(obj.get("id"))
55
- metadata = self.build_metadata(**obj.get("metadata", {}))
56
- spec = self.build_spec(validate=validate, **obj.get("spec", {}))
57
- status = self.build_status(**obj.get("status", {}))
58
- user = obj.get("user")
59
- return {
60
- "project": project,
61
- "name": name,
62
- "uuid": uuid,
63
- "kind": kind,
64
- "metadata": metadata,
65
- "spec": spec,
66
- "status": status,
67
- "user": user,
68
- }
@@ -1,53 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import typing
4
-
5
- from digitalhub.entities._base.context.entity import ContextEntity
6
- from digitalhub.utils.io_utils import write_yaml
7
-
8
- if typing.TYPE_CHECKING:
9
- from digitalhub.entities._base.entity.metadata import Metadata
10
- from digitalhub.entities._base.entity.spec import Spec
11
- from digitalhub.entities._base.entity.status import Status
12
-
13
-
14
- class VersionedEntity(ContextEntity):
15
- def __init__(
16
- self,
17
- project: str,
18
- name: str,
19
- uuid: str,
20
- kind: str,
21
- metadata: Metadata,
22
- spec: Spec,
23
- status: Status,
24
- user: str | None = None,
25
- ) -> None:
26
- super().__init__(project, kind, metadata, spec, status, user)
27
- self.name = name
28
- self.id = uuid
29
- self.key = f"store://{project}/{self.ENTITY_TYPE}/{kind}/{name}:{uuid}"
30
-
31
- # Add attributes to be used in the to_dict method
32
- self._obj_attr.extend(["name", "id"])
33
-
34
- def export(self, filename: str | None = None) -> str:
35
- """
36
- Export object as a YAML file.
37
-
38
- Parameters
39
- ----------
40
- filename : str
41
- Name of the export YAML file. If not specified, the default value is used.
42
-
43
- Returns
44
- -------
45
- str
46
- Exported file.
47
- """
48
- obj = self.to_dict()
49
- if filename is None:
50
- filename = f"{self.ENTITY_TYPE}-{self.name}-{self.id}.yml"
51
- pth = self._context().root / filename
52
- write_yaml(pth, obj)
53
- return str(pth)
File without changes
@@ -1,86 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import typing
4
-
5
- from digitalhub.entities._base.versioned.builder import VersionedBuilder
6
- from digitalhub.entities.utils.entity_types import EntityTypes
7
- from digitalhub.utils.exceptions import EntityError
8
-
9
- if typing.TYPE_CHECKING:
10
- from digitalhub.entities.artifact._base.entity import Artifact
11
-
12
-
13
- class ArtifactBuilder(VersionedBuilder):
14
- """
15
- Artifact builder.
16
- """
17
-
18
- ENTITY_TYPE = EntityTypes.ARTIFACT.value
19
-
20
- def build(
21
- self,
22
- kind: str,
23
- project: str,
24
- name: str,
25
- uuid: str | None = None,
26
- description: str | None = None,
27
- labels: list[str] | None = None,
28
- embedded: bool = False,
29
- path: str | None = None,
30
- **kwargs,
31
- ) -> Artifact:
32
- """
33
- Create a new object.
34
-
35
- Parameters
36
- ----------
37
- project : str
38
- Project name.
39
- name : str
40
- Object name.
41
- kind : str
42
- Kind the object.
43
- uuid : str
44
- ID of the object.
45
- description : str
46
- Description of the object (human readable).
47
- labels : list[str]
48
- List of labels.
49
- embedded : bool
50
- Flag to determine if object spec must be embedded in project spec.
51
- path : str
52
- Object path on local file system or remote storage. It is also the destination path of upload() method.
53
- **kwargs : dict
54
- Spec keyword arguments.
55
-
56
- Returns
57
- -------
58
- Artifact
59
- Object instance.
60
- """
61
- if path is None:
62
- raise EntityError("Path must be provided.")
63
-
64
- name = self.build_name(name)
65
- uuid = self.build_uuid(uuid)
66
- metadata = self.build_metadata(
67
- project=project,
68
- name=name,
69
- description=description,
70
- labels=labels,
71
- embedded=embedded,
72
- )
73
- spec = self.build_spec(
74
- path=path,
75
- **kwargs,
76
- )
77
- status = self.build_status()
78
- return self.build_entity(
79
- project=project,
80
- name=name,
81
- uuid=uuid,
82
- kind=kind,
83
- metadata=metadata,
84
- spec=spec,
85
- status=status,
86
- )
@@ -1,15 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from digitalhub.entities._base.material.spec import MaterialSpec, MaterialValidator
4
-
5
-
6
- class ArtifactSpec(MaterialSpec):
7
- """
8
- ArtifactSpec specifications.
9
- """
10
-
11
-
12
- class ArtifactValidator(MaterialValidator):
13
- """
14
- ArtifactValidator validator.
15
- """
@@ -1,9 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from digitalhub.entities._base.material.status import MaterialStatus
4
-
5
-
6
- class ArtifactStatus(MaterialStatus):
7
- """
8
- ArtifactStatus status.
9
- """
File without changes