digitalhub 0.8.0b0__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 (159) hide show
  1. digitalhub/__init__.py +62 -94
  2. digitalhub/client/__init__.py +0 -0
  3. digitalhub/client/builder.py +105 -0
  4. digitalhub/client/objects/__init__.py +0 -0
  5. digitalhub/client/objects/base.py +56 -0
  6. digitalhub/client/objects/dhcore.py +681 -0
  7. digitalhub/client/objects/local.py +533 -0
  8. digitalhub/context/__init__.py +0 -0
  9. digitalhub/context/builder.py +178 -0
  10. digitalhub/context/context.py +136 -0
  11. digitalhub/datastores/__init__.py +0 -0
  12. digitalhub/datastores/builder.py +134 -0
  13. digitalhub/datastores/objects/__init__.py +0 -0
  14. digitalhub/datastores/objects/base.py +85 -0
  15. digitalhub/datastores/objects/local.py +42 -0
  16. digitalhub/datastores/objects/remote.py +23 -0
  17. digitalhub/datastores/objects/s3.py +38 -0
  18. digitalhub/datastores/objects/sql.py +60 -0
  19. digitalhub/entities/__init__.py +0 -0
  20. digitalhub/entities/_base/__init__.py +0 -0
  21. digitalhub/entities/_base/api.py +346 -0
  22. digitalhub/entities/_base/base.py +82 -0
  23. digitalhub/entities/_base/crud.py +610 -0
  24. digitalhub/entities/_base/entity/__init__.py +0 -0
  25. digitalhub/entities/_base/entity/base.py +132 -0
  26. digitalhub/entities/_base/entity/context.py +118 -0
  27. digitalhub/entities/_base/entity/executable.py +380 -0
  28. digitalhub/entities/_base/entity/material.py +214 -0
  29. digitalhub/entities/_base/entity/unversioned.py +87 -0
  30. digitalhub/entities/_base/entity/versioned.py +94 -0
  31. digitalhub/entities/_base/metadata.py +59 -0
  32. digitalhub/entities/_base/spec/__init__.py +0 -0
  33. digitalhub/entities/_base/spec/base.py +58 -0
  34. digitalhub/entities/_base/spec/material.py +22 -0
  35. digitalhub/entities/_base/state.py +31 -0
  36. digitalhub/entities/_base/status/__init__.py +0 -0
  37. digitalhub/entities/_base/status/base.py +32 -0
  38. digitalhub/entities/_base/status/material.py +49 -0
  39. digitalhub/entities/_builders/__init__.py +0 -0
  40. digitalhub/entities/_builders/metadata.py +60 -0
  41. digitalhub/entities/_builders/name.py +31 -0
  42. digitalhub/entities/_builders/spec.py +43 -0
  43. digitalhub/entities/_builders/status.py +62 -0
  44. digitalhub/entities/_builders/uuid.py +33 -0
  45. digitalhub/entities/artifact/__init__.py +0 -0
  46. digitalhub/entities/artifact/builder.py +133 -0
  47. digitalhub/entities/artifact/crud.py +358 -0
  48. digitalhub/entities/artifact/entity/__init__.py +0 -0
  49. digitalhub/entities/artifact/entity/_base.py +39 -0
  50. digitalhub/entities/artifact/entity/artifact.py +9 -0
  51. digitalhub/entities/artifact/spec.py +39 -0
  52. digitalhub/entities/artifact/status.py +15 -0
  53. digitalhub/entities/dataitem/__init__.py +0 -0
  54. digitalhub/entities/dataitem/builder.py +144 -0
  55. digitalhub/entities/dataitem/crud.py +395 -0
  56. digitalhub/entities/dataitem/entity/__init__.py +0 -0
  57. digitalhub/entities/dataitem/entity/_base.py +75 -0
  58. digitalhub/entities/dataitem/entity/dataitem.py +9 -0
  59. digitalhub/entities/dataitem/entity/iceberg.py +7 -0
  60. digitalhub/entities/dataitem/entity/table.py +125 -0
  61. digitalhub/entities/dataitem/models.py +62 -0
  62. digitalhub/entities/dataitem/spec.py +61 -0
  63. digitalhub/entities/dataitem/status.py +38 -0
  64. digitalhub/entities/entity_types.py +19 -0
  65. digitalhub/entities/function/__init__.py +0 -0
  66. digitalhub/entities/function/builder.py +86 -0
  67. digitalhub/entities/function/crud.py +305 -0
  68. digitalhub/entities/function/entity.py +101 -0
  69. digitalhub/entities/function/models.py +118 -0
  70. digitalhub/entities/function/spec.py +81 -0
  71. digitalhub/entities/function/status.py +9 -0
  72. digitalhub/entities/model/__init__.py +0 -0
  73. digitalhub/entities/model/builder.py +152 -0
  74. digitalhub/entities/model/crud.py +358 -0
  75. digitalhub/entities/model/entity/__init__.py +0 -0
  76. digitalhub/entities/model/entity/_base.py +34 -0
  77. digitalhub/entities/model/entity/huggingface.py +9 -0
  78. digitalhub/entities/model/entity/mlflow.py +90 -0
  79. digitalhub/entities/model/entity/model.py +9 -0
  80. digitalhub/entities/model/entity/sklearn.py +9 -0
  81. digitalhub/entities/model/models.py +26 -0
  82. digitalhub/entities/model/spec.py +146 -0
  83. digitalhub/entities/model/status.py +33 -0
  84. digitalhub/entities/project/__init__.py +0 -0
  85. digitalhub/entities/project/builder.py +82 -0
  86. digitalhub/entities/project/crud.py +350 -0
  87. digitalhub/entities/project/entity.py +2060 -0
  88. digitalhub/entities/project/spec.py +50 -0
  89. digitalhub/entities/project/status.py +9 -0
  90. digitalhub/entities/registries.py +48 -0
  91. digitalhub/entities/run/__init__.py +0 -0
  92. digitalhub/entities/run/builder.py +77 -0
  93. digitalhub/entities/run/crud.py +232 -0
  94. digitalhub/entities/run/entity.py +461 -0
  95. digitalhub/entities/run/spec.py +153 -0
  96. digitalhub/entities/run/status.py +114 -0
  97. digitalhub/entities/secret/__init__.py +0 -0
  98. digitalhub/entities/secret/builder.py +93 -0
  99. digitalhub/entities/secret/crud.py +294 -0
  100. digitalhub/entities/secret/entity.py +73 -0
  101. digitalhub/entities/secret/spec.py +35 -0
  102. digitalhub/entities/secret/status.py +9 -0
  103. digitalhub/entities/task/__init__.py +0 -0
  104. digitalhub/entities/task/builder.py +74 -0
  105. digitalhub/entities/task/crud.py +241 -0
  106. digitalhub/entities/task/entity.py +135 -0
  107. digitalhub/entities/task/models.py +199 -0
  108. digitalhub/entities/task/spec.py +51 -0
  109. digitalhub/entities/task/status.py +9 -0
  110. digitalhub/entities/utils.py +184 -0
  111. digitalhub/entities/workflow/__init__.py +0 -0
  112. digitalhub/entities/workflow/builder.py +91 -0
  113. digitalhub/entities/workflow/crud.py +304 -0
  114. digitalhub/entities/workflow/entity.py +77 -0
  115. digitalhub/entities/workflow/spec.py +15 -0
  116. digitalhub/entities/workflow/status.py +9 -0
  117. digitalhub/readers/__init__.py +0 -0
  118. digitalhub/readers/builder.py +54 -0
  119. digitalhub/readers/objects/__init__.py +0 -0
  120. digitalhub/readers/objects/base.py +70 -0
  121. digitalhub/readers/objects/pandas.py +207 -0
  122. digitalhub/readers/registry.py +15 -0
  123. digitalhub/registry/__init__.py +0 -0
  124. digitalhub/registry/models.py +87 -0
  125. digitalhub/registry/registry.py +74 -0
  126. digitalhub/registry/utils.py +150 -0
  127. digitalhub/runtimes/__init__.py +0 -0
  128. digitalhub/runtimes/base.py +164 -0
  129. digitalhub/runtimes/builder.py +53 -0
  130. digitalhub/runtimes/kind_registry.py +170 -0
  131. digitalhub/stores/__init__.py +0 -0
  132. digitalhub/stores/builder.py +257 -0
  133. digitalhub/stores/objects/__init__.py +0 -0
  134. digitalhub/stores/objects/base.py +189 -0
  135. digitalhub/stores/objects/local.py +230 -0
  136. digitalhub/stores/objects/remote.py +143 -0
  137. digitalhub/stores/objects/s3.py +563 -0
  138. digitalhub/stores/objects/sql.py +328 -0
  139. digitalhub/utils/__init__.py +0 -0
  140. digitalhub/utils/data_utils.py +127 -0
  141. digitalhub/utils/env_utils.py +123 -0
  142. digitalhub/utils/exceptions.py +55 -0
  143. digitalhub/utils/file_utils.py +204 -0
  144. digitalhub/utils/generic_utils.py +207 -0
  145. digitalhub/utils/git_utils.py +148 -0
  146. digitalhub/utils/io_utils.py +79 -0
  147. digitalhub/utils/logger.py +17 -0
  148. digitalhub/utils/uri_utils.py +56 -0
  149. {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/METADATA +27 -12
  150. digitalhub-0.8.0b1.dist-info/RECORD +161 -0
  151. test/test_crud_artifacts.py +1 -1
  152. test/test_crud_dataitems.py +1 -1
  153. test/test_crud_functions.py +1 -1
  154. test/test_crud_runs.py +1 -1
  155. test/test_crud_tasks.py +1 -1
  156. digitalhub-0.8.0b0.dist-info/RECORD +0 -14
  157. {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/LICENSE.txt +0 -0
  158. {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/WHEEL +0 -0
  159. {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,346 @@
1
+ from __future__ import annotations
2
+
3
+ API_BASE = "/api/v1"
4
+ API_CONTEXT = f"{API_BASE}/-"
5
+
6
+
7
+ ##############################
8
+ # Context APIs
9
+ ##############################
10
+
11
+
12
+ def api_ctx_create(
13
+ project: str,
14
+ entity_type: str,
15
+ ) -> str:
16
+ """
17
+ Create context API.
18
+
19
+ Parameters
20
+ ----------
21
+ project : str
22
+ Project name.
23
+ entity_type : str
24
+ The name of the entity_type.
25
+
26
+ Returns
27
+ -------
28
+ str
29
+ The API string formatted.
30
+ """
31
+ if not entity_type.endswith("s"):
32
+ entity_type += "s"
33
+ return f"{API_CONTEXT}/{project}/{entity_type}"
34
+
35
+
36
+ def api_ctx_read(project: str, entity_type: str, entity_id: str) -> str:
37
+ """
38
+ Read context API.
39
+
40
+ Parameters
41
+ ----------
42
+ project : str
43
+ Project name.
44
+ entity_type : str
45
+ Entity type.
46
+ entity_id : str
47
+ Entity ID.
48
+
49
+ Returns
50
+ -------
51
+ str
52
+ The API string formatted.
53
+ """
54
+ if not entity_type.endswith("s"):
55
+ entity_type += "s"
56
+ return f"{API_CONTEXT}/{project}/{entity_type}/{entity_id}"
57
+
58
+
59
+ def api_ctx_update(
60
+ project: str,
61
+ entity_type: str,
62
+ entity_id: str,
63
+ ) -> str:
64
+ """
65
+ Update context API.
66
+
67
+ Parameters
68
+ ----------
69
+ project : str
70
+ Project name.
71
+ entity_type : str
72
+ Entity type.
73
+ entity_id : str
74
+ Entity ID.
75
+
76
+ Returns
77
+ -------
78
+ str
79
+ The API string formatted.
80
+ """
81
+ if not entity_type.endswith("s"):
82
+ entity_type += "s"
83
+ return f"{API_CONTEXT}/{project}/{entity_type}/{entity_id}"
84
+
85
+
86
+ def api_ctx_delete(project: str, entity_type: str, entity_id: str) -> str:
87
+ """
88
+ Delete context API.
89
+
90
+ Parameters
91
+ ----------
92
+ project : str
93
+ Project name.
94
+ entity_type : str
95
+ Entity type.
96
+ entity_id : str
97
+ Entity ID.
98
+
99
+ Returns
100
+ -------
101
+ str
102
+ The API string formatted.
103
+ """
104
+ if not entity_type.endswith("s"):
105
+ entity_type += "s"
106
+ return f"{API_CONTEXT}/{project}/{entity_type}/{entity_id}"
107
+
108
+
109
+ def api_ctx_list(project: str, entity_type: str) -> str:
110
+ """
111
+ List context API.
112
+
113
+ Parameters
114
+ ----------
115
+ project : str
116
+ Project name.
117
+ entity_type : str
118
+ Entity type.
119
+
120
+ Returns
121
+ -------
122
+ str
123
+ The API string formatted.
124
+ """
125
+ if not entity_type.endswith("s"):
126
+ entity_type += "s"
127
+ return f"{API_CONTEXT}/{project}/{entity_type}"
128
+
129
+
130
+ def api_ctx_data(project: str, entity_type: str) -> str:
131
+ """
132
+ Data context API.
133
+
134
+ Parameters
135
+ ----------
136
+ project : str
137
+ Project name.
138
+ entity_type : str
139
+ Entity type.
140
+
141
+ Returns
142
+ -------
143
+ str
144
+ The API string formatted.
145
+ """
146
+ if not entity_type.endswith("s"):
147
+ entity_type += "s"
148
+ return f"{API_CONTEXT}/{project}/{entity_type}/data"
149
+
150
+
151
+ def api_ctx_logs(project: str, entity_type: str, entity_id: str) -> str:
152
+ """
153
+ Logs context API.
154
+
155
+ Parameters
156
+ ----------
157
+ project : str
158
+ Project name.
159
+ entity_type : str
160
+ Entity type.
161
+ entity_id : str
162
+ Entity ID.
163
+
164
+ Returns
165
+ -------
166
+ str
167
+ The API string formatted.
168
+ """
169
+ if not entity_type.endswith("s"):
170
+ entity_type += "s"
171
+ return f"{API_CONTEXT}/{project}/{entity_type}/{entity_id}/logs"
172
+
173
+
174
+ def api_ctx_stop(project: str, entity_type: str, entity_id: str) -> str:
175
+ """
176
+ Stop context API.
177
+
178
+ Parameters
179
+ ----------
180
+ project : str
181
+ Project name.
182
+ entity_type : str
183
+ Entity type.
184
+ entity_id : str
185
+ Entity ID.
186
+
187
+ Returns
188
+ -------
189
+ str
190
+ The API string formatted.
191
+ """
192
+ if not entity_type.endswith("s"):
193
+ entity_type += "s"
194
+ return f"{API_CONTEXT}/{project}/{entity_type}/{entity_id}/stop"
195
+
196
+
197
+ def api_ctx_resume(project: str, entity_type: str, entity_id: str) -> str:
198
+ """
199
+ Resume context API.
200
+
201
+ Parameters
202
+ ----------
203
+ project : str
204
+ Project name.
205
+ entity_type : str
206
+ Entity type.
207
+ entity_id : str
208
+ Entity ID.
209
+
210
+ Returns
211
+ -------
212
+ str
213
+ The API string formatted.
214
+ """
215
+ if not entity_type.endswith("s"):
216
+ entity_type += "s"
217
+ return f"{API_CONTEXT}/{project}/{entity_type}/{entity_id}/resume"
218
+
219
+
220
+ def api_ctx_files(project: str, entity_type: str, entity_id: str) -> str:
221
+ """
222
+ Files context API.
223
+
224
+ Parameters
225
+ ----------
226
+ project : str
227
+ Project name.
228
+ entity_type : str
229
+ Entity type.
230
+ entity_id : str
231
+ Entity ID.
232
+
233
+ Returns
234
+ -------
235
+ str
236
+ The API string formatted.
237
+ """
238
+ if not entity_type.endswith("s"):
239
+ entity_type += "s"
240
+ return f"{API_CONTEXT}/{project}/{entity_type}/{entity_id}/files/info"
241
+
242
+
243
+ ##############################
244
+ # Base APIs
245
+ ##############################
246
+
247
+
248
+ def api_base_list(entity_type: str) -> str:
249
+ """
250
+ List base API.
251
+
252
+ Parameters
253
+ ----------
254
+ entity_type : str
255
+ Entity type.
256
+
257
+ Returns
258
+ -------
259
+ str
260
+ The API string formatted.
261
+ """
262
+ if not entity_type.endswith("s"):
263
+ entity_type += "s"
264
+ return f"{API_BASE}/{entity_type}"
265
+
266
+
267
+ def api_base_create(entity_type: str) -> str:
268
+ """
269
+ Create base API.
270
+
271
+ Parameters
272
+ ----------
273
+ entity_type : str
274
+ Entity type.
275
+
276
+ Returns
277
+ -------
278
+ str
279
+ The API string formatted.
280
+ """
281
+ if not entity_type.endswith("s"):
282
+ entity_type += "s"
283
+ return f"{API_BASE}/{entity_type}"
284
+
285
+
286
+ def api_base_read(entity_type: str, entity_id: str) -> str:
287
+ """
288
+ Read base API.
289
+
290
+ Parameters
291
+ ----------
292
+ entity_type : str
293
+ Entity type.
294
+ entity_id : str
295
+ Entity ID.
296
+
297
+ Returns
298
+ -------
299
+ str
300
+ The API string formatted.
301
+ """
302
+ if not entity_type.endswith("s"):
303
+ entity_type += "s"
304
+ return f"{API_BASE}/{entity_type}/{entity_id}"
305
+
306
+
307
+ def api_base_update(entity_type: str, entity_id: str) -> str:
308
+ """
309
+ Update base API.
310
+
311
+ Parameters
312
+ ----------
313
+ entity_type : str
314
+ Entity type.
315
+ entity_id : str
316
+ Entity ID.
317
+
318
+ Returns
319
+ -------
320
+ str
321
+ The API string formatted.
322
+ """
323
+ if not entity_type.endswith("s"):
324
+ entity_type += "s"
325
+ return f"{API_BASE}/{entity_type}/{entity_id}"
326
+
327
+
328
+ def api_base_delete(entity_type: str, entity_id: str) -> str:
329
+ """
330
+ Delete base API.
331
+
332
+ Parameters
333
+ ----------
334
+ entity_type : str
335
+ Entity type.
336
+ entity_id : str
337
+ Entity ID.
338
+
339
+ Returns
340
+ -------
341
+ str
342
+ The API string formatted.
343
+ """
344
+ if not entity_type.endswith("s"):
345
+ entity_type += "s"
346
+ return f"{API_BASE}/{entity_type}/{entity_id}"
@@ -0,0 +1,82 @@
1
+ from __future__ import annotations
2
+
3
+ from digitalhub.utils.generic_utils import dict_to_json
4
+
5
+
6
+ class ModelObj:
7
+ """
8
+ Base class for all entities.
9
+ It implements to_dict abd to_json method to represent
10
+ the object as a dictionary/json and an any_setter method to
11
+ set generic attributes coming from a constructor.
12
+ """
13
+
14
+ def to_dict(self) -> dict:
15
+ """
16
+ Return object as dict with all non private keys.
17
+
18
+ Returns
19
+ -------
20
+ dict
21
+ A dictionary containing the attributes of the entity instance.
22
+ """
23
+ obj = {}
24
+ for key, value in self.__dict__.items():
25
+ if not key.startswith("_") and value is not None:
26
+ if hasattr(value, "to_dict"):
27
+ sub_dict = value.to_dict()
28
+ if sub_dict:
29
+ obj[key] = sub_dict
30
+ else:
31
+ obj[key] = value
32
+ return obj
33
+
34
+ def to_json(self) -> str:
35
+ """
36
+ Return object as json with all non private keys.
37
+
38
+ Returns
39
+ -------
40
+ str
41
+ A json string containing the attributes of the entity instance.
42
+ """
43
+ return dict_to_json(self.to_dict())
44
+
45
+ def _any_setter(self, **kwargs) -> None:
46
+ """
47
+ Set any attribute of the object.
48
+
49
+ Parameters
50
+ ----------
51
+ **kwargs : dict
52
+ Keyword arguments to be set as attributes.
53
+
54
+ Returns
55
+ -------
56
+ None
57
+ """
58
+ for k, v in kwargs.items():
59
+ if k not in self.__dict__:
60
+ setattr(self, k, v)
61
+
62
+ def _get_private_attrs(self) -> dict:
63
+ """
64
+ Return all private attributes of the object.
65
+
66
+ Returns
67
+ -------
68
+ dict
69
+ A dictionary containing the private attributes of the entity instance.
70
+ """
71
+ return {k: v for k, v in self.__dict__.items() if k.startswith("_")}
72
+
73
+ def __repr__(self) -> str:
74
+ """
75
+ Return string representation of the entity object.
76
+
77
+ Returns
78
+ -------
79
+ str
80
+ A string representing the entity instance.
81
+ """
82
+ return str(self.to_dict())