warpzone-sdk 15.0.1.dev1__py3-none-any.whl → 15.1.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.
- warpzone/db/client.py +11 -6
- warpzone/deltastorage/store.py +14 -4
- warpzone/deltastorage/table.py +17 -4
- warpzone/monitor/traces.py +0 -7
- {warpzone_sdk-15.0.1.dev1.dist-info → warpzone_sdk-15.1.0.dist-info}/METADATA +1 -1
- {warpzone_sdk-15.0.1.dev1.dist-info → warpzone_sdk-15.1.0.dist-info}/RECORD +7 -7
- {warpzone_sdk-15.0.1.dev1.dist-info → warpzone_sdk-15.1.0.dist-info}/WHEEL +0 -0
warpzone/db/client.py
CHANGED
|
@@ -170,6 +170,7 @@ class WarpzoneDatabaseClient:
|
|
|
170
170
|
time_interval: Optional[pdz.TimeInterval] = None,
|
|
171
171
|
time_travel: Optional[pdz.TimeTravel] = None,
|
|
172
172
|
filters: Optional[dict[str, object]] = None,
|
|
173
|
+
columns: Optional[list[str]] = None,
|
|
173
174
|
include_validity_period_columns: bool = False,
|
|
174
175
|
include_generated_columns: bool = False,
|
|
175
176
|
) -> pd.DataFrame:
|
|
@@ -188,13 +189,18 @@ class WarpzoneDatabaseClient:
|
|
|
188
189
|
filters (Optional[dict[str, object]], optional): Filters to apply to the
|
|
189
190
|
query.
|
|
190
191
|
Defaults to None.
|
|
192
|
+
columns (Optional[list[str]], optional): Columns to return.
|
|
193
|
+
Selecting columns can significantly improve query performance.
|
|
194
|
+
Defaults to None, meaning all columns will be returned.
|
|
191
195
|
include_validity_period_columns (bool, optional): Whether to include
|
|
192
196
|
validity period columns in the result;
|
|
193
|
-
(
|
|
194
|
-
Defaults to False.
|
|
197
|
+
(`valid_from_time_utc`, `valid_to_time_utc`).
|
|
198
|
+
Defaults to False. If set to True while using `columns`-argument, make sure
|
|
199
|
+
to include these columns in the `columns`-list.
|
|
195
200
|
include_generated_columns (bool, optional): Whether to include generated
|
|
196
201
|
columns in the result; (e.g. `valid_from_time_utc`, `valid_to_time_utc`).
|
|
197
|
-
Defaults to False.
|
|
202
|
+
Defaults to False. If set to True while using `columns`-argument, make sure
|
|
203
|
+
to include these columns in the `columns`-list.
|
|
198
204
|
|
|
199
205
|
Returns:
|
|
200
206
|
pd.DataFrame: The result of the query.
|
|
@@ -214,7 +220,6 @@ class WarpzoneDatabaseClient:
|
|
|
214
220
|
hyper_slice.append((key, "in", value))
|
|
215
221
|
else:
|
|
216
222
|
hyper_slice.append((key, "=", value))
|
|
217
|
-
|
|
218
223
|
if time_interval:
|
|
219
224
|
hyper_slice.append(("time_utc", ">=", time_interval.left))
|
|
220
225
|
hyper_slice.append(("time_utc", "<=", time_interval.right))
|
|
@@ -230,9 +235,9 @@ class WarpzoneDatabaseClient:
|
|
|
230
235
|
valid_from_column="valid_from_time_utc",
|
|
231
236
|
valid_to_column="valid_to_time_utc",
|
|
232
237
|
)
|
|
233
|
-
hyper_slice.extend(tt_filter)
|
|
234
238
|
|
|
235
|
-
|
|
239
|
+
hyper_slice.extend(tt_filter)
|
|
240
|
+
pl_df = table.read(hyper_slice=HyperSlice(hyper_slice), columns=columns)
|
|
236
241
|
|
|
237
242
|
pd_df = pl_df.to_pandas()
|
|
238
243
|
|
warpzone/deltastorage/store.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
|
2
2
|
|
|
3
3
|
import deltalake as dl
|
|
4
4
|
import obstore as obs
|
|
5
|
+
from deltalake.exceptions import TableNotFoundError as DeltaTableNotFoundError
|
|
5
6
|
|
|
6
7
|
from .schema import Schema
|
|
7
8
|
from .table import Table
|
|
@@ -76,10 +77,19 @@ class Store:
|
|
|
76
77
|
Args:
|
|
77
78
|
table_name (str): Table name
|
|
78
79
|
"""
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
# For some reason `deltalake.DeltaTable.is_deltatable()` can be very slow.
|
|
81
|
+
# deltalake has an issue open about this:
|
|
82
|
+
# https://github.com/delta-io/delta-rs/issues/3942
|
|
83
|
+
# For now we catch the exception when trying to load the table
|
|
84
|
+
try:
|
|
85
|
+
_ = dl.DeltaTable(
|
|
86
|
+
table_uri=self._get_table_uri(table_name),
|
|
87
|
+
storage_options=self.storage_options,
|
|
88
|
+
without_files=True,
|
|
89
|
+
)
|
|
90
|
+
except DeltaTableNotFoundError:
|
|
91
|
+
return False
|
|
92
|
+
return True
|
|
83
93
|
|
|
84
94
|
def create_table(
|
|
85
95
|
self,
|
warpzone/deltastorage/table.py
CHANGED
|
@@ -42,6 +42,7 @@ class Table:
|
|
|
42
42
|
self.storage_options = storage_options
|
|
43
43
|
|
|
44
44
|
self.table_name = self.table_uri.split("/")[-1]
|
|
45
|
+
self._delta_table = None
|
|
45
46
|
|
|
46
47
|
def __repr__(self):
|
|
47
48
|
return f"Table('{self.table_name}')"
|
|
@@ -49,12 +50,21 @@ class Table:
|
|
|
49
50
|
@property
|
|
50
51
|
def delta_table(self) -> dl.DeltaTable:
|
|
51
52
|
"""Get the Delta table object.
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
As the `Table`-class is lazily initialized,
|
|
54
|
+
the `delta_table`-property is initialized on the first access
|
|
55
|
+
and saved for future use to minimize overhead.
|
|
56
|
+
It is *important* that this property is only initialized within
|
|
57
|
+
a lock when doing concurrent reads/writes
|
|
58
|
+
and not initialized when creating the `Table`-object.
|
|
59
|
+
This is important because using the same instance can lead to transaction
|
|
54
60
|
issues in delta as DeltaTable uses metadata (transaction id) from
|
|
55
61
|
the first time the object is instantiated.
|
|
56
62
|
"""
|
|
57
|
-
|
|
63
|
+
if self._delta_table is None:
|
|
64
|
+
self._delta_table = dl.DeltaTable(
|
|
65
|
+
self.table_uri, storage_options=self.storage_options
|
|
66
|
+
)
|
|
67
|
+
return self._delta_table
|
|
58
68
|
|
|
59
69
|
def partition_cols(self) -> list[str]:
|
|
60
70
|
"""Get the partition columns of the table"""
|
|
@@ -65,7 +75,9 @@ class Table:
|
|
|
65
75
|
pa_schema = pa.schema(self.delta_table.schema())
|
|
66
76
|
return Schema.from_arrow(pa_schema)
|
|
67
77
|
|
|
68
|
-
def read(
|
|
78
|
+
def read(
|
|
79
|
+
self, hyper_slice: Optional[HyperSlice] = None, columns=None
|
|
80
|
+
) -> pl.DataFrame:
|
|
69
81
|
"""Read from Delta table
|
|
70
82
|
|
|
71
83
|
Args:
|
|
@@ -88,6 +100,7 @@ class Table:
|
|
|
88
100
|
partition_filters = [f for f in hyper_slice if f[0] in partition_cols]
|
|
89
101
|
|
|
90
102
|
pyarrow_table_existing_data = delta_table.to_pyarrow_table(
|
|
103
|
+
columns=columns,
|
|
91
104
|
partitions=partition_filters,
|
|
92
105
|
filters=file_filters,
|
|
93
106
|
)
|
warpzone/monitor/traces.py
CHANGED
|
@@ -23,13 +23,6 @@ TRACING_IS_CONFIGURED = False
|
|
|
23
23
|
|
|
24
24
|
def configure_tracing():
|
|
25
25
|
global TRACING_IS_CONFIGURED
|
|
26
|
-
if TRACING_IS_CONFIGURED:
|
|
27
|
-
# tracing should only be set up once
|
|
28
|
-
# to avoid duplicated trace handling.
|
|
29
|
-
# Global variables is the pattern used
|
|
30
|
-
# by opentelemetry, so we use the same
|
|
31
|
-
return
|
|
32
|
-
|
|
33
26
|
# Add thread locking to avoid race conditions during setup
|
|
34
27
|
with _TRACING_LOCK:
|
|
35
28
|
if TRACING_IS_CONFIGURED:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: warpzone-sdk
|
|
3
|
-
Version: 15.
|
|
3
|
+
Version: 15.1.0
|
|
4
4
|
Summary: The main objective of this package is to centralize logic used to interact with Azure Functions, Azure Service Bus and Azure Table Storage
|
|
5
5
|
Author: Team Enigma
|
|
6
6
|
Author-email: enigma@energinet.dk
|
|
@@ -2,15 +2,15 @@ warpzone/__init__.py,sha256=Ay7znIadokCdHHqsPlWAqhdg-zdWhXHNtxVinViYm7o,1533
|
|
|
2
2
|
warpzone/blobstorage/__init__.py,sha256=lnc0uiaGLF0qMi_rWhCpRSFvaj0CJEiMCAl6Yqn1ZiA,21
|
|
3
3
|
warpzone/blobstorage/client.py,sha256=YwDV83acoCeHS_D_ydsTYwnf56rSTy9CKpsxqeoXmBs,4638
|
|
4
4
|
warpzone/db/__init__.py,sha256=lnc0uiaGLF0qMi_rWhCpRSFvaj0CJEiMCAl6Yqn1ZiA,21
|
|
5
|
-
warpzone/db/client.py,sha256=
|
|
5
|
+
warpzone/db/client.py,sha256=tqY_ANThnO72rBaB4sydigLhlSFwCmadg_6rVZwjO8M,9688
|
|
6
6
|
warpzone/deltastorage/__init__.py,sha256=cV8sGT2N_N5Z-E179NMW5O7q3FUDrb3j5f-yVNlNPv0,152
|
|
7
7
|
warpzone/deltastorage/data_types.py,sha256=tWjLO_0ig7-tYxSHShvrd0znA7FFDnS-wBuFClUQG2U,2059
|
|
8
8
|
warpzone/deltastorage/generated_columns.py,sha256=Dr_bihM7v9JKCgBXxc3JQC2P2mUGobXsReRKOl6jDO4,4765
|
|
9
9
|
warpzone/deltastorage/lock_client.py,sha256=z19ub2ahsUHdcriRmgLOxO6zGOGadxF6NmNAhcGp9Lg,9024
|
|
10
10
|
warpzone/deltastorage/schema.py,sha256=AhkJnsB9oX3HVwoCUWcYSdD1zwouT2wj5XydXgU5WEA,4483
|
|
11
11
|
warpzone/deltastorage/slicing.py,sha256=r4Fbg8HHBkZlrYEC847yq86caCTTE02JzpnY_TqI_MA,638
|
|
12
|
-
warpzone/deltastorage/store.py,sha256=
|
|
13
|
-
warpzone/deltastorage/table.py,sha256=
|
|
12
|
+
warpzone/deltastorage/store.py,sha256=LwoDXk0xtQuzfMbqv_ldIRh-9RzA-Hx9NRhtBmlbWB8,4812
|
|
13
|
+
warpzone/deltastorage/table.py,sha256=_5tBQEKnimNWsAWyVhGjuX_3pllqzakkMrvALw6-2Qw,5713
|
|
14
14
|
warpzone/enums/__init__.py,sha256=Gvd-EeZc5jWu5WdusYe3i3Zyt1v85CljBK_EJu7EwZk,24
|
|
15
15
|
warpzone/enums/topicenum.py,sha256=cj9F7kYzwvDeHN5jJXwgnHXTh6E64VwRNpFepNthIyk,213
|
|
16
16
|
warpzone/function/__init__.py,sha256=rJOZBpWsUgjMc7YtXMJ1rLGm45KB1AhDJ_Y2ISiSISc,35
|
|
@@ -29,7 +29,7 @@ warpzone/healthchecks/__init__.py,sha256=9gc_Mt2szs8sDSwy0V4l3JZ6d9hX41xTpZCkDP2
|
|
|
29
29
|
warpzone/healthchecks/model.py,sha256=mM7DnrirLbUpBPPfi82MUPP654D0eOR2_F65TmzsPD0,1187
|
|
30
30
|
warpzone/monitor/__init__.py,sha256=gXT2cxR4tlZER54zd7D49ZQBVyitLaqj13_cUoILuyM,109
|
|
31
31
|
warpzone/monitor/logs.py,sha256=q3SUQCtG1ii0B9GkVs2l8kgZ5b5bI2qI6L0SoOW2QTY,3147
|
|
32
|
-
warpzone/monitor/traces.py,sha256=
|
|
32
|
+
warpzone/monitor/traces.py,sha256=Xc_po1LxJFy5jtNWxIVphIInl_d89Zw3Rb21PsdQhQA,4170
|
|
33
33
|
warpzone/servicebus/data/__init__.py,sha256=lnc0uiaGLF0qMi_rWhCpRSFvaj0CJEiMCAl6Yqn1ZiA,21
|
|
34
34
|
warpzone/servicebus/data/client.py,sha256=zECS3JwedhYnDk8PntYgIYpBF_uu9YN38KzpPFK7CKs,6511
|
|
35
35
|
warpzone/servicebus/events/__init__.py,sha256=lnc0uiaGLF0qMi_rWhCpRSFvaj0CJEiMCAl6Yqn1ZiA,21
|
|
@@ -52,6 +52,6 @@ warpzone/tools/copy.py,sha256=5fddotMZkXZO8avzUbGOhvs0cp8mce95pNpy0oPVjnQ,2596
|
|
|
52
52
|
warpzone/transform/__init__.py,sha256=ruGa7tl-v4ndlWpULE1jSGU_a4_iRc3V6eyNr5xKP9E,27
|
|
53
53
|
warpzone/transform/data.py,sha256=Abb8PcrgMbbNCJkkIUdtrTHdlY0OfXid387qw1nDpFY,2362
|
|
54
54
|
warpzone/transform/schema.py,sha256=nbSQtDMvXkyqGKuwhuFCF0WsEDsaNyoPYpMKvbsKlv8,2423
|
|
55
|
-
warpzone_sdk-15.
|
|
56
|
-
warpzone_sdk-15.
|
|
57
|
-
warpzone_sdk-15.
|
|
55
|
+
warpzone_sdk-15.1.0.dist-info/METADATA,sha256=q0pdO2gAFw7uT3fTYGgBfLeFDOyQstIvEQR-3qfKZb8,7279
|
|
56
|
+
warpzone_sdk-15.1.0.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
|
|
57
|
+
warpzone_sdk-15.1.0.dist-info/RECORD,,
|
|
File without changes
|