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.
- digitalhub/__init__.py +62 -94
- digitalhub/client/__init__.py +0 -0
- digitalhub/client/builder.py +105 -0
- digitalhub/client/objects/__init__.py +0 -0
- digitalhub/client/objects/base.py +56 -0
- digitalhub/client/objects/dhcore.py +681 -0
- digitalhub/client/objects/local.py +533 -0
- digitalhub/context/__init__.py +0 -0
- digitalhub/context/builder.py +178 -0
- digitalhub/context/context.py +136 -0
- digitalhub/datastores/__init__.py +0 -0
- digitalhub/datastores/builder.py +134 -0
- digitalhub/datastores/objects/__init__.py +0 -0
- digitalhub/datastores/objects/base.py +85 -0
- digitalhub/datastores/objects/local.py +42 -0
- digitalhub/datastores/objects/remote.py +23 -0
- digitalhub/datastores/objects/s3.py +38 -0
- digitalhub/datastores/objects/sql.py +60 -0
- digitalhub/entities/__init__.py +0 -0
- digitalhub/entities/_base/__init__.py +0 -0
- digitalhub/entities/_base/api.py +346 -0
- digitalhub/entities/_base/base.py +82 -0
- digitalhub/entities/_base/crud.py +610 -0
- digitalhub/entities/_base/entity/__init__.py +0 -0
- digitalhub/entities/_base/entity/base.py +132 -0
- digitalhub/entities/_base/entity/context.py +118 -0
- digitalhub/entities/_base/entity/executable.py +380 -0
- digitalhub/entities/_base/entity/material.py +214 -0
- digitalhub/entities/_base/entity/unversioned.py +87 -0
- digitalhub/entities/_base/entity/versioned.py +94 -0
- digitalhub/entities/_base/metadata.py +59 -0
- digitalhub/entities/_base/spec/__init__.py +0 -0
- digitalhub/entities/_base/spec/base.py +58 -0
- digitalhub/entities/_base/spec/material.py +22 -0
- digitalhub/entities/_base/state.py +31 -0
- digitalhub/entities/_base/status/__init__.py +0 -0
- digitalhub/entities/_base/status/base.py +32 -0
- digitalhub/entities/_base/status/material.py +49 -0
- digitalhub/entities/_builders/__init__.py +0 -0
- digitalhub/entities/_builders/metadata.py +60 -0
- digitalhub/entities/_builders/name.py +31 -0
- digitalhub/entities/_builders/spec.py +43 -0
- digitalhub/entities/_builders/status.py +62 -0
- digitalhub/entities/_builders/uuid.py +33 -0
- digitalhub/entities/artifact/__init__.py +0 -0
- digitalhub/entities/artifact/builder.py +133 -0
- digitalhub/entities/artifact/crud.py +358 -0
- digitalhub/entities/artifact/entity/__init__.py +0 -0
- digitalhub/entities/artifact/entity/_base.py +39 -0
- digitalhub/entities/artifact/entity/artifact.py +9 -0
- digitalhub/entities/artifact/spec.py +39 -0
- digitalhub/entities/artifact/status.py +15 -0
- digitalhub/entities/dataitem/__init__.py +0 -0
- digitalhub/entities/dataitem/builder.py +144 -0
- digitalhub/entities/dataitem/crud.py +395 -0
- digitalhub/entities/dataitem/entity/__init__.py +0 -0
- digitalhub/entities/dataitem/entity/_base.py +75 -0
- digitalhub/entities/dataitem/entity/dataitem.py +9 -0
- digitalhub/entities/dataitem/entity/iceberg.py +7 -0
- digitalhub/entities/dataitem/entity/table.py +125 -0
- digitalhub/entities/dataitem/models.py +62 -0
- digitalhub/entities/dataitem/spec.py +61 -0
- digitalhub/entities/dataitem/status.py +38 -0
- digitalhub/entities/entity_types.py +19 -0
- digitalhub/entities/function/__init__.py +0 -0
- digitalhub/entities/function/builder.py +86 -0
- digitalhub/entities/function/crud.py +305 -0
- digitalhub/entities/function/entity.py +101 -0
- digitalhub/entities/function/models.py +118 -0
- digitalhub/entities/function/spec.py +81 -0
- digitalhub/entities/function/status.py +9 -0
- digitalhub/entities/model/__init__.py +0 -0
- digitalhub/entities/model/builder.py +152 -0
- digitalhub/entities/model/crud.py +358 -0
- digitalhub/entities/model/entity/__init__.py +0 -0
- digitalhub/entities/model/entity/_base.py +34 -0
- digitalhub/entities/model/entity/huggingface.py +9 -0
- digitalhub/entities/model/entity/mlflow.py +90 -0
- digitalhub/entities/model/entity/model.py +9 -0
- digitalhub/entities/model/entity/sklearn.py +9 -0
- digitalhub/entities/model/models.py +26 -0
- digitalhub/entities/model/spec.py +146 -0
- digitalhub/entities/model/status.py +33 -0
- digitalhub/entities/project/__init__.py +0 -0
- digitalhub/entities/project/builder.py +82 -0
- digitalhub/entities/project/crud.py +350 -0
- digitalhub/entities/project/entity.py +2060 -0
- digitalhub/entities/project/spec.py +50 -0
- digitalhub/entities/project/status.py +9 -0
- digitalhub/entities/registries.py +48 -0
- digitalhub/entities/run/__init__.py +0 -0
- digitalhub/entities/run/builder.py +77 -0
- digitalhub/entities/run/crud.py +232 -0
- digitalhub/entities/run/entity.py +461 -0
- digitalhub/entities/run/spec.py +153 -0
- digitalhub/entities/run/status.py +114 -0
- digitalhub/entities/secret/__init__.py +0 -0
- digitalhub/entities/secret/builder.py +93 -0
- digitalhub/entities/secret/crud.py +294 -0
- digitalhub/entities/secret/entity.py +73 -0
- digitalhub/entities/secret/spec.py +35 -0
- digitalhub/entities/secret/status.py +9 -0
- digitalhub/entities/task/__init__.py +0 -0
- digitalhub/entities/task/builder.py +74 -0
- digitalhub/entities/task/crud.py +241 -0
- digitalhub/entities/task/entity.py +135 -0
- digitalhub/entities/task/models.py +199 -0
- digitalhub/entities/task/spec.py +51 -0
- digitalhub/entities/task/status.py +9 -0
- digitalhub/entities/utils.py +184 -0
- digitalhub/entities/workflow/__init__.py +0 -0
- digitalhub/entities/workflow/builder.py +91 -0
- digitalhub/entities/workflow/crud.py +304 -0
- digitalhub/entities/workflow/entity.py +77 -0
- digitalhub/entities/workflow/spec.py +15 -0
- digitalhub/entities/workflow/status.py +9 -0
- digitalhub/readers/__init__.py +0 -0
- digitalhub/readers/builder.py +54 -0
- digitalhub/readers/objects/__init__.py +0 -0
- digitalhub/readers/objects/base.py +70 -0
- digitalhub/readers/objects/pandas.py +207 -0
- digitalhub/readers/registry.py +15 -0
- digitalhub/registry/__init__.py +0 -0
- digitalhub/registry/models.py +87 -0
- digitalhub/registry/registry.py +74 -0
- digitalhub/registry/utils.py +150 -0
- digitalhub/runtimes/__init__.py +0 -0
- digitalhub/runtimes/base.py +164 -0
- digitalhub/runtimes/builder.py +53 -0
- digitalhub/runtimes/kind_registry.py +170 -0
- digitalhub/stores/__init__.py +0 -0
- digitalhub/stores/builder.py +257 -0
- digitalhub/stores/objects/__init__.py +0 -0
- digitalhub/stores/objects/base.py +189 -0
- digitalhub/stores/objects/local.py +230 -0
- digitalhub/stores/objects/remote.py +143 -0
- digitalhub/stores/objects/s3.py +563 -0
- digitalhub/stores/objects/sql.py +328 -0
- digitalhub/utils/__init__.py +0 -0
- digitalhub/utils/data_utils.py +127 -0
- digitalhub/utils/env_utils.py +123 -0
- digitalhub/utils/exceptions.py +55 -0
- digitalhub/utils/file_utils.py +204 -0
- digitalhub/utils/generic_utils.py +207 -0
- digitalhub/utils/git_utils.py +148 -0
- digitalhub/utils/io_utils.py +79 -0
- digitalhub/utils/logger.py +17 -0
- digitalhub/utils/uri_utils.py +56 -0
- {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/METADATA +27 -12
- digitalhub-0.8.0b1.dist-info/RECORD +161 -0
- test/test_crud_artifacts.py +1 -1
- test/test_crud_dataitems.py +1 -1
- test/test_crud_functions.py +1 -1
- test/test_crud_runs.py +1 -1
- test/test_crud_tasks.py +1 -1
- digitalhub-0.8.0b0.dist-info/RECORD +0 -14
- {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/LICENSE.txt +0 -0
- {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/WHEEL +0 -0
- {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())
|