vavacars-data-utils 1.3.5__tar.gz → 1.3.7__tar.gz
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.
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/PKG-INFO +1 -1
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/setup.cfg +1 -1
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/azure/az_helper.py +17 -1
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/sql/sql_helper.py +74 -10
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vavacars_data_utils.egg-info/PKG-INFO +1 -1
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vavacars_data_utils.egg-info/SOURCES.txt +29 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/README.md +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/pyproject.toml +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/test/utils/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/test/utils/test_strings.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/azure/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/bigquery/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/bigquery/bigquery_helper.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/camunda/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/camunda/camunda_helper.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/email/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/email/email_helper.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/salesforce/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/salesforce/salesforce_helper.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/smartiq/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/smartiq/smartiq_helper.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/smartiq/smartiq_helper_v2.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/sql/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/turkey/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/turkey/dates.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/utils/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/utils/callables.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/utils/comparisons.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/utils/naming.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/utils/singleton.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/utils/strings.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/utils/utils.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/vavaprice/__init__.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/vavaprice/vavaprice_helper.py +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vavacars_data_utils.egg-info/dependency_links.txt +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vavacars_data_utils.egg-info/requires.txt +0 -0
- {vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vavacars_data_utils.egg-info/top_level.txt +0 -0
|
@@ -9,6 +9,7 @@ from azureml.core.authentication import ServicePrincipalAuthentication
|
|
|
9
9
|
from azureml.core.model import Model
|
|
10
10
|
from azureml.data.datapath import DataPath
|
|
11
11
|
|
|
12
|
+
from azure.storage.blob import BlobServiceClient
|
|
12
13
|
|
|
13
14
|
from vava_utils.utils.singleton import singleton
|
|
14
15
|
|
|
@@ -26,7 +27,7 @@ class Az_Helper:
|
|
|
26
27
|
- service_principal_password
|
|
27
28
|
- subscription_id
|
|
28
29
|
- resource_group
|
|
29
|
-
-
|
|
30
|
+
- workspace
|
|
30
31
|
"""
|
|
31
32
|
self.auth = ServicePrincipalAuthentication(
|
|
32
33
|
tenant_id=config["tenant_id"],
|
|
@@ -39,6 +40,9 @@ class Az_Helper:
|
|
|
39
40
|
workspace_name=config["workspace"],
|
|
40
41
|
auth=self.auth,
|
|
41
42
|
)
|
|
43
|
+
self.blob = BlobServiceClient.from_connection_string(
|
|
44
|
+
f"DefaultEndpointsProtocol=https;AccountName={self.account_name};AccountKey={account_key};EndpointSuffix=core.windows.net"
|
|
45
|
+
)
|
|
42
46
|
|
|
43
47
|
def register_model(self, path, name, include_version=True, **kwargs):
|
|
44
48
|
"""
|
|
@@ -258,3 +262,15 @@ class Az_Helper:
|
|
|
258
262
|
tags=tags,
|
|
259
263
|
**kwargs,
|
|
260
264
|
)
|
|
265
|
+
|
|
266
|
+
def write_blob_file(self, container, local_file):
|
|
267
|
+
"""
|
|
268
|
+
Write local file to Azure Blob Storage
|
|
269
|
+
|
|
270
|
+
Parameters:
|
|
271
|
+
container (string): Azure Blob Storage container name
|
|
272
|
+
local_file (string): local file path
|
|
273
|
+
"""
|
|
274
|
+
blob = Datastore.get(self.ws, container)
|
|
275
|
+
blob.upload_files(files=[local_file], target_path=".", overwrite=True)
|
|
276
|
+
|
|
@@ -49,18 +49,39 @@ def get_mysql_helper(host, user, port, database=None, password=None, **kwargs):
|
|
|
49
49
|
return SQL_Helper(engine, engine_type=MYSQL)
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def
|
|
52
|
+
def _get_sqlserver_helper_from_user_password(
|
|
53
|
+
host,
|
|
54
|
+
database,
|
|
55
|
+
user,
|
|
56
|
+
password,
|
|
57
|
+
port,
|
|
58
|
+
db_driver,
|
|
59
|
+
fast_execute_many,
|
|
60
|
+
**kwargs,
|
|
61
|
+
):
|
|
62
|
+
conn_str = urllib.parse.quote_plus(
|
|
63
|
+
f"DRIVER={{{db_driver}}};SERVER={host},{port};DATABASE={database};UID={user};PWD={password}"
|
|
64
|
+
)
|
|
65
|
+
engine = create_engine(
|
|
66
|
+
url=URL.create("mssql+pyodbc", query={"odbc_connect": conn_str}),
|
|
67
|
+
fast_executemany=fast_execute_many,
|
|
68
|
+
pool_pre_ping=True,
|
|
69
|
+
**kwargs,
|
|
70
|
+
)
|
|
71
|
+
return SQL_Helper(engine, engine_type=SQL_SERVER)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _get_sqlserver_helper_from_service_principal(
|
|
53
75
|
host,
|
|
54
76
|
database,
|
|
55
77
|
service_principal_id,
|
|
56
78
|
service_principal_secret,
|
|
57
79
|
tenant_id,
|
|
58
|
-
port
|
|
59
|
-
db_driver
|
|
60
|
-
fast_execute_many
|
|
80
|
+
port,
|
|
81
|
+
db_driver,
|
|
82
|
+
fast_execute_many,
|
|
61
83
|
**kwargs,
|
|
62
84
|
):
|
|
63
|
-
|
|
64
85
|
creds = ConfidentialClientApplication(
|
|
65
86
|
client_id=service_principal_id,
|
|
66
87
|
client_credential=service_principal_secret,
|
|
@@ -89,6 +110,49 @@ def get_sqlserver_helper(
|
|
|
89
110
|
return SQL_Helper(engine, engine_type=SQL_SERVER)
|
|
90
111
|
|
|
91
112
|
|
|
113
|
+
def get_sqlserver_helper(
|
|
114
|
+
host,
|
|
115
|
+
database,
|
|
116
|
+
service_principal_id=None,
|
|
117
|
+
service_principal_secret=None,
|
|
118
|
+
tenant_id=None,
|
|
119
|
+
user=None,
|
|
120
|
+
password=None,
|
|
121
|
+
port=1433,
|
|
122
|
+
db_driver="ODBC Driver 17 for SQL Server",
|
|
123
|
+
fast_execute_many=True,
|
|
124
|
+
**kwargs,
|
|
125
|
+
):
|
|
126
|
+
|
|
127
|
+
if user and password:
|
|
128
|
+
return _get_sqlserver_helper_from_user_password(
|
|
129
|
+
host,
|
|
130
|
+
database,
|
|
131
|
+
user,
|
|
132
|
+
password,
|
|
133
|
+
port,
|
|
134
|
+
db_driver,
|
|
135
|
+
fast_execute_many,
|
|
136
|
+
**kwargs,
|
|
137
|
+
)
|
|
138
|
+
elif service_principal_id and service_principal_secret and tenant_id:
|
|
139
|
+
return _get_sqlserver_helper_from_service_principal(
|
|
140
|
+
host,
|
|
141
|
+
database,
|
|
142
|
+
service_principal_id,
|
|
143
|
+
service_principal_secret,
|
|
144
|
+
tenant_id,
|
|
145
|
+
port,
|
|
146
|
+
db_driver,
|
|
147
|
+
fast_execute_many,
|
|
148
|
+
**kwargs,
|
|
149
|
+
)
|
|
150
|
+
else:
|
|
151
|
+
raise ValueError(
|
|
152
|
+
"Either user and password or service_principal_id, service_principal_secret and tenant_id must be provided"
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
92
156
|
def _value_to_str(v):
|
|
93
157
|
if isinstance(v, bool):
|
|
94
158
|
return str(int(v))
|
|
@@ -170,19 +234,19 @@ class SQL_Helper:
|
|
|
170
234
|
df (pd.DataFrame): data to write
|
|
171
235
|
table_name (str): output database table name
|
|
172
236
|
if_exists (str): action to take if table already exists
|
|
173
|
-
* fail,
|
|
174
|
-
* replace
|
|
175
|
-
* append
|
|
237
|
+
* fail,
|
|
238
|
+
* replace
|
|
239
|
+
* append
|
|
176
240
|
* truncate: NEW, truncate table before writing, like 'replace' but keeps structure
|
|
177
241
|
**kwargs: additional keyword parameters passed to df.to_sql
|
|
178
242
|
"""
|
|
179
243
|
with self._engine.connect() as conn:
|
|
180
244
|
trans = conn.begin()
|
|
181
245
|
try:
|
|
182
|
-
if if_exists == "truncate":
|
|
246
|
+
if if_exists == "truncate":
|
|
183
247
|
conn.execute(f"TRUNCATE TABLE {table_name}")
|
|
184
248
|
if_exists = "append"
|
|
185
|
-
df.to_sql(table_name.lower(), conn, chunksize=chunksize, index=index, **kwargs)
|
|
249
|
+
df.to_sql(table_name.lower(), conn, chunksize=chunksize, index=index, if_exists=if_exists, **kwargs)
|
|
186
250
|
trans.commit()
|
|
187
251
|
except Exception as ex:
|
|
188
252
|
LOGGER.warning(str(ex))
|
{vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vavacars_data_utils.egg-info/SOURCES.txt
RENAMED
|
@@ -30,6 +30,35 @@ setup.cfg
|
|
|
30
30
|
./vava_utils/utils/utils.py
|
|
31
31
|
./vava_utils/vavaprice/__init__.py
|
|
32
32
|
./vava_utils/vavaprice/vavaprice_helper.py
|
|
33
|
+
test/utils/__init__.py
|
|
34
|
+
test/utils/test_strings.py
|
|
35
|
+
vava_utils/__init__.py
|
|
36
|
+
vava_utils/azure/__init__.py
|
|
37
|
+
vava_utils/azure/az_helper.py
|
|
38
|
+
vava_utils/bigquery/__init__.py
|
|
39
|
+
vava_utils/bigquery/bigquery_helper.py
|
|
40
|
+
vava_utils/camunda/__init__.py
|
|
41
|
+
vava_utils/camunda/camunda_helper.py
|
|
42
|
+
vava_utils/email/__init__.py
|
|
43
|
+
vava_utils/email/email_helper.py
|
|
44
|
+
vava_utils/salesforce/__init__.py
|
|
45
|
+
vava_utils/salesforce/salesforce_helper.py
|
|
46
|
+
vava_utils/smartiq/__init__.py
|
|
47
|
+
vava_utils/smartiq/smartiq_helper.py
|
|
48
|
+
vava_utils/smartiq/smartiq_helper_v2.py
|
|
49
|
+
vava_utils/sql/__init__.py
|
|
50
|
+
vava_utils/sql/sql_helper.py
|
|
51
|
+
vava_utils/turkey/__init__.py
|
|
52
|
+
vava_utils/turkey/dates.py
|
|
53
|
+
vava_utils/utils/__init__.py
|
|
54
|
+
vava_utils/utils/callables.py
|
|
55
|
+
vava_utils/utils/comparisons.py
|
|
56
|
+
vava_utils/utils/naming.py
|
|
57
|
+
vava_utils/utils/singleton.py
|
|
58
|
+
vava_utils/utils/strings.py
|
|
59
|
+
vava_utils/utils/utils.py
|
|
60
|
+
vava_utils/vavaprice/__init__.py
|
|
61
|
+
vava_utils/vavaprice/vavaprice_helper.py
|
|
33
62
|
vavacars_data_utils.egg-info/PKG-INFO
|
|
34
63
|
vavacars_data_utils.egg-info/SOURCES.txt
|
|
35
64
|
vavacars_data_utils.egg-info/dependency_links.txt
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/bigquery/bigquery_helper.py
RENAMED
|
File without changes
|
|
File without changes
|
{vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/camunda/camunda_helper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/salesforce/salesforce_helper.py
RENAMED
|
File without changes
|
|
File without changes
|
{vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/smartiq/smartiq_helper.py
RENAMED
|
File without changes
|
{vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/smartiq/smartiq_helper_v2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vava_utils/vavaprice/vavaprice_helper.py
RENAMED
|
File without changes
|
|
File without changes
|
{vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vavacars_data_utils.egg-info/requires.txt
RENAMED
|
File without changes
|
{vavacars_data_utils-1.3.5 → vavacars_data_utils-1.3.7}/vavacars_data_utils.egg-info/top_level.txt
RENAMED
|
File without changes
|