digitalhub 0.13.1__py3-none-any.whl → 0.13.3__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/context/context.py +12 -0
- digitalhub/entities/_base/material/entity.py +4 -0
- digitalhub/entities/_base/material/utils.py +27 -0
- digitalhub/entities/dataitem/table/entity.py +3 -0
- digitalhub/stores/credentials/configurator.py +2 -1
- digitalhub/stores/data/s3/configurator.py +2 -2
- digitalhub/stores/readers/data/pandas/reader.py +9 -3
- {digitalhub-0.13.1.dist-info → digitalhub-0.13.3.dist-info}/METADATA +1 -1
- {digitalhub-0.13.1.dist-info → digitalhub-0.13.3.dist-info}/RECORD +12 -12
- {digitalhub-0.13.1.dist-info → digitalhub-0.13.3.dist-info}/WHEEL +0 -0
- {digitalhub-0.13.1.dist-info → digitalhub-0.13.3.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.13.1.dist-info → digitalhub-0.13.3.dist-info}/licenses/LICENSE +0 -0
digitalhub/context/context.py
CHANGED
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
+
import os
|
|
7
8
|
import typing
|
|
8
9
|
from pathlib import Path
|
|
9
10
|
|
|
11
|
+
from digitalhub.runtimes.enums import RuntimeEnvVar
|
|
12
|
+
|
|
10
13
|
if typing.TYPE_CHECKING:
|
|
11
14
|
from digitalhub.entities.project._base.entity import Project
|
|
12
15
|
from digitalhub.stores.client._base.client import Client
|
|
@@ -47,6 +50,15 @@ class Context:
|
|
|
47
50
|
|
|
48
51
|
self.is_running: bool = False
|
|
49
52
|
self._run_ctx: str | None = None
|
|
53
|
+
self._search_run_ctx()
|
|
54
|
+
|
|
55
|
+
def _search_run_ctx(self) -> None:
|
|
56
|
+
"""
|
|
57
|
+
Search for an existing run id in env.
|
|
58
|
+
"""
|
|
59
|
+
run_id = os.getenv(RuntimeEnvVar.RUN_ID.value)
|
|
60
|
+
if run_id is not None:
|
|
61
|
+
self.set_run(run_id)
|
|
50
62
|
|
|
51
63
|
def set_run(self, run_ctx: str) -> None:
|
|
52
64
|
"""
|
|
@@ -7,6 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
|
|
10
|
+
from digitalhub.entities._base.material.utils import refresh_decorator
|
|
10
11
|
from digitalhub.entities._base.versioned.entity import VersionedEntity
|
|
11
12
|
from digitalhub.entities._processors.context import context_processor
|
|
12
13
|
from digitalhub.stores.data.api import get_store
|
|
@@ -72,6 +73,7 @@ class MaterialEntity(VersionedEntity):
|
|
|
72
73
|
# I/O Methods
|
|
73
74
|
##############################
|
|
74
75
|
|
|
76
|
+
@refresh_decorator
|
|
75
77
|
def as_file(self) -> list[str]:
|
|
76
78
|
"""
|
|
77
79
|
Get object as file(s). It downloads the object from storage in
|
|
@@ -86,6 +88,7 @@ class MaterialEntity(VersionedEntity):
|
|
|
86
88
|
dst = store._build_temp()
|
|
87
89
|
return store.download(self.spec.path, dst=dst)
|
|
88
90
|
|
|
91
|
+
@refresh_decorator
|
|
89
92
|
def download(
|
|
90
93
|
self,
|
|
91
94
|
destination: str | None = None,
|
|
@@ -130,6 +133,7 @@ class MaterialEntity(VersionedEntity):
|
|
|
130
133
|
|
|
131
134
|
return store.download(self.spec.path, dst, overwrite=overwrite)
|
|
132
135
|
|
|
136
|
+
@refresh_decorator
|
|
133
137
|
def upload(self, source: SourcesOrListOfSources) -> None:
|
|
134
138
|
"""
|
|
135
139
|
Upload object from given local path to spec path destination.
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
+
import typing
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
|
|
9
10
|
from digitalhub.stores.data.api import get_default_store
|
|
11
|
+
from digitalhub.utils.exceptions import BackendError
|
|
10
12
|
from digitalhub.utils.file_utils import eval_zip_type
|
|
11
13
|
from digitalhub.utils.uri_utils import has_local_scheme
|
|
12
14
|
|
|
@@ -108,3 +110,28 @@ def build_log_path_from_source(
|
|
|
108
110
|
path += f"/{Path(source).name}"
|
|
109
111
|
|
|
110
112
|
return path
|
|
113
|
+
|
|
114
|
+
def refresh_decorator(fn: typing.Callable) -> typing.Callable:
|
|
115
|
+
"""
|
|
116
|
+
Refresh decorator.
|
|
117
|
+
|
|
118
|
+
Parameters
|
|
119
|
+
----------
|
|
120
|
+
fn : Callable
|
|
121
|
+
Function to decorate.
|
|
122
|
+
|
|
123
|
+
Returns
|
|
124
|
+
-------
|
|
125
|
+
Callable
|
|
126
|
+
Decorated function.
|
|
127
|
+
"""
|
|
128
|
+
|
|
129
|
+
def wrapper(self, *args, **kwargs):
|
|
130
|
+
# Prevent rising error if entity is not yet created in backend
|
|
131
|
+
try:
|
|
132
|
+
self.refresh()
|
|
133
|
+
except BackendError:
|
|
134
|
+
pass
|
|
135
|
+
return fn(self, *args, **kwargs)
|
|
136
|
+
|
|
137
|
+
return wrapper
|
|
@@ -9,6 +9,7 @@ import typing
|
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
from typing import Any
|
|
11
11
|
|
|
12
|
+
from digitalhub.entities._base.material.utils import refresh_decorator
|
|
12
13
|
from digitalhub.entities.dataitem._base.entity import Dataitem
|
|
13
14
|
from digitalhub.stores.data.api import get_store
|
|
14
15
|
from digitalhub.utils.uri_utils import has_sql_scheme
|
|
@@ -65,6 +66,7 @@ class DataitemTable(Dataitem):
|
|
|
65
66
|
self._query = query
|
|
66
67
|
return self
|
|
67
68
|
|
|
69
|
+
@refresh_decorator
|
|
68
70
|
def as_df(
|
|
69
71
|
self,
|
|
70
72
|
file_format: str | None = None,
|
|
@@ -107,6 +109,7 @@ class DataitemTable(Dataitem):
|
|
|
107
109
|
**kwargs,
|
|
108
110
|
)
|
|
109
111
|
|
|
112
|
+
@refresh_decorator
|
|
110
113
|
def write_df(
|
|
111
114
|
self,
|
|
112
115
|
df: Any,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
-
from datetime import datetime, timezone
|
|
7
|
+
from datetime import datetime, timedelta, timezone
|
|
8
8
|
|
|
9
9
|
from botocore.config import Config
|
|
10
10
|
|
|
@@ -111,5 +111,5 @@ class S3StoreConfigurator(Configurator):
|
|
|
111
111
|
return False
|
|
112
112
|
dt = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%SZ")
|
|
113
113
|
dt = dt.replace(tzinfo=timezone.utc)
|
|
114
|
-
now = datetime.now(timezone.utc) +
|
|
114
|
+
now = datetime.now(timezone.utc) + timedelta(seconds=120)
|
|
115
115
|
return dt < now
|
|
@@ -133,7 +133,9 @@ class DataframeReaderPandas(DataframeReader):
|
|
|
133
133
|
-------
|
|
134
134
|
None
|
|
135
135
|
"""
|
|
136
|
-
|
|
136
|
+
if "index" not in kwargs:
|
|
137
|
+
kwargs["index"] = False
|
|
138
|
+
df.to_csv(dst, **kwargs)
|
|
137
139
|
|
|
138
140
|
@staticmethod
|
|
139
141
|
def write_parquet(df: pd.DataFrame, dst: str | BytesIO, **kwargs) -> None:
|
|
@@ -153,7 +155,9 @@ class DataframeReaderPandas(DataframeReader):
|
|
|
153
155
|
-------
|
|
154
156
|
None
|
|
155
157
|
"""
|
|
156
|
-
|
|
158
|
+
if "index" not in kwargs:
|
|
159
|
+
kwargs["index"] = False
|
|
160
|
+
df.to_parquet(dst, **kwargs)
|
|
157
161
|
|
|
158
162
|
@staticmethod
|
|
159
163
|
def write_table(df: pd.DataFrame, table: str, engine: Any, schema: str | None = None, **kwargs) -> None:
|
|
@@ -177,7 +181,9 @@ class DataframeReaderPandas(DataframeReader):
|
|
|
177
181
|
-------
|
|
178
182
|
None
|
|
179
183
|
"""
|
|
180
|
-
|
|
184
|
+
if "index" not in kwargs:
|
|
185
|
+
kwargs["index"] = False
|
|
186
|
+
df.to_sql(table, engine, schema=schema, **kwargs)
|
|
181
187
|
|
|
182
188
|
##############################
|
|
183
189
|
# Utils
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: digitalhub
|
|
3
|
-
Version: 0.13.
|
|
3
|
+
Version: 0.13.3
|
|
4
4
|
Summary: Python SDK for Digitalhub
|
|
5
5
|
Project-URL: Homepage, https://github.com/scc-digitalhub/digitalhub-sdk
|
|
6
6
|
Author-email: Fondazione Bruno Kessler <digitalhub@fbk.eu>, Matteo Martini <mmartini@fbk.eu>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
digitalhub/__init__.py,sha256=JrwZhABki1rBFSP3uHBJOckWQiF213_UXuJRoX7QFHA,2572
|
|
2
2
|
digitalhub/context/api.py,sha256=eIVsYhneu8bEQiUV15sUNlv5WlZu6zV7Dvidvg_0FfA,1500
|
|
3
3
|
digitalhub/context/builder.py,sha256=NM4xcD2n4jXwdTS2hl3MAobf-BVUQH-9LB6U3J_F3pM,2826
|
|
4
|
-
digitalhub/context/context.py,sha256=
|
|
4
|
+
digitalhub/context/context.py,sha256=IXgrLtI6nKp0S9XclqiyiMcsbkTVveNVkkVnURBFvFc,2569
|
|
5
5
|
digitalhub/entities/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
6
6
|
digitalhub/entities/builders.py,sha256=I-RVAFNgnZGmx7Dyz8_n7gfsG-BVgbgfraJal5NWipE,2054
|
|
7
7
|
digitalhub/entities/_base/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
@@ -24,10 +24,10 @@ digitalhub/entities/_base/entity/_constructors/uuid.py,sha256=7QhQ9epJAnYLCKUPY6
|
|
|
24
24
|
digitalhub/entities/_base/executable/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
25
25
|
digitalhub/entities/_base/executable/entity.py,sha256=duxjwi3ROHM4hewYfUzkTpHuETfHQ8WsQ4n3wprj3DA,13321
|
|
26
26
|
digitalhub/entities/_base/material/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
27
|
-
digitalhub/entities/_base/material/entity.py,sha256=
|
|
27
|
+
digitalhub/entities/_base/material/entity.py,sha256=lhqhp5s2tzKW3lj6p_GrI4Y9-JDiadL3p_IBU7H7iSQ,6947
|
|
28
28
|
digitalhub/entities/_base/material/spec.py,sha256=7lF_Pv7zGJUAR2ixmmCt-UPnoASgOLxnb9yffqwBVp8,544
|
|
29
29
|
digitalhub/entities/_base/material/status.py,sha256=vAIb5qti5KxdIPdB9WYmWrCnqwGyUxuF6CpGSpcWxbE,520
|
|
30
|
-
digitalhub/entities/_base/material/utils.py,sha256=
|
|
30
|
+
digitalhub/entities/_base/material/utils.py,sha256=beAcQta_pysWEz8hUBXFBV8dwcxTfFdVKm7-eY74sQ0,3086
|
|
31
31
|
digitalhub/entities/_base/runtime_entity/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
32
32
|
digitalhub/entities/_base/runtime_entity/builder.py,sha256=VvhNKHeMj434q-bMQsoBN_abz2igvQAqIFYQ-abzX8c,2522
|
|
33
33
|
digitalhub/entities/_base/unversioned/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
@@ -77,7 +77,7 @@ digitalhub/entities/dataitem/iceberg/spec.py,sha256=vtfaV9OE1WBKTtTHoYSdMnjQfUey
|
|
|
77
77
|
digitalhub/entities/dataitem/iceberg/status.py,sha256=HMBNAzqQplUxmnnIVb57cCcjhmUQ1v8K3wAGUnYdRlA,310
|
|
78
78
|
digitalhub/entities/dataitem/table/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
79
79
|
digitalhub/entities/dataitem/table/builder.py,sha256=FoXrW09HXCZ0XNnCPHNSZs_iLrIG_8WPCZo_5Vq6_YI,824
|
|
80
|
-
digitalhub/entities/dataitem/table/entity.py,sha256=
|
|
80
|
+
digitalhub/entities/dataitem/table/entity.py,sha256=qhv6BXOm_zd68tHeOckgkyWHFtwn7HH36dMkw5QUjsI,4331
|
|
81
81
|
digitalhub/entities/dataitem/table/models.py,sha256=5wqwm4GQjikdJVtDPEn5hwUR_FWxW_7hwIf-GLikqjQ,1269
|
|
82
82
|
digitalhub/entities/dataitem/table/spec.py,sha256=oYgh5XqFrdzIpGxXe1FW5bsGlFHokUJdHJSamuyFs4k,779
|
|
83
83
|
digitalhub/entities/dataitem/table/status.py,sha256=_-_UrcPZh3maGENDZ99pLA8Gz1yrXapvsxs_lPI1skw,306
|
|
@@ -209,7 +209,7 @@ digitalhub/stores/client/local/key_builder.py,sha256=ijISHvPcMyx591gHlSP1IZdiRrF
|
|
|
209
209
|
digitalhub/stores/client/local/params_builder.py,sha256=_hR4bwn0bpGc74iKb3PM3WUJ6s3GAgsc1zcXoWjy560,3589
|
|
210
210
|
digitalhub/stores/credentials/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
211
211
|
digitalhub/stores/credentials/api.py,sha256=mwClY8tCG62eAhbwrmK-kzYQzEJ5ZmCW52WmYsQ-004,738
|
|
212
|
-
digitalhub/stores/credentials/configurator.py,sha256=
|
|
212
|
+
digitalhub/stores/credentials/configurator.py,sha256=RbvkmHyf_vhLC3WamNEjC6V6NtqfSXQMuONEj4pyGwk,5505
|
|
213
213
|
digitalhub/stores/credentials/enums.py,sha256=uRJ6af0ujk3Ki4DXM9rFqBROyhlbf4EYNWml_CSdJL8,1665
|
|
214
214
|
digitalhub/stores/credentials/handler.py,sha256=CHrs3vmTkCQrtTenvVQ9QlRIntyrOOqZN-9BBJFG6JI,4355
|
|
215
215
|
digitalhub/stores/credentials/ini_module.py,sha256=ouHCGuAA_odbpKJKuwfCQMt40jRCCh9wLID_HucKo5o,3750
|
|
@@ -225,7 +225,7 @@ digitalhub/stores/data/local/store.py,sha256=_XuIp3HpEa7hxxMfQhK05EscPA_RBiQyb61
|
|
|
225
225
|
digitalhub/stores/data/remote/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
226
226
|
digitalhub/stores/data/remote/store.py,sha256=DTrBW62zc1ix7UbLnY6YeqN0_8kGeUH_h9k7Br2HY3k,6130
|
|
227
227
|
digitalhub/stores/data/s3/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
228
|
-
digitalhub/stores/data/s3/configurator.py,sha256=
|
|
228
|
+
digitalhub/stores/data/s3/configurator.py,sha256=BDgvjlD3ES-Ri01ncq87cQtxvOa4u3_MYR81yZMZ35A,3703
|
|
229
229
|
digitalhub/stores/data/s3/store.py,sha256=hwcvTkKaBWcCc7fDGuoddgT2v5b8Jr5LtTojja9tdZ8,19583
|
|
230
230
|
digitalhub/stores/data/s3/utils.py,sha256=jCzXp9X2tnF3iHRSmvfnp1e5ahbZkMaMMC35FfysFZw,1894
|
|
231
231
|
digitalhub/stores/data/sql/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
@@ -240,7 +240,7 @@ digitalhub/stores/readers/data/_base/builder.py,sha256=N_e5qlGrxyqnyr8F7SvbSLrgt
|
|
|
240
240
|
digitalhub/stores/readers/data/_base/reader.py,sha256=q6s37uI_2J1cJlpvRzwr2Az8aD9lDsKvzbi82CUO3PU,1862
|
|
241
241
|
digitalhub/stores/readers/data/pandas/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
242
242
|
digitalhub/stores/readers/data/pandas/builder.py,sha256=ucnW7ReZgQ9XmGifYMkaDxpBVc_0XMMazOyPnUlY4os,804
|
|
243
|
-
digitalhub/stores/readers/data/pandas/reader.py,sha256=
|
|
243
|
+
digitalhub/stores/readers/data/pandas/reader.py,sha256=LLbp_tWSmyQizM8ULpiax3rl7bIfSs5SwVc13afNS5E,8260
|
|
244
244
|
digitalhub/stores/readers/query/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
245
245
|
digitalhub/utils/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
|
|
246
246
|
digitalhub/utils/enums.py,sha256=FvvBBkryy2-Ji0MhBMeJC6oLnd_ba0b0y1uCcWT-mvU,377
|
|
@@ -252,8 +252,8 @@ digitalhub/utils/io_utils.py,sha256=p2K9VFJGzl3PmXc7GfXKZkPyg5hImduvXlfYVpnsMck,
|
|
|
252
252
|
digitalhub/utils/logger.py,sha256=hH3gGE35L8jRxrg8EPXGZZAK1OA5-CvWnayuBZzteBM,545
|
|
253
253
|
digitalhub/utils/types.py,sha256=orCxY43zXMJfKZsOj6FUR85u9wRBPJ0wdkzrBHTnVW8,217
|
|
254
254
|
digitalhub/utils/uri_utils.py,sha256=Go787CxAOo2MMjFIEt8XssomtyV8vTdIrpyjSQK3gAM,4408
|
|
255
|
-
digitalhub-0.13.
|
|
256
|
-
digitalhub-0.13.
|
|
257
|
-
digitalhub-0.13.
|
|
258
|
-
digitalhub-0.13.
|
|
259
|
-
digitalhub-0.13.
|
|
255
|
+
digitalhub-0.13.3.dist-info/METADATA,sha256=tMGK821-isSqCg_7khZzbRbGZlYy2WEe4MmUwM4RWuY,18026
|
|
256
|
+
digitalhub-0.13.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
257
|
+
digitalhub-0.13.3.dist-info/licenses/AUTHORS,sha256=iDleK_2EAMmh0o8Te_E9mdXQCP4rBfFr9dW9d0-pCno,301
|
|
258
|
+
digitalhub-0.13.3.dist-info/licenses/LICENSE,sha256=z3xQCHfGmTnigfoUe3uidW_GUSVeFBdos30w9VNTRec,11361
|
|
259
|
+
digitalhub-0.13.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|