analytic-workspace-client 1.29.0rc2__tar.gz → 1.29.2__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.
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/PKG-INFO +4 -1
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/setup.py +3 -3
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/analytic_workspace_client.egg-info/PKG-INFO +4 -1
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/analytic_workspace_client.egg-info/SOURCES.txt +2 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/analytic_workspace_client.egg-info/requires.txt +4 -4
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/data_master/base.py +2 -2
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/data_master/v2.py +1 -1
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/etl_blocks/dto.py +1 -1
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/etl_blocks/runtime.py +1 -1
- analytic_workspace_client-1.29.2/src/aw_client/ml/mlflow_wrapper.py +50 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/model_dev/runner.py +3 -2
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/models/model_schema.py +9 -1
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/session.py +6 -20
- analytic_workspace_client-1.29.2/src/aw_etl/__init__.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/README.md +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/pyproject.toml +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/setup.cfg +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/analytic_workspace_client.egg-info/dependency_links.txt +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/analytic_workspace_client.egg-info/top_level.txt +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/__init__.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/cache.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/core/__init__.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/core/bundle.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/core/compiler.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/core/model_vault.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/core/spark.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/data_master/__init__.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/data_master/v0.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/data_master/v1.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/domain.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/etl_blocks/__init__.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/etl_blocks/application.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/etl_blocks/services.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/etl_blocks/test_data.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/etl_blocks/tools.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/exceptions.py +0 -0
- {analytic_workspace_client-1.29.0rc2/src/aw_client/model_dev → analytic_workspace_client-1.29.2/src/aw_client/ml}/__init__.py +0 -0
- {analytic_workspace_client-1.29.0rc2/src/aw_client/models → analytic_workspace_client-1.29.2/src/aw_client/model_dev}/__init__.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/model_dev/application.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/model_dev/cache.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/model_dev/virtual_objects.py +0 -0
- {analytic_workspace_client-1.29.0rc2/src/aw_etl → analytic_workspace_client-1.29.2/src/aw_client/models}/__init__.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/tools.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_etl/compiler.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_etl/etl_blocks.py +0 -0
- {analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_etl/models.py +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: analytic_workspace_client
|
|
3
|
-
Version: 1.29.
|
|
3
|
+
Version: 1.29.2
|
|
4
4
|
Summary: Библиотека для подключения к Analytic Workspace
|
|
5
5
|
Home-page: https://analyticworkspace.ru/
|
|
6
6
|
Author: Analytic Workspace
|
|
7
7
|
Author-email: aw_help@analyticworkspace.ru
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Platform: UNKNOWN
|
|
8
10
|
Classifier: Programming Language :: Python :: 3
|
|
9
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
12
|
Classifier: Operating System :: OS Independent
|
|
@@ -39,3 +41,4 @@ df = session.load(model_id=123) # df: pandas.DataFrame
|
|
|
39
41
|
|
|
40
42
|
display(df)
|
|
41
43
|
```
|
|
44
|
+
|
|
@@ -10,7 +10,7 @@ long_description = (here / "README.md").read_text(encoding="utf-8")
|
|
|
10
10
|
|
|
11
11
|
setup(
|
|
12
12
|
name='analytic_workspace_client',
|
|
13
|
-
version='1.29.
|
|
13
|
+
version='1.29.2',
|
|
14
14
|
|
|
15
15
|
description='Библиотека для подключения к Analytic Workspace',
|
|
16
16
|
long_description=long_description,
|
|
@@ -36,13 +36,13 @@ setup(
|
|
|
36
36
|
'python-dotenv>=1.0,<1.1',
|
|
37
37
|
'httpx>=0.25,<1.0',
|
|
38
38
|
'pandas',
|
|
39
|
-
'pydantic>=
|
|
39
|
+
'pydantic>=2.0',
|
|
40
40
|
'colorama>=0.4,<0.5'
|
|
41
41
|
],
|
|
42
42
|
|
|
43
43
|
extras_require={
|
|
44
44
|
'dev': ['pyspark==3.5.0', 'pytest>=8.2,<8.3'],
|
|
45
|
-
'ml': ['mlflow
|
|
45
|
+
'ml': ['mlflow==2.14.3']
|
|
46
46
|
},
|
|
47
47
|
|
|
48
48
|
setup_requires=['wheel'],
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: analytic-workspace-client
|
|
3
|
-
Version: 1.29.
|
|
3
|
+
Version: 1.29.2
|
|
4
4
|
Summary: Библиотека для подключения к Analytic Workspace
|
|
5
5
|
Home-page: https://analyticworkspace.ru/
|
|
6
6
|
Author: Analytic Workspace
|
|
7
7
|
Author-email: aw_help@analyticworkspace.ru
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Platform: UNKNOWN
|
|
8
10
|
Classifier: Programming Language :: Python :: 3
|
|
9
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
12
|
Classifier: Operating System :: OS Independent
|
|
@@ -39,3 +41,4 @@ df = session.load(model_id=123) # df: pandas.DataFrame
|
|
|
39
41
|
|
|
40
42
|
display(df)
|
|
41
43
|
```
|
|
44
|
+
|
|
@@ -29,6 +29,8 @@ src/aw_client/etl_blocks/runtime.py
|
|
|
29
29
|
src/aw_client/etl_blocks/services.py
|
|
30
30
|
src/aw_client/etl_blocks/test_data.py
|
|
31
31
|
src/aw_client/etl_blocks/tools.py
|
|
32
|
+
src/aw_client/ml/__init__.py
|
|
33
|
+
src/aw_client/ml/mlflow_wrapper.py
|
|
32
34
|
src/aw_client/model_dev/__init__.py
|
|
33
35
|
src/aw_client/model_dev/application.py
|
|
34
36
|
src/aw_client/model_dev/cache.py
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
colorama<0.5,>=0.4
|
|
2
2
|
httpx<1.0,>=0.25
|
|
3
3
|
pandas
|
|
4
|
-
pydantic
|
|
5
|
-
|
|
4
|
+
pydantic>=2.0
|
|
5
|
+
python-dotenv<1.1,>=1.0
|
|
6
6
|
|
|
7
7
|
[dev]
|
|
8
8
|
pyspark==3.5.0
|
|
9
9
|
pytest<8.3,>=8.2
|
|
10
10
|
|
|
11
11
|
[ml]
|
|
12
|
-
mlflow
|
|
12
|
+
mlflow==2.14.3
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional
|
|
1
|
+
from typing import Optional, Iterator
|
|
2
2
|
|
|
3
3
|
import abc
|
|
4
4
|
from pathlib import Path
|
|
@@ -38,7 +38,7 @@ class DataMasterApi(metaclass=abc.ABCMeta):
|
|
|
38
38
|
""" """
|
|
39
39
|
|
|
40
40
|
@contextmanager
|
|
41
|
-
def get_http_client(self) -> httpx.Client:
|
|
41
|
+
def get_http_client(self) -> Iterator[httpx.Client]:
|
|
42
42
|
""" """
|
|
43
43
|
if not self.api_config.aw_url:
|
|
44
44
|
raise DataMasterApi.MisconfiguredError('Не указан URL к Analytic Workspace')
|
|
@@ -34,7 +34,7 @@ class DataMasterV2(DataMasterApi):
|
|
|
34
34
|
raise AwModelForbidden(f'Доступ к модели {model_id} запрещен')
|
|
35
35
|
raise Exception(f'Ошибка запроса схемы модели HTTP {r.status_code} GET {r.url}: {r.text}')
|
|
36
36
|
|
|
37
|
-
return ModelSchema.
|
|
37
|
+
return ModelSchema.model_validate(r.json())
|
|
38
38
|
|
|
39
39
|
def load_model_object_data(self, folder: Path, model_id: int, model_object_name: str, limit: Optional[int]):
|
|
40
40
|
""" """
|
|
@@ -32,7 +32,7 @@ def get_etl_block_meta(block_path: Path) -> ETLBlockMeta:
|
|
|
32
32
|
raise Exception(f'Файл с метаданным блока не найден: {block_meta_path}')
|
|
33
33
|
|
|
34
34
|
with open(block_meta_path, 'rt') as f:
|
|
35
|
-
return ETLBlockMeta.
|
|
35
|
+
return ETLBlockMeta.model_validate_json(f.read())
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
def get_etl_block_schema(block_path: Path,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from urllib.parse import urljoin
|
|
3
|
+
|
|
4
|
+
from aw_client.exceptions import AwClientMisconfigured
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class MlflowWrapper:
|
|
8
|
+
""" """
|
|
9
|
+
def __init__(self, aw_url: str, auth_token: str):
|
|
10
|
+
""" """
|
|
11
|
+
self.aw_url = aw_url
|
|
12
|
+
self.auth_token = auth_token
|
|
13
|
+
self.mlflow = None
|
|
14
|
+
|
|
15
|
+
def _mlflow(self):
|
|
16
|
+
""" """
|
|
17
|
+
if not self.mlflow:
|
|
18
|
+
try:
|
|
19
|
+
import mlflow
|
|
20
|
+
except ImportError:
|
|
21
|
+
raise AwClientMisconfigured(
|
|
22
|
+
'Для использованиея MLFlow установите библиотеку с опцией ml: pip install analytic-workspace-client[ml]')
|
|
23
|
+
|
|
24
|
+
if not self.auth_token:
|
|
25
|
+
data_master_url = urljoin(self.aw_url, 'data-master/get-token')
|
|
26
|
+
raise AwClientMisconfigured(
|
|
27
|
+
f'Не указан токен доступа к AnalyticWorkspace. Пройдите по адресу {data_master_url} для получения '
|
|
28
|
+
f'токена.')
|
|
29
|
+
|
|
30
|
+
tracking_url = urljoin(self.aw_url, 'mlflow')
|
|
31
|
+
|
|
32
|
+
if mlflow.get_tracking_uri() != tracking_url:
|
|
33
|
+
mlflow.set_tracking_uri(tracking_url)
|
|
34
|
+
|
|
35
|
+
os.environ['MLFLOW_TRACKING_TOKEN'] = self.auth_token
|
|
36
|
+
self.mlflow = mlflow
|
|
37
|
+
|
|
38
|
+
return self.mlflow
|
|
39
|
+
|
|
40
|
+
def setup_experiment(self, experiment_name: str) -> str:
|
|
41
|
+
""" """
|
|
42
|
+
mlflow = self._mlflow()
|
|
43
|
+
|
|
44
|
+
experiment = mlflow.get_experiment_by_name(experiment_name)
|
|
45
|
+
return mlflow.create_experiment(experiment_name) if experiment is None else experiment.experiment_id
|
|
46
|
+
|
|
47
|
+
def __getattr__(self, name: str):
|
|
48
|
+
""" """
|
|
49
|
+
mlflow = self._mlflow()
|
|
50
|
+
return getattr(mlflow, name)
|
|
@@ -150,7 +150,8 @@ if __name__ == '__main__':
|
|
|
150
150
|
if cache.model_schema_path().exists() and not args.no_cache:
|
|
151
151
|
print(Fore.YELLOW + f'Не удалось получить схему модели {model_id}: {e}. '
|
|
152
152
|
f'Для запуска скрипта используется схема модели из кеша.' + Fore.RESET)
|
|
153
|
-
|
|
153
|
+
with open(cache.model_schema_path(), 'rt') as f:
|
|
154
|
+
model_schema = ModelSchema.model_validate_json(f.read())
|
|
154
155
|
else:
|
|
155
156
|
print(Fore.RED + f'ОШИБКА: Не удалось получить схему модели {model_id}: {e}' + Fore.RESET)
|
|
156
157
|
sys.exit(1)
|
|
@@ -162,7 +163,7 @@ if __name__ == '__main__':
|
|
|
162
163
|
cache_folder = cache.get_model_folder()
|
|
163
164
|
os.makedirs(cache_folder, exist_ok=True)
|
|
164
165
|
with open(cache.model_schema_path(), 'wt') as f:
|
|
165
|
-
f.write(model_schema.
|
|
166
|
+
f.write(model_schema.model_dump_json(indent=2))
|
|
166
167
|
|
|
167
168
|
# ------------------------------------------------------------------------------
|
|
168
169
|
# Загрузка данных объектов модели
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import Optional, List, Dict
|
|
2
2
|
|
|
3
|
-
from pydantic import BaseModel
|
|
3
|
+
from pydantic import BaseModel, ConfigDict
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class ModelObjectField(BaseModel):
|
|
@@ -9,6 +9,10 @@ class ModelObjectField(BaseModel):
|
|
|
9
9
|
model_name: str
|
|
10
10
|
simple_type: str
|
|
11
11
|
|
|
12
|
+
model_config = ConfigDict(
|
|
13
|
+
protected_namespaces=()
|
|
14
|
+
)
|
|
15
|
+
|
|
12
16
|
|
|
13
17
|
class ModelObject(BaseModel):
|
|
14
18
|
""" """
|
|
@@ -18,6 +22,10 @@ class ModelObject(BaseModel):
|
|
|
18
22
|
sql_text: Optional[str] = None
|
|
19
23
|
fields: List[ModelObjectField] = []
|
|
20
24
|
|
|
25
|
+
model_config = ConfigDict(
|
|
26
|
+
protected_namespaces=()
|
|
27
|
+
)
|
|
28
|
+
|
|
21
29
|
|
|
22
30
|
class ModelSql(BaseModel):
|
|
23
31
|
"""
|
{analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/session.py
RENAMED
|
@@ -12,6 +12,7 @@ from aw_client.data_master import get_nearest_api
|
|
|
12
12
|
from aw_client.domain import APIConfig
|
|
13
13
|
from aw_client.models.model_schema import ModelSchema
|
|
14
14
|
from aw_client.exceptions import AwClientMisconfigured
|
|
15
|
+
from aw_client.ml.mlflow_wrapper import MlflowWrapper
|
|
15
16
|
|
|
16
17
|
from aw_client.tools import strip_column_name_prefix
|
|
17
18
|
|
|
@@ -34,6 +35,7 @@ class Session:
|
|
|
34
35
|
if not self.aw_url.endswith('/'):
|
|
35
36
|
self.aw_url += '/'
|
|
36
37
|
self.version = version if version is not None else None
|
|
38
|
+
self._mlflow_wrapper = None
|
|
37
39
|
|
|
38
40
|
def get_aw_version(self) -> int:
|
|
39
41
|
""" """
|
|
@@ -132,23 +134,7 @@ class Session:
|
|
|
132
134
|
@property
|
|
133
135
|
def mlflow(self):
|
|
134
136
|
""" """
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
'Для использованиея MLFlow установите библиотеку с опцией ml: pip install analytic-workspace-client[ml]')
|
|
140
|
-
|
|
141
|
-
if not self.token:
|
|
142
|
-
data_master_url = urljoin(self.aw_url, 'data-master/get-token')
|
|
143
|
-
raise AwClientMisconfigured(
|
|
144
|
-
f'Не указан токен доступа к AnalyticWorkspace. Пройдите по адресу {data_master_url} для получения '
|
|
145
|
-
f'токена')
|
|
146
|
-
|
|
147
|
-
tracking_url = urljoin(self.aw_url, 'mlflow')
|
|
148
|
-
|
|
149
|
-
if mlflow.get_tracking_uri() != tracking_url:
|
|
150
|
-
mlflow.set_tracking_uri(tracking_url)
|
|
151
|
-
|
|
152
|
-
os.environ['MLFLOW_TRACKING_TOKEN'] = self.token
|
|
153
|
-
|
|
154
|
-
return mlflow
|
|
137
|
+
if self._mlflow_wrapper is None:
|
|
138
|
+
self._mlflow_wrapper = MlflowWrapper(aw_url=self.aw_url, auth_token=self.token)
|
|
139
|
+
|
|
140
|
+
return self._mlflow_wrapper
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/__init__.py
RENAMED
|
File without changes
|
{analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/cache.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/core/spark.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/domain.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_client/tools.py
RENAMED
|
File without changes
|
{analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_etl/compiler.py
RENAMED
|
File without changes
|
{analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_etl/etl_blocks.py
RENAMED
|
File without changes
|
{analytic_workspace_client-1.29.0rc2 → analytic_workspace_client-1.29.2}/src/aw_etl/models.py
RENAMED
|
File without changes
|