mostlyai 4.6.4__tar.gz → 4.7.1__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.
- {mostlyai-4.6.4 → mostlyai-4.7.1}/PKG-INFO +15 -9
- {mostlyai-4.6.4 → mostlyai-4.7.1}/README.md +10 -4
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/__init__.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/auto_detect.py +4 -4
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/base.py +9 -10
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/context.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/base.py +46 -8
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/databricks.py +4 -6
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/hive.py +4 -6
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/oracle.py +3 -3
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/dtype.py +5 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/base.py +3 -3
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/container/aws.py +2 -3
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/language_model.py +1 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/non_context.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/pull_context.py +2 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/pull_utils.py +6 -6
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/util/common.py +4 -4
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/util/kerberos.py +3 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/cli.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/connectors.py +7 -6
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/jobs.py +27 -17
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/migration.py +1 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/plan.py +29 -26
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +3 -4
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_create_model_report.py +5 -7
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_deliver_data.py +2 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_finalize_generation.py +2 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_generate_data.py +2 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +2 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_pull_training_data.py +3 -3
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_train_model.py +3 -3
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/progress.py +2 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/routes.py +36 -37
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/server.py +4 -6
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/storage.py +7 -6
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/synthetic_datasets.py +22 -19
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/client/_utils.py +10 -10
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/client/api.py +22 -22
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/domain.py +78 -29
- {mostlyai-4.6.4 → mostlyai-4.7.1}/pyproject.toml +8 -5
- {mostlyai-4.6.4 → mostlyai-4.7.1}/.gitignore +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/LICENSE +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/__init__.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/conversions.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/__init__.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/bigquery.py +2 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/mssql.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/mysql.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/postgresql.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/snowflake.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/sqlite.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/exceptions.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/__init__.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/container/azure.py +4 -4
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/container/gcs.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/container/minio.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/table/csv.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/table/feather.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/table/json.py +2 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/file/utils.py +3 -3
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/metadata_objects.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/progress_callback.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/pull.py +4 -4
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/push.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_data/util/__init__.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/__init__.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/__init__.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_create_data_report.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_encode_training_data.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/_local/generators.py +17 -17
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/client/__init__.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/client/_base_utils.py +1 -1
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/client/_naming_conventions.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/client/base.py +2 -2
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/client/connectors.py +3 -3
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/client/exceptions.py +0 -0
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/client/generators.py +9 -9
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/client/synthetic_datasets.py +5 -5
- {mostlyai-4.6.4 → mostlyai-4.7.1}/mostlyai/sdk/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mostlyai
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.7.1
|
|
4
4
|
Summary: Synthetic Data SDK
|
|
5
5
|
Project-URL: homepage, https://app.mostly.ai/
|
|
6
6
|
Project-URL: repository, https://github.com/mostly-ai/mostlyai
|
|
@@ -59,8 +59,8 @@ Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local'
|
|
|
59
59
|
Requires-Dist: filelock>=3.16.1; extra == 'local'
|
|
60
60
|
Requires-Dist: gcsfs>=2023.1.0; extra == 'local'
|
|
61
61
|
Requires-Dist: joblib>=1.4.2; extra == 'local'
|
|
62
|
-
Requires-Dist: mostlyai-engine==1.4.
|
|
63
|
-
Requires-Dist: mostlyai-qa==1.9.
|
|
62
|
+
Requires-Dist: mostlyai-engine==1.4.3; extra == 'local'
|
|
63
|
+
Requires-Dist: mostlyai-qa==1.9.6; extra == 'local'
|
|
64
64
|
Requires-Dist: networkx<4,>=3.0; extra == 'local'
|
|
65
65
|
Requires-Dist: openpyxl>=3.1.5; extra == 'local'
|
|
66
66
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local'
|
|
@@ -81,8 +81,8 @@ Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-gpu'
|
|
|
81
81
|
Requires-Dist: filelock>=3.16.1; extra == 'local-gpu'
|
|
82
82
|
Requires-Dist: gcsfs>=2023.1.0; extra == 'local-gpu'
|
|
83
83
|
Requires-Dist: joblib>=1.4.2; extra == 'local-gpu'
|
|
84
|
-
Requires-Dist: mostlyai-engine[gpu]==1.4.
|
|
85
|
-
Requires-Dist: mostlyai-qa==1.9.
|
|
84
|
+
Requires-Dist: mostlyai-engine[gpu]==1.4.3; extra == 'local-gpu'
|
|
85
|
+
Requires-Dist: mostlyai-qa==1.9.6; extra == 'local-gpu'
|
|
86
86
|
Requires-Dist: networkx<4,>=3.0; extra == 'local-gpu'
|
|
87
87
|
Requires-Dist: openpyxl>=3.1.5; extra == 'local-gpu'
|
|
88
88
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local-gpu'
|
|
@@ -350,11 +350,17 @@ As an alternative, you can also build a Docker image, which provides you with an
|
|
|
350
350
|
|
|
351
351
|
<details>
|
|
352
352
|
|
|
353
|
-
<summary>
|
|
353
|
+
<summary>Get the image</summary>
|
|
354
354
|
|
|
355
|
-
|
|
355
|
+
- **Pull from official repository**
|
|
356
356
|
|
|
357
|
-
|
|
357
|
+
`docker pull --platform=linux/amd64 quay.io/mostlyai/sdk`
|
|
358
|
+
|
|
359
|
+
- **(Optional) Build your own image**
|
|
360
|
+
|
|
361
|
+
If your environment is capable of executing Makefile (see [here](https://github.com/mostly-ai/mostlyai/blob/main/Makefile#L47-L73)), then execute `make docker-build`.
|
|
362
|
+
|
|
363
|
+
Otherwise, use `docker buildx build . --platform=linux/amd64 -t quay.io/mostlyai/sdk` instead.
|
|
358
364
|
|
|
359
365
|
</details>
|
|
360
366
|
|
|
@@ -366,7 +372,7 @@ As an alternative, you can also build a Docker image, which provides you with an
|
|
|
366
372
|
|
|
367
373
|
If your environment is capable of executing Makefile, then execute `make docker-run`. Or `make docker-run HOST_PORT=8080` to forward to a host port of your choice. One could also mount the `local_dir` via `make docker-run HOST_LOCAL_DIR=/path/to/host/folder` to make the generators and synthetic datasets directly accessible from the host.
|
|
368
374
|
|
|
369
|
-
Otherwise, use `docker run --platform=linux/amd64 -p 8080:8080 mostlyai/
|
|
375
|
+
Otherwise, use `docker run --platform=linux/amd64 -p 8080:8080 quay.io/mostlyai/sdk` instead. Optionally, you can use the `-v` flag to mount a [volume](https://docs.docker.com/engine/storage/volumes/#syntax) for passing files between the host and the container.
|
|
370
376
|
|
|
371
377
|
</details>
|
|
372
378
|
|
|
@@ -241,11 +241,17 @@ As an alternative, you can also build a Docker image, which provides you with an
|
|
|
241
241
|
|
|
242
242
|
<details>
|
|
243
243
|
|
|
244
|
-
<summary>
|
|
244
|
+
<summary>Get the image</summary>
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
- **Pull from official repository**
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
`docker pull --platform=linux/amd64 quay.io/mostlyai/sdk`
|
|
249
|
+
|
|
250
|
+
- **(Optional) Build your own image**
|
|
251
|
+
|
|
252
|
+
If your environment is capable of executing Makefile (see [here](https://github.com/mostly-ai/mostlyai/blob/main/Makefile#L47-L73)), then execute `make docker-build`.
|
|
253
|
+
|
|
254
|
+
Otherwise, use `docker buildx build . --platform=linux/amd64 -t quay.io/mostlyai/sdk` instead.
|
|
249
255
|
|
|
250
256
|
</details>
|
|
251
257
|
|
|
@@ -257,7 +263,7 @@ As an alternative, you can also build a Docker image, which provides you with an
|
|
|
257
263
|
|
|
258
264
|
If your environment is capable of executing Makefile, then execute `make docker-run`. Or `make docker-run HOST_PORT=8080` to forward to a host port of your choice. One could also mount the `local_dir` via `make docker-run HOST_LOCAL_DIR=/path/to/host/folder` to make the generators and synthetic datasets directly accessible from the host.
|
|
259
265
|
|
|
260
|
-
Otherwise, use `docker run --platform=linux/amd64 -p 8080:8080 mostlyai/
|
|
266
|
+
Otherwise, use `docker run --platform=linux/amd64 -p 8080:8080 quay.io/mostlyai/sdk` instead. Optionally, you can use the `-v` flag to mount a [volume](https://docs.docker.com/engine/storage/volumes/#syntax) for passing files between the host and the container.
|
|
261
267
|
|
|
262
268
|
</details>
|
|
263
269
|
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
import re
|
|
16
15
|
import logging
|
|
16
|
+
import re
|
|
17
17
|
import time
|
|
18
18
|
|
|
19
19
|
import pandas as pd
|
|
20
20
|
|
|
21
21
|
from mostlyai.engine._common import safe_convert_datetime
|
|
22
|
-
from mostlyai.sdk.domain import ModelEncodingType
|
|
23
22
|
from mostlyai.sdk._data.base import DataTable
|
|
24
|
-
from mostlyai.sdk._data.dtype import VirtualDType,
|
|
25
|
-
from mostlyai.sdk._data.util.common import
|
|
23
|
+
from mostlyai.sdk._data.dtype import VirtualDType, VirtualInteger, VirtualVarchar
|
|
24
|
+
from mostlyai.sdk._data.util.common import absorb_errors, run_with_timeout_unsafe
|
|
25
|
+
from mostlyai.sdk.domain import ModelEncodingType
|
|
26
26
|
|
|
27
27
|
AUTODETECT_SAMPLE_SIZE = 10_000
|
|
28
28
|
AUTODETECT_TIMEOUT = 15
|
|
@@ -16,30 +16,29 @@ import abc
|
|
|
16
16
|
import functools
|
|
17
17
|
import itertools
|
|
18
18
|
import logging
|
|
19
|
+
from collections.abc import Generator, Iterable
|
|
19
20
|
from copy import deepcopy
|
|
20
21
|
from dataclasses import dataclass, field
|
|
21
22
|
from typing import Any
|
|
22
|
-
from collections.abc import Generator, Iterable
|
|
23
23
|
|
|
24
24
|
import networkx as nx
|
|
25
25
|
import pandas as pd
|
|
26
26
|
|
|
27
|
-
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
28
|
-
from mostlyai.sdk.domain import ModelEncodingType
|
|
29
|
-
|
|
30
27
|
from mostlyai.sdk._data.dtype import V_DTYPE_ENCODING_TYPE_MAP, DType, VirtualDType
|
|
28
|
+
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
31
29
|
from mostlyai.sdk._data.util.common import (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
get_passphrase,
|
|
30
|
+
DATA_TABLE_METADATA_FIELDS,
|
|
31
|
+
IS_NULL,
|
|
35
32
|
MAX_SCP_SIBLINGS_LIMIT,
|
|
36
|
-
TABLE_COLUMN_INFIX,
|
|
37
33
|
NON_CONTEXT_COLUMN_INFIX,
|
|
38
|
-
|
|
39
|
-
DATA_TABLE_METADATA_FIELDS,
|
|
34
|
+
TABLE_COLUMN_INFIX,
|
|
40
35
|
Key,
|
|
41
36
|
OrderBy,
|
|
37
|
+
as_list,
|
|
38
|
+
decrypt,
|
|
39
|
+
get_passphrase,
|
|
42
40
|
)
|
|
41
|
+
from mostlyai.sdk.domain import ModelEncodingType
|
|
43
42
|
|
|
44
43
|
_LOG = logging.getLogger(__name__)
|
|
45
44
|
|
|
@@ -17,8 +17,8 @@ import logging
|
|
|
17
17
|
import numpy as np
|
|
18
18
|
import pandas as pd
|
|
19
19
|
|
|
20
|
+
from mostlyai.sdk._data.base import ContextRelation, DataIdentifier, Schema
|
|
20
21
|
from mostlyai.sdk.domain import ModelEncodingType, ModelType
|
|
21
|
-
from mostlyai.sdk._data.base import Schema, DataIdentifier, ContextRelation
|
|
22
22
|
|
|
23
23
|
_LOG = logging.getLogger(__name__)
|
|
24
24
|
|
|
@@ -14,40 +14,45 @@
|
|
|
14
14
|
|
|
15
15
|
import abc
|
|
16
16
|
import base64
|
|
17
|
+
import decimal
|
|
18
|
+
import enum
|
|
17
19
|
import functools
|
|
18
20
|
import hashlib
|
|
19
21
|
import logging
|
|
22
|
+
import os
|
|
20
23
|
import re
|
|
21
24
|
import shutil
|
|
22
|
-
import os
|
|
23
|
-
|
|
24
25
|
import socket
|
|
25
26
|
import subprocess
|
|
26
27
|
import tempfile
|
|
27
28
|
import time
|
|
29
|
+
import uuid
|
|
28
30
|
from collections import defaultdict
|
|
31
|
+
from collections.abc import Callable, Generator, Iterable
|
|
29
32
|
from contextlib import contextmanager
|
|
30
33
|
from functools import lru_cache
|
|
31
34
|
from pathlib import Path
|
|
32
35
|
from typing import Any, Literal, Optional
|
|
33
|
-
from collections.abc import Callable, Generator, Iterable
|
|
34
36
|
|
|
37
|
+
import numpy as np
|
|
35
38
|
import pandas as pd
|
|
36
39
|
import sqlalchemy as sa
|
|
37
40
|
import sqlalchemy.sql.sqltypes as sa_types
|
|
38
41
|
import sshtunnel
|
|
39
42
|
from joblib import Parallel, delayed
|
|
43
|
+
from sqlalchemy import Table
|
|
40
44
|
from sqlalchemy.orm import sessionmaker
|
|
41
45
|
|
|
42
|
-
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
43
46
|
from mostlyai.sdk._data.base import (
|
|
44
47
|
DataContainer,
|
|
45
48
|
DataTable,
|
|
46
|
-
order_df_by,
|
|
47
49
|
ForeignKey,
|
|
50
|
+
order_df_by,
|
|
48
51
|
)
|
|
49
52
|
from mostlyai.sdk._data.db.types_coercion import coerce_to_sql_dtype
|
|
50
53
|
from mostlyai.sdk._data.dtype import (
|
|
54
|
+
FLOAT64,
|
|
55
|
+
STRING,
|
|
51
56
|
VirtualBoolean,
|
|
52
57
|
VirtualDate,
|
|
53
58
|
VirtualDatetime,
|
|
@@ -59,9 +64,9 @@ from mostlyai.sdk._data.dtype import (
|
|
|
59
64
|
WrappedDType,
|
|
60
65
|
coerce_dtypes_by_encoding,
|
|
61
66
|
)
|
|
62
|
-
from mostlyai.sdk._data.
|
|
67
|
+
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
68
|
+
from mostlyai.sdk._data.util.common import ColumnSort, OrderBy, assert_read_only_sql, prepare_ssl_path
|
|
63
69
|
from mostlyai.sdk._data.util.kerberos import is_kerberos_ticket_alive
|
|
64
|
-
from sqlalchemy import Table
|
|
65
70
|
|
|
66
71
|
_LOG = logging.getLogger(__name__)
|
|
67
72
|
|
|
@@ -591,7 +596,7 @@ class SqlAlchemyContainer(DBContainer, abc.ABC):
|
|
|
591
596
|
assert_read_only_sql(sql)
|
|
592
597
|
with self.init_sa_connection() as engine:
|
|
593
598
|
try:
|
|
594
|
-
return pd.read_sql(sql, engine)
|
|
599
|
+
return pd.read_sql(sql, engine, dtype_backend="pyarrow")
|
|
595
600
|
except sa.exc.SQLAlchemyError as e:
|
|
596
601
|
_LOG.error(f"Error executing query: {str(e)}")
|
|
597
602
|
raise
|
|
@@ -1284,6 +1289,8 @@ class SqlAlchemyTable(DBTable, abc.ABC):
|
|
|
1284
1289
|
assert self.is_output
|
|
1285
1290
|
_LOG.info(f"write data {df.shape} to table `{self.name}` started")
|
|
1286
1291
|
|
|
1292
|
+
df = _normalize_for_sql(df)
|
|
1293
|
+
|
|
1287
1294
|
# map mostly-data dtypes to SQLAlchemy dtypes
|
|
1288
1295
|
dtypes = self.dtype_class().from_dtypes_unwrap(self.dtypes)
|
|
1289
1296
|
|
|
@@ -1312,6 +1319,37 @@ class SqlAlchemyTable(DBTable, abc.ABC):
|
|
|
1312
1319
|
return self._sa_execute([stmt]).loc[0, "count_1"]
|
|
1313
1320
|
|
|
1314
1321
|
|
|
1322
|
+
def _normalize_for_sql(df: pd.DataFrame) -> pd.DataFrame:
|
|
1323
|
+
# ensure pd.DataFrame.to_sql(...) works alongside pyarrow backend
|
|
1324
|
+
apply_map = {
|
|
1325
|
+
np.ndarray: lambda x: x.tolist() if isinstance(x, np.ndarray) else x,
|
|
1326
|
+
enum.Enum: lambda x: x.value if isinstance(x, enum.Enum) else x,
|
|
1327
|
+
}
|
|
1328
|
+
astype_map = {
|
|
1329
|
+
decimal.Decimal: FLOAT64,
|
|
1330
|
+
uuid.UUID: STRING,
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
for col in df.columns:
|
|
1334
|
+
series = df[col]
|
|
1335
|
+
if series.empty or series.dropna().empty:
|
|
1336
|
+
continue
|
|
1337
|
+
|
|
1338
|
+
sample = series.dropna().iloc[0]
|
|
1339
|
+
|
|
1340
|
+
for typ, astype_target in astype_map.items():
|
|
1341
|
+
if isinstance(sample, typ):
|
|
1342
|
+
df[col] = series.astype(astype_target)
|
|
1343
|
+
break
|
|
1344
|
+
else:
|
|
1345
|
+
for typ, apply_func in apply_map.items():
|
|
1346
|
+
if isinstance(sample, typ):
|
|
1347
|
+
df[col] = series.apply(apply_func)
|
|
1348
|
+
break
|
|
1349
|
+
|
|
1350
|
+
return df
|
|
1351
|
+
|
|
1352
|
+
|
|
1315
1353
|
def _write_chunk(
|
|
1316
1354
|
chunk: pd.DataFrame,
|
|
1317
1355
|
sa_engine_uri: str,
|
|
@@ -22,15 +22,13 @@ from typing import Literal
|
|
|
22
22
|
import pandas as pd
|
|
23
23
|
import sqlalchemy as sa
|
|
24
24
|
from azure.identity import ClientSecretCredential
|
|
25
|
-
|
|
26
|
-
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
27
|
-
from mostlyai.sdk._data.db.base import DBDType, SqlAlchemyContainer, SqlAlchemyTable
|
|
28
|
-
from mostlyai.sdk._data.util.common import calculate_rows_per_chunk_for_df
|
|
25
|
+
from databricks.sqlalchemy import DatabricksDialect
|
|
29
26
|
from sqlalchemy import text
|
|
30
27
|
from sqlalchemy.exc import SQLAlchemyError
|
|
31
28
|
|
|
32
|
-
from
|
|
33
|
-
|
|
29
|
+
from mostlyai.sdk._data.db.base import DBDType, SqlAlchemyContainer, SqlAlchemyTable
|
|
30
|
+
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
31
|
+
from mostlyai.sdk._data.util.common import calculate_rows_per_chunk_for_df
|
|
34
32
|
|
|
35
33
|
AZURE_DATABRICKS_SERVICE = "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d"
|
|
36
34
|
|
|
@@ -20,16 +20,14 @@ from urllib.parse import quote
|
|
|
20
20
|
|
|
21
21
|
import numpy as np
|
|
22
22
|
import pandas as pd
|
|
23
|
+
import sqlalchemy as sa
|
|
24
|
+
from impala.dbapi import connect as impala_connect
|
|
23
25
|
from impala.sqlalchemy import ImpalaDialect, _impala_type_to_sqlalchemy_type
|
|
24
26
|
from pyhive.sqlalchemy_hive import HiveDialect
|
|
25
|
-
from impala.dbapi import connect as impala_connect
|
|
26
|
-
|
|
27
|
-
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
28
|
-
|
|
29
|
-
from mostlyai.sdk._data.db.base import DBDType, SqlAlchemyContainer, SqlAlchemyTable
|
|
30
|
-
import sqlalchemy as sa
|
|
31
27
|
from sqlalchemy.dialects import registry
|
|
32
28
|
|
|
29
|
+
from mostlyai.sdk._data.db.base import DBDType, SqlAlchemyContainer, SqlAlchemyTable
|
|
30
|
+
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
33
31
|
from mostlyai.sdk._data.util.common import run_with_timeout_unsafe
|
|
34
32
|
|
|
35
33
|
_LOG = logging.getLogger(__name__)
|
|
@@ -21,15 +21,15 @@ import numpy as np
|
|
|
21
21
|
import oracledb
|
|
22
22
|
import pandas as pd
|
|
23
23
|
import sqlalchemy as sa
|
|
24
|
+
import sqlalchemy.dialects.oracle as oracle
|
|
24
25
|
import sqlalchemy.dialects.oracle as sa_oracle
|
|
25
|
-
from pandas.io.sql import
|
|
26
|
+
from pandas.io.sql import SQLDatabase, SQLTable
|
|
26
27
|
from sqlalchemy import text
|
|
27
28
|
from sqlalchemy.dialects.oracle.base import OracleDialect
|
|
28
|
-
import sqlalchemy.dialects.oracle as oracle
|
|
29
29
|
|
|
30
|
-
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
31
30
|
from mostlyai.sdk._data.db.base import DBDType, SqlAlchemyContainer, SqlAlchemyTable
|
|
32
31
|
from mostlyai.sdk._data.dtype import STRING
|
|
32
|
+
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
33
33
|
from mostlyai.sdk._data.util.common import run_with_timeout_unsafe
|
|
34
34
|
|
|
35
35
|
_LOG = logging.getLogger(__name__)
|
|
@@ -26,8 +26,8 @@ import pandas as pd
|
|
|
26
26
|
import pyarrow as pa
|
|
27
27
|
|
|
28
28
|
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
29
|
-
from mostlyai.sdk.domain import ModelEncodingType
|
|
30
29
|
from mostlyai.sdk._data.util.common import absorb_errors
|
|
30
|
+
from mostlyai.sdk.domain import ModelEncodingType
|
|
31
31
|
|
|
32
32
|
STRING = "string[pyarrow]" # This utilizes pyarrow's large string type since pandas 2.2
|
|
33
33
|
INT64 = "int64[pyarrow]"
|
|
@@ -322,6 +322,10 @@ def coerce_dtype_by_encoding(
|
|
|
322
322
|
x = x.astype(STRING)
|
|
323
323
|
elif encoding_type is None or encoding_type == ModelEncodingType.auto:
|
|
324
324
|
# treat keys as strings
|
|
325
|
+
if pd.api.types.is_float_dtype(x):
|
|
326
|
+
# convert float values that represent whole numbers to integers
|
|
327
|
+
if x.dropna().apply(lambda v: float(v).is_integer()).all():
|
|
328
|
+
x = x.astype("Int64")
|
|
325
329
|
x = x.astype(STRING)
|
|
326
330
|
else:
|
|
327
331
|
raise MostlyDataException(f"Incorrect ModelEncodingType {encoding_type} for {x.name}.")
|
|
@@ -18,10 +18,10 @@ import logging
|
|
|
18
18
|
import re
|
|
19
19
|
import time
|
|
20
20
|
from abc import abstractmethod
|
|
21
|
+
from collections.abc import Generator, Iterable
|
|
21
22
|
from enum import Enum
|
|
22
23
|
from pathlib import Path
|
|
23
24
|
from typing import Any
|
|
24
|
-
from collections.abc import Generator, Iterable
|
|
25
25
|
from urllib.parse import urlparse
|
|
26
26
|
|
|
27
27
|
import duckdb
|
|
@@ -33,18 +33,18 @@ from cloudpathlib import AnyPath
|
|
|
33
33
|
from fsspec.implementations.local import LocalFileSystem
|
|
34
34
|
from pyarrow import ArrowIndexError, ArrowInvalid
|
|
35
35
|
|
|
36
|
-
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
37
36
|
from mostlyai.sdk._data.base import (
|
|
38
37
|
DataContainer,
|
|
39
38
|
DataTable,
|
|
40
39
|
order_df_by,
|
|
41
40
|
)
|
|
42
|
-
from mostlyai.sdk._data.util.common import SCHEME_SEP, DATA_TABLE_METADATA_FIELDS, OrderBy, assert_read_only_sql
|
|
43
41
|
from mostlyai.sdk._data.dtype import (
|
|
44
42
|
PandasDType,
|
|
45
43
|
coerce_dtypes_by_encoding,
|
|
46
44
|
pyarrow_to_pandas_map,
|
|
47
45
|
)
|
|
46
|
+
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
47
|
+
from mostlyai.sdk._data.util.common import DATA_TABLE_METADATA_FIELDS, SCHEME_SEP, OrderBy, assert_read_only_sql
|
|
48
48
|
|
|
49
49
|
FILE_DATA_TABLE_LAZY_INIT_FIELDS = DATA_TABLE_METADATA_FIELDS + [
|
|
50
50
|
"columns",
|
|
@@ -14,20 +14,19 @@
|
|
|
14
14
|
|
|
15
15
|
import logging
|
|
16
16
|
import os
|
|
17
|
+
import re
|
|
17
18
|
import tempfile
|
|
18
19
|
from typing import Any
|
|
19
20
|
from urllib.parse import urlparse
|
|
20
|
-
import re
|
|
21
21
|
|
|
22
22
|
import boto3 as boto3
|
|
23
|
+
import duckdb
|
|
23
24
|
import s3fs
|
|
24
25
|
from cloudpathlib.s3 import S3Client, S3Path
|
|
25
|
-
import duckdb
|
|
26
26
|
|
|
27
27
|
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
28
28
|
from mostlyai.sdk._data.file.container.bucket_based import BucketBasedContainer
|
|
29
29
|
|
|
30
|
-
|
|
31
30
|
_LOG = logging.getLogger(__name__)
|
|
32
31
|
|
|
33
32
|
|
|
@@ -17,10 +17,9 @@ import uuid
|
|
|
17
17
|
|
|
18
18
|
import pandas as pd
|
|
19
19
|
|
|
20
|
-
from mostlyai.sdk.domain import ModelType
|
|
21
|
-
|
|
22
20
|
from mostlyai.sdk._data.base import Schema
|
|
23
21
|
from mostlyai.sdk._data.util.common import TABLE_COLUMN_INFIX, TEMPORARY_PRIMARY_KEY
|
|
22
|
+
from mostlyai.sdk.domain import ModelType
|
|
24
23
|
|
|
25
24
|
_LOG = logging.getLogger(__name__)
|
|
26
25
|
|
|
@@ -17,7 +17,7 @@ from copy import copy
|
|
|
17
17
|
|
|
18
18
|
import pandas as pd
|
|
19
19
|
|
|
20
|
-
from mostlyai.sdk._data.base import
|
|
20
|
+
from mostlyai.sdk._data.base import DataIdentifier, DataTable, NonContextRelation, Schema
|
|
21
21
|
|
|
22
22
|
_LOG = logging.getLogger(__name__)
|
|
23
23
|
|
|
@@ -18,9 +18,9 @@ from pathlib import Path
|
|
|
18
18
|
from typing import Any
|
|
19
19
|
|
|
20
20
|
from mostlyai.sdk._data.base import Schema
|
|
21
|
-
from mostlyai.sdk.domain import ModelType
|
|
22
21
|
from mostlyai.sdk._data.progress_callback import ProgressCallbackWrapper
|
|
23
|
-
from mostlyai.sdk._data.pull_utils import
|
|
22
|
+
from mostlyai.sdk._data.pull_utils import handle_workspace_dir, prepare_schema, pull_split
|
|
23
|
+
from mostlyai.sdk.domain import ModelType
|
|
24
24
|
|
|
25
25
|
_LOG = logging.getLogger(__name__)
|
|
26
26
|
|
|
@@ -26,30 +26,30 @@ import numpy as np
|
|
|
26
26
|
import pandas as pd
|
|
27
27
|
import xxhash
|
|
28
28
|
|
|
29
|
-
from mostlyai.sdk.domain import ModelType, ModelEncodingType
|
|
30
29
|
from mostlyai.sdk._data.base import (
|
|
31
30
|
ContextRelation,
|
|
32
31
|
DataIdentifier,
|
|
33
|
-
Schema,
|
|
34
32
|
NonContextRelation,
|
|
33
|
+
Schema,
|
|
35
34
|
)
|
|
36
|
-
from mostlyai.sdk._data.util.common import TEMPORARY_PRIMARY_KEY
|
|
37
35
|
from mostlyai.sdk._data.context import (
|
|
38
36
|
add_gpc_context,
|
|
39
37
|
add_ns_context,
|
|
40
|
-
get_ns_prev_cur_name,
|
|
41
38
|
add_scp_context,
|
|
42
39
|
drop_unsupported_encoding_types_from_context,
|
|
40
|
+
get_ns_prev_cur_name,
|
|
43
41
|
get_table_chain_to_tgt,
|
|
44
42
|
)
|
|
45
43
|
from mostlyai.sdk._data.dtype import STRING
|
|
46
44
|
from mostlyai.sdk._data.file.table.parquet import ParquetDataTable
|
|
47
|
-
from mostlyai.sdk._data.non_context import handle_non_context_relations
|
|
48
45
|
from mostlyai.sdk._data.language_model import (
|
|
49
|
-
split_language_model,
|
|
50
46
|
drop_language_columns_in_target,
|
|
47
|
+
split_language_model,
|
|
51
48
|
)
|
|
49
|
+
from mostlyai.sdk._data.non_context import handle_non_context_relations
|
|
52
50
|
from mostlyai.sdk._data.progress_callback import ProgressCallbackWrapper
|
|
51
|
+
from mostlyai.sdk._data.util.common import TEMPORARY_PRIMARY_KEY
|
|
52
|
+
from mostlyai.sdk.domain import ModelEncodingType, ModelType
|
|
53
53
|
|
|
54
54
|
_LOG = logging.getLogger(__name__)
|
|
55
55
|
|
|
@@ -12,22 +12,22 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
import concurrent.futures
|
|
15
16
|
import hashlib
|
|
16
17
|
import json
|
|
17
18
|
import logging
|
|
18
19
|
import os
|
|
19
20
|
import traceback
|
|
20
21
|
import uuid
|
|
22
|
+
from collections.abc import Callable
|
|
21
23
|
from json import JSONDecodeError
|
|
22
24
|
from pathlib import Path
|
|
23
|
-
from typing import Any,
|
|
24
|
-
from collections.abc import Callable
|
|
25
|
+
from typing import Any, Literal, Union
|
|
25
26
|
|
|
26
27
|
import pandas as pd
|
|
28
|
+
import sqlparse
|
|
27
29
|
from Cryptodome.Cipher import AES
|
|
28
30
|
from Cryptodome.Util.Padding import pad, unpad
|
|
29
|
-
import concurrent.futures
|
|
30
|
-
import sqlparse
|
|
31
31
|
from sqlparse.tokens import DML
|
|
32
32
|
|
|
33
33
|
from mostlyai.sdk._data.exceptions import MostlyDataException
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
import re
|
|
16
|
-
import pandas as pd
|
|
17
16
|
from datetime import datetime
|
|
18
|
-
from dateutil.parser import parse
|
|
19
17
|
from io import StringIO
|
|
20
18
|
|
|
19
|
+
import pandas as pd
|
|
20
|
+
from dateutil.parser import parse
|
|
21
|
+
|
|
21
22
|
|
|
22
23
|
def is_kerberos_ticket_alive(klist_result: str, service_principal: str):
|
|
23
24
|
# Extract the relevant part of the data that contains the tickets
|
|
@@ -16,7 +16,7 @@ from pathlib import Path
|
|
|
16
16
|
|
|
17
17
|
import typer
|
|
18
18
|
|
|
19
|
-
from mostlyai.sdk._local.execution.jobs import
|
|
19
|
+
from mostlyai.sdk._local.execution.jobs import execute_generation_job, execute_training_job
|
|
20
20
|
|
|
21
21
|
cli = typer.Typer(pretty_exceptions_enable=False)
|
|
22
22
|
|
|
@@ -12,25 +12,26 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from pathlib import Path
|
|
16
15
|
from io import BytesIO
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
17
18
|
import pandas as pd
|
|
18
19
|
from fastapi import HTTPException
|
|
19
20
|
|
|
20
21
|
from mostlyai.sdk._data.conversions import create_container_from_connector
|
|
22
|
+
from mostlyai.sdk._data.file.utils import make_data_table_from_container
|
|
21
23
|
from mostlyai.sdk._data.util.common import encrypt, get_passphrase
|
|
22
24
|
from mostlyai.sdk._local.storage import write_connector_to_json
|
|
23
25
|
from mostlyai.sdk.domain import (
|
|
24
|
-
ConnectorConfig,
|
|
25
26
|
Connector,
|
|
26
|
-
ConnectorPatchConfig,
|
|
27
27
|
ConnectorAccessType,
|
|
28
|
-
|
|
29
|
-
ConnectorWriteDataConfig,
|
|
28
|
+
ConnectorConfig,
|
|
30
29
|
ConnectorDeleteDataConfig,
|
|
30
|
+
ConnectorPatchConfig,
|
|
31
|
+
ConnectorReadDataConfig,
|
|
31
32
|
ConnectorType,
|
|
33
|
+
ConnectorWriteDataConfig,
|
|
32
34
|
)
|
|
33
|
-
from mostlyai.sdk._data.file.utils import make_data_table_from_container
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
def create_connector(home_dir: Path, config: ConnectorConfig, test_connection: bool = True) -> Connector:
|