mostlyai 4.0.5__tar.gz → 4.0.6__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.0.5 → mostlyai-4.0.6}/PKG-INFO +31 -32
- {mostlyai-4.0.5 → mostlyai-4.0.6}/README.md +6 -4
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/__init__.py +1 -1
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/jobs.py +1 -1
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/generators.py +38 -1
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/routes.py +13 -15
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/synthetic_datasets.py +28 -20
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/client/base.py +5 -5
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/domain.py +194 -37
- {mostlyai-4.0.5 → mostlyai-4.0.6}/pyproject.toml +33 -29
- {mostlyai-4.0.5 → mostlyai-4.0.6}/.gitignore +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/LICENSE +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/__init__.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/auto_detect.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/base.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/context.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/conversions.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/__init__.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/base.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/bigquery.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/databricks.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/hive.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/mssql.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/mysql.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/oracle.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/postgresql.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/snowflake.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/sqlite.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/dtype.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/exceptions.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/__init__.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/base.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/container/aws.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/container/azure.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/container/minio.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/table/csv.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/table/feather.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/table/json.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/file/utils.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/language_model.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/metadata_objects.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/non_context.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/progress_callback.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/pull.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/pull_context.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/pull_utils.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/push.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/util/__init__.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/util/common.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_data/util/kerberos.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/__init__.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/cli.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/connectors.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/__init__.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/plan.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/progress.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/server.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/storage.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/client/__init__.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/client/_base_utils.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/client/_naming_conventions.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/client/_utils.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/client/api.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/client/connectors.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/client/exceptions.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/client/generators.py +0 -0
- {mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/client/synthetic_datasets.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mostlyai
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.6
|
|
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
|
|
@@ -23,40 +23,35 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
23
23
|
Classifier: Programming Language :: Python :: 3.13
|
|
24
24
|
Classifier: Topic :: Software Development :: Libraries
|
|
25
25
|
Classifier: Typing :: Typed
|
|
26
|
-
Requires-Python:
|
|
26
|
+
Requires-Python: <3.14,>=3.10
|
|
27
27
|
Requires-Dist: adlfs<2024,>=2023.4.0
|
|
28
28
|
Requires-Dist: azure-storage-blob<13,>=12.16.0
|
|
29
29
|
Requires-Dist: cloudpathlib[azure,gs,s3]<0.18,>=0.17.0
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist: environs<10,>=9.5.0
|
|
32
|
-
Requires-Dist: fastparquet<2024,>=2023.4.0
|
|
30
|
+
Requires-Dist: environs>=9.5.0
|
|
33
31
|
Requires-Dist: filelock>=3.16.1
|
|
34
32
|
Requires-Dist: gcsfs<2024,>=2023.1.0
|
|
35
|
-
Requires-Dist: gputil<2,>=1.4.0
|
|
36
33
|
Requires-Dist: greenlet<4,>=3.1.1
|
|
37
|
-
Requires-Dist: gunicorn
|
|
38
|
-
Requires-Dist: httpx
|
|
39
|
-
Requires-Dist: joblib
|
|
40
|
-
Requires-Dist: networkx~=3.1
|
|
34
|
+
Requires-Dist: gunicorn>=23.0.0
|
|
35
|
+
Requires-Dist: httpx>=0.25.0
|
|
36
|
+
Requires-Dist: joblib>=1.2.0
|
|
41
37
|
Requires-Dist: openpyxl>=3.1.5
|
|
42
|
-
Requires-Dist: pandas
|
|
43
|
-
Requires-Dist: psutil
|
|
38
|
+
Requires-Dist: pandas>=2.0.0
|
|
39
|
+
Requires-Dist: psutil>=5.9.5
|
|
44
40
|
Requires-Dist: pyarrow>=16.0.0
|
|
45
|
-
Requires-Dist: pycryptodomex<4,>=3.
|
|
41
|
+
Requires-Dist: pycryptodomex<4,>=3.10.0
|
|
46
42
|
Requires-Dist: pydantic<3,>=2.4.2
|
|
47
|
-
Requires-Dist:
|
|
48
|
-
Requires-Dist: requests<3,>=2.31.0
|
|
43
|
+
Requires-Dist: requests>=2.31.0
|
|
49
44
|
Requires-Dist: rich>=13.7.0
|
|
50
45
|
Requires-Dist: s3fs<2024,>=2023.1.0
|
|
51
|
-
Requires-Dist: schema
|
|
52
|
-
Requires-Dist: semantic-version
|
|
46
|
+
Requires-Dist: schema>=0.7.5
|
|
47
|
+
Requires-Dist: semantic-version>=2.10.0
|
|
53
48
|
Requires-Dist: smart-open>=6.0.0
|
|
54
49
|
Requires-Dist: smart-open[azure,gcs,s3]<7,>=6.3.0
|
|
55
|
-
Requires-Dist: sqlalchemy
|
|
50
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
|
56
51
|
Requires-Dist: sshtunnel<0.5,>=0.4.0
|
|
57
|
-
Requires-Dist: typer
|
|
52
|
+
Requires-Dist: typer>=0.9.0
|
|
58
53
|
Requires-Dist: xlsxwriter<4,>=3.1.9
|
|
59
|
-
Requires-Dist: xxhash
|
|
54
|
+
Requires-Dist: xxhash>=3.2.0
|
|
60
55
|
Provides-Extra: databricks
|
|
61
56
|
Requires-Dist: databricks-sql-connector<4,>=3.2.0; extra == 'databricks'
|
|
62
57
|
Provides-Extra: googlebigquery
|
|
@@ -67,23 +62,25 @@ Requires-Dist: kerberos<2,>=1.3.1; extra == 'hive'
|
|
|
67
62
|
Requires-Dist: pyhive[hive-pure-sasl]<0.8,>=0.7.0; extra == 'hive'
|
|
68
63
|
Provides-Extra: local
|
|
69
64
|
Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local'
|
|
70
|
-
Requires-Dist: mostlyai-engine==1.0.
|
|
71
|
-
Requires-Dist: mostlyai-qa==1.5.
|
|
65
|
+
Requires-Dist: mostlyai-engine==1.0.3; extra == 'local'
|
|
66
|
+
Requires-Dist: mostlyai-qa==1.5.2; extra == 'local'
|
|
72
67
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local'
|
|
68
|
+
Requires-Dist: torch<2.6.0,>=2.5.1; extra == 'local'
|
|
73
69
|
Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local'
|
|
74
70
|
Provides-Extra: local-cpu
|
|
75
71
|
Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-cpu'
|
|
76
|
-
Requires-Dist: mostlyai-engine[cpu]==1.0.
|
|
77
|
-
Requires-Dist: mostlyai-qa==1.5.
|
|
72
|
+
Requires-Dist: mostlyai-engine[cpu]==1.0.3; extra == 'local-cpu'
|
|
73
|
+
Requires-Dist: mostlyai-qa[cpu]==1.5.2; extra == 'local-cpu'
|
|
78
74
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local-cpu'
|
|
79
|
-
Requires-Dist: torch
|
|
75
|
+
Requires-Dist: torch<2.6.0,>=2.5.1; (sys_platform != 'linux') and extra == 'local-cpu'
|
|
76
|
+
Requires-Dist: torch==2.5.1+cpu; (sys_platform == 'linux') and extra == 'local-cpu'
|
|
80
77
|
Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local-cpu'
|
|
81
78
|
Provides-Extra: local-gpu
|
|
82
79
|
Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-gpu'
|
|
83
|
-
Requires-Dist: mostlyai-engine[gpu]==1.0.
|
|
84
|
-
Requires-Dist: mostlyai-qa==1.5.
|
|
80
|
+
Requires-Dist: mostlyai-engine[gpu]==1.0.3; extra == 'local-gpu'
|
|
81
|
+
Requires-Dist: mostlyai-qa[gpu]==1.5.2; extra == 'local-gpu'
|
|
85
82
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local-gpu'
|
|
86
|
-
Requires-Dist: torch
|
|
83
|
+
Requires-Dist: torch<2.6.0,>=2.5.1; extra == 'local-gpu'
|
|
87
84
|
Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local-gpu'
|
|
88
85
|
Provides-Extra: mssql
|
|
89
86
|
Requires-Dist: pyodbc<6,>=5.1.0; extra == 'mssql'
|
|
@@ -136,12 +133,14 @@ pip install -U mostlyai
|
|
|
136
133
|
**Client + Local mode**
|
|
137
134
|
|
|
138
135
|
```shell
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
# for CPU on macOS
|
|
137
|
+
pip install -U 'mostlyai[local]'
|
|
138
|
+
# for CPU on Linux
|
|
139
|
+
#pip install -U mostlyai[local] --extra-index-url https://download.pytorch.org/whl/cpu
|
|
140
|
+
# for GPU on Linux
|
|
141
|
+
#pip install -U mostlyai[local-gpu]
|
|
141
142
|
```
|
|
142
143
|
|
|
143
|
-
NOTE: installing `mostlyai[local]` on Linux requires `--extra-index-url https://download.pytorch.org/whl/cpu` to be specified.
|
|
144
|
-
|
|
145
144
|
**Optional Connectors**
|
|
146
145
|
|
|
147
146
|
Add any of the following extras for further data connectors support: `databricks`, `googlebigquery`, `hive`, `mssql`, `mysql`, `oracle`, `postgres`, `snowflake`.
|
|
@@ -37,12 +37,14 @@ pip install -U mostlyai
|
|
|
37
37
|
**Client + Local mode**
|
|
38
38
|
|
|
39
39
|
```shell
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
# for CPU on macOS
|
|
41
|
+
pip install -U 'mostlyai[local]'
|
|
42
|
+
# for CPU on Linux
|
|
43
|
+
#pip install -U mostlyai[local] --extra-index-url https://download.pytorch.org/whl/cpu
|
|
44
|
+
# for GPU on Linux
|
|
45
|
+
#pip install -U mostlyai[local-gpu]
|
|
42
46
|
```
|
|
43
47
|
|
|
44
|
-
NOTE: installing `mostlyai[local]` on Linux requires `--extra-index-url https://download.pytorch.org/whl/cpu` to be specified.
|
|
45
|
-
|
|
46
48
|
**Optional Connectors**
|
|
47
49
|
|
|
48
50
|
Add any of the following extras for further data connectors support: `databricks`, `googlebigquery`, `hive`, `mssql`, `mysql`, `oracle`, `postgres`, `snowflake`.
|
|
@@ -170,7 +170,7 @@ def _set_overall_accuracy(generator: Generator) -> None:
|
|
|
170
170
|
|
|
171
171
|
def _probe_random_samples(home_dir: Path, generator: Generator) -> None:
|
|
172
172
|
config = SyntheticProbeConfig(generator_id=generator.id)
|
|
173
|
-
synthetic_dataset = create_synthetic_dataset(home_dir=home_dir, config=config,
|
|
173
|
+
synthetic_dataset = create_synthetic_dataset(home_dir=home_dir, config=config, sample_size=20)
|
|
174
174
|
probes = execute_probing_job(synthetic_dataset_id=synthetic_dataset.id, home_dir=home_dir)
|
|
175
175
|
|
|
176
176
|
random_samples_dir = home_dir / "generators" / generator.id / "RandomSamples"
|
|
@@ -14,7 +14,12 @@
|
|
|
14
14
|
|
|
15
15
|
from pathlib import Path
|
|
16
16
|
|
|
17
|
-
from mostlyai.sdk._local.storage import
|
|
17
|
+
from mostlyai.sdk._local.storage import (
|
|
18
|
+
write_generator_to_json,
|
|
19
|
+
write_connector_to_json,
|
|
20
|
+
write_job_progress_to_json,
|
|
21
|
+
read_generator_from_json,
|
|
22
|
+
)
|
|
18
23
|
from mostlyai.sdk._local.execution.plan import has_tabular_model, has_language_model, TRAINING_TASK_STEPS
|
|
19
24
|
from mostlyai.sdk.client._base_utils import convert_to_df
|
|
20
25
|
from mostlyai.sdk.domain import (
|
|
@@ -30,6 +35,8 @@ from mostlyai.sdk.domain import (
|
|
|
30
35
|
ProgressValue,
|
|
31
36
|
JobProgress,
|
|
32
37
|
TaskType,
|
|
38
|
+
SourceTableConfig,
|
|
39
|
+
SourceForeignKeyConfig,
|
|
33
40
|
)
|
|
34
41
|
|
|
35
42
|
|
|
@@ -108,3 +115,33 @@ def create_generator(home_dir: Path, config: GeneratorConfig) -> Generator:
|
|
|
108
115
|
write_job_progress_to_json(generator_dir, job_progress)
|
|
109
116
|
|
|
110
117
|
return generator
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def get_generator_config(home_dir: Path, generator_id: str) -> GeneratorConfig:
|
|
121
|
+
generator_dir = home_dir / "generators" / generator_id
|
|
122
|
+
generator = read_generator_from_json(generator_dir)
|
|
123
|
+
# construct GeneratorConfig explicitly to avoid validation warnings of extra fields
|
|
124
|
+
config = GeneratorConfig(
|
|
125
|
+
name=generator.name,
|
|
126
|
+
description=generator.description,
|
|
127
|
+
tables=[
|
|
128
|
+
SourceTableConfig(
|
|
129
|
+
name=t.name,
|
|
130
|
+
source_connector_id=t.source_connector_id,
|
|
131
|
+
location=t.location,
|
|
132
|
+
tabular_model_configuration=t.tabular_model_configuration,
|
|
133
|
+
language_model_configuration=t.language_model_configuration,
|
|
134
|
+
primary_key=t.primary_key,
|
|
135
|
+
foreign_keys=[SourceForeignKeyConfig.model_construct(**k.model_dump()) for k in t.foreign_keys]
|
|
136
|
+
if t.foreign_keys
|
|
137
|
+
else None,
|
|
138
|
+
columns=[SourceColumnConfig.model_construct(**c.model_dump()) for c in t.columns]
|
|
139
|
+
if t.columns
|
|
140
|
+
else None,
|
|
141
|
+
)
|
|
142
|
+
for t in generator.tables
|
|
143
|
+
]
|
|
144
|
+
if generator.tables
|
|
145
|
+
else None,
|
|
146
|
+
)
|
|
147
|
+
return config
|
|
@@ -54,6 +54,7 @@ from mostlyai.sdk.domain import (
|
|
|
54
54
|
GeneratorCloneConfig,
|
|
55
55
|
GeneratorCloneTrainingStatus,
|
|
56
56
|
SyntheticDatasetReportType,
|
|
57
|
+
SyntheticDatasetListItem,
|
|
57
58
|
)
|
|
58
59
|
from mostlyai.sdk._local.storage import (
|
|
59
60
|
read_generator_from_json,
|
|
@@ -183,7 +184,8 @@ class Routes:
|
|
|
183
184
|
connector = read_connector_from_json(connector_dir)
|
|
184
185
|
if not searchTerm or searchTerm.lower() in (connector.name or "").lower():
|
|
185
186
|
if not access_type or access_type == connector.access_type:
|
|
186
|
-
|
|
187
|
+
# use model_construct to skip validation and warnings of extra fields
|
|
188
|
+
connector_list_items.append(ConnectorListItem.model_construct(**connector.model_dump()))
|
|
187
189
|
|
|
188
190
|
# use jsonable_encoder to handle non-serializable objects like datetime
|
|
189
191
|
return JSONResponse(
|
|
@@ -278,7 +280,8 @@ class Routes:
|
|
|
278
280
|
or searchTerm.lower() in (generator.description or "").lower()
|
|
279
281
|
):
|
|
280
282
|
if not status or status == generator.training_status:
|
|
281
|
-
|
|
283
|
+
# use model_construct to skip validation and warnings of extra fields
|
|
284
|
+
generator_list_items.append(GeneratorListItem.model_construct(**generator.model_dump()))
|
|
282
285
|
# use jsonable_encoder to handle non-serializable objects like datetime
|
|
283
286
|
return JSONResponse(
|
|
284
287
|
status_code=200,
|
|
@@ -338,10 +341,8 @@ class Routes:
|
|
|
338
341
|
# check if any connectors are file upload
|
|
339
342
|
if any(read_connector_from_json(c).type == ConnectorType.file_upload for c in connector_dirs):
|
|
340
343
|
raise HTTPException(status_code=400, detail="Cannot clone a generator with uploaded files.")
|
|
341
|
-
|
|
342
|
-
new_generator = create_generator_model(
|
|
343
|
-
home_dir=self.home_dir, config=GeneratorConfig(**generator.model_dump())
|
|
344
|
-
)
|
|
344
|
+
generator_config = generators.get_generator_config(self.home_dir, id)
|
|
345
|
+
new_generator = create_generator_model(home_dir=self.home_dir, config=generator_config)
|
|
345
346
|
new_generator_dir = self.home_dir / "generators" / new_generator.id
|
|
346
347
|
if config.training_status == GeneratorCloneTrainingStatus.continue_:
|
|
347
348
|
new_generator.training_status = ProgressStatus.continue_
|
|
@@ -410,10 +411,7 @@ class Routes:
|
|
|
410
411
|
|
|
411
412
|
@self.router.get("/generators/{id}/config", response_model=GeneratorConfig)
|
|
412
413
|
async def get_generator_config(id: str) -> GeneratorConfig:
|
|
413
|
-
|
|
414
|
-
generator = read_generator_from_json(generator_dir)
|
|
415
|
-
config = GeneratorConfig(**generator.model_dump())
|
|
416
|
-
return config
|
|
414
|
+
return generators.get_generator_config(self.home_dir, id)
|
|
417
415
|
|
|
418
416
|
### SYNTHETIC DATASETS
|
|
419
417
|
|
|
@@ -431,7 +429,10 @@ class Routes:
|
|
|
431
429
|
or searchTerm.lower() in (synthetic_dataset.description or "").lower()
|
|
432
430
|
):
|
|
433
431
|
if not status or status == synthetic_dataset.generation_status:
|
|
434
|
-
|
|
432
|
+
# use model_construct to skip validation and warnings of extra fields
|
|
433
|
+
synthetic_dataset_list_items.append(
|
|
434
|
+
SyntheticDatasetListItem.model_construct(**synthetic_dataset.model_dump())
|
|
435
|
+
)
|
|
435
436
|
# use jsonable_encoder to handle non-serializable objects like datetime
|
|
436
437
|
return JSONResponse(
|
|
437
438
|
status_code=200,
|
|
@@ -505,10 +506,7 @@ class Routes:
|
|
|
505
506
|
|
|
506
507
|
@self.router.get("/synthetic-datasets/{id}/config", response_model=SyntheticDatasetConfig)
|
|
507
508
|
async def get_synthetic_dataset_config(id: str) -> SyntheticDatasetConfig:
|
|
508
|
-
|
|
509
|
-
synthetic_dataset = read_synthetic_dataset_from_json(synthetic_dataset_dir)
|
|
510
|
-
config = SyntheticDatasetConfig(**synthetic_dataset.model_dump())
|
|
511
|
-
return config
|
|
509
|
+
return synthetic_datasets.get_synthetic_dataset_config(self.home_dir, id)
|
|
512
510
|
|
|
513
511
|
@self.router.get("/synthetic-datasets/{id}/download", response_class=FileResponse)
|
|
514
512
|
async def download_synthetic_dataset(id: str, slft: str, format: str) -> FileResponse:
|
|
@@ -19,6 +19,7 @@ from mostlyai.sdk._local.storage import (
|
|
|
19
19
|
write_job_progress_to_json,
|
|
20
20
|
read_generator_from_json,
|
|
21
21
|
write_connector_to_json,
|
|
22
|
+
read_synthetic_dataset_from_json,
|
|
22
23
|
)
|
|
23
24
|
from mostlyai.sdk._local.execution.plan import (
|
|
24
25
|
has_tabular_model,
|
|
@@ -36,19 +37,19 @@ from mostlyai.sdk.domain import (
|
|
|
36
37
|
ProgressValue,
|
|
37
38
|
JobProgress,
|
|
38
39
|
SyntheticTable,
|
|
39
|
-
SyntheticTableConfiguration,
|
|
40
40
|
TaskType,
|
|
41
41
|
Connector,
|
|
42
42
|
ConnectorType,
|
|
43
43
|
ConnectorAccessType,
|
|
44
44
|
SyntheticProbeConfig,
|
|
45
|
+
SyntheticTableConfig,
|
|
45
46
|
)
|
|
46
47
|
|
|
47
48
|
|
|
48
49
|
def create_synthetic_dataset(
|
|
49
50
|
home_dir: Path,
|
|
50
51
|
config: SyntheticDatasetConfig | SyntheticProbeConfig,
|
|
51
|
-
|
|
52
|
+
sample_size: int | None = None,
|
|
52
53
|
) -> SyntheticDataset:
|
|
53
54
|
# create a FILE_UPLOAD connector and replace sample_seed_dict/sample_seed_data with sample_seed_connector_id
|
|
54
55
|
for t in config.tables or []:
|
|
@@ -77,30 +78,21 @@ def create_synthetic_dataset(
|
|
|
77
78
|
generator_dir = home_dir / "generators" / config.generator_id
|
|
78
79
|
generator = read_generator_from_json(generator_dir)
|
|
79
80
|
|
|
80
|
-
# fill
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
# validate & fill defaults in config against generator
|
|
82
|
+
config.validate_against_generator(generator)
|
|
83
|
+
|
|
84
|
+
# create synthetic tables
|
|
83
85
|
sd_tables = []
|
|
84
86
|
for g_table in generator.tables:
|
|
85
|
-
|
|
86
|
-
sd_table = SyntheticTable(**next(t for t in config.tables if t.name == g_table.name).model_dump())
|
|
87
|
-
else:
|
|
88
|
-
sd_table = SyntheticTable(name=g_table.name)
|
|
87
|
+
sd_table = SyntheticTable(**next(t for t in config.tables if t.name == g_table.name).model_dump())
|
|
89
88
|
sd_table.foreign_keys = g_table.foreign_keys
|
|
90
89
|
sd_table.source_table_total_rows = g_table.total_rows
|
|
91
|
-
if sd_table.configuration is None:
|
|
92
|
-
sd_table.configuration = SyntheticTableConfiguration()
|
|
93
|
-
is_subject = not any(fk.is_context for fk in g_table.foreign_keys or [])
|
|
94
|
-
if is_subject and sd_table.configuration.sample_size is None:
|
|
95
|
-
if isinstance(size, int):
|
|
96
|
-
sd_table.configuration.sample_size = size
|
|
97
|
-
else: # isinstance(size, dict)
|
|
98
|
-
default_sample_size = 1 if isinstance(config, SyntheticProbeConfig) else g_table.total_rows
|
|
99
|
-
sd_table.configuration.sample_size = size.get(g_table.name, default_sample_size)
|
|
100
|
-
elif not is_subject:
|
|
101
|
-
sd_table.configuration.sample_size = None # sample size is not applicable to linked tables
|
|
102
90
|
sd_table.tabular_model_metrics = g_table.tabular_model_metrics
|
|
103
91
|
sd_table.language_model_metrics = g_table.language_model_metrics
|
|
92
|
+
# overwrite sample size of subject table, if provided
|
|
93
|
+
is_subject = not any(fk.is_context for fk in g_table.foreign_keys or [])
|
|
94
|
+
if is_subject and sample_size is not None:
|
|
95
|
+
sd_table.configuration.sample_size = sample_size
|
|
104
96
|
sd_tables.append(sd_table)
|
|
105
97
|
|
|
106
98
|
# create synthetic dataset
|
|
@@ -161,3 +153,19 @@ def create_synthetic_dataset(
|
|
|
161
153
|
)
|
|
162
154
|
write_job_progress_to_json(synthetic_dataset_dir, job_progress)
|
|
163
155
|
return synthetic_dataset
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def get_synthetic_dataset_config(home_dir: Path, synthetic_dataset_id: str) -> SyntheticDatasetConfig:
|
|
159
|
+
synthetic_dataset_dir = home_dir / "synthetic-datasets" / synthetic_dataset_id
|
|
160
|
+
synthetic_dataset = read_synthetic_dataset_from_json(synthetic_dataset_dir)
|
|
161
|
+
# construct SyntheticDatasetConfig explicitly to avoid validation warnings of extra fields
|
|
162
|
+
config = SyntheticDatasetConfig(
|
|
163
|
+
generator_id=synthetic_dataset.generator_id,
|
|
164
|
+
name=synthetic_dataset.name,
|
|
165
|
+
description=synthetic_dataset.description,
|
|
166
|
+
tables=[SyntheticTableConfig.model_construct(**t.model_dump()) for t in synthetic_dataset.tables]
|
|
167
|
+
if synthetic_dataset.tables
|
|
168
|
+
else None,
|
|
169
|
+
delivery=synthetic_dataset.delivery,
|
|
170
|
+
)
|
|
171
|
+
return config
|
|
@@ -221,7 +221,7 @@ class Paginator(Generic[T]):
|
|
|
221
221
|
item = self.page_items[self.index_in_page]
|
|
222
222
|
self.index_in_page += 1
|
|
223
223
|
self.index += 1
|
|
224
|
-
return self.response_class(**item, client=self.client
|
|
224
|
+
return self.response_class(**item, client=self.client)
|
|
225
225
|
|
|
226
226
|
def _fetch_page(self):
|
|
227
227
|
if self.is_last_page:
|
|
@@ -247,10 +247,10 @@ class CustomBaseModel(BaseModel):
|
|
|
247
247
|
|
|
248
248
|
@model_validator(mode="before")
|
|
249
249
|
def __warn_extra_fields__(cls, values):
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
250
|
+
if isinstance(values, dict):
|
|
251
|
+
extra_fields = values.keys() - cls.model_fields.keys() - {v.alias for v in cls.model_fields.values()}
|
|
252
|
+
if extra_fields:
|
|
253
|
+
_LOG.warning(f"ignoring unrecognized fields for {cls.__name__}: {', '.join(extra_fields)}")
|
|
254
254
|
return values
|
|
255
255
|
|
|
256
256
|
def _repr_html_(self):
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
# generated by datamodel-codegen:
|
|
16
|
-
# timestamp: 2025-01-
|
|
16
|
+
# timestamp: 2025-01-30T19:49:04+00:00
|
|
17
17
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
@@ -37,7 +37,7 @@ class AboutService(CustomBaseModel):
|
|
|
37
37
|
General information about the service.
|
|
38
38
|
"""
|
|
39
39
|
|
|
40
|
-
version: str | None = Field(None, description="The version number of the service.", examples=["
|
|
40
|
+
version: str | None = Field(None, description="The version number of the service.", examples=["4.0.0"])
|
|
41
41
|
assistant: bool | None = Field(None, description="A flag indicating if the assistant is enabled.")
|
|
42
42
|
|
|
43
43
|
|
|
@@ -406,8 +406,9 @@ class SourceForeignKey(CustomBaseModel):
|
|
|
406
406
|
@model_validator(mode="before")
|
|
407
407
|
@classmethod
|
|
408
408
|
def add_required_fields(cls, values):
|
|
409
|
-
if
|
|
410
|
-
|
|
409
|
+
if isinstance(values, dict):
|
|
410
|
+
if "id" not in values:
|
|
411
|
+
values["id"] = str(uuid.uuid4())
|
|
411
412
|
return values
|
|
412
413
|
|
|
413
414
|
|
|
@@ -1493,8 +1494,9 @@ class Connector(CustomBaseModel):
|
|
|
1493
1494
|
@model_validator(mode="before")
|
|
1494
1495
|
@classmethod
|
|
1495
1496
|
def add_required_fields(cls, values):
|
|
1496
|
-
if
|
|
1497
|
-
|
|
1497
|
+
if isinstance(values, dict):
|
|
1498
|
+
if "id" not in values:
|
|
1499
|
+
values["id"] = str(uuid.uuid4())
|
|
1498
1500
|
return values
|
|
1499
1501
|
|
|
1500
1502
|
def update(
|
|
@@ -1645,12 +1647,13 @@ class SourceColumn(CustomBaseModel):
|
|
|
1645
1647
|
@model_validator(mode="before")
|
|
1646
1648
|
@classmethod
|
|
1647
1649
|
def add_required_fields(cls, values):
|
|
1648
|
-
if
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1650
|
+
if isinstance(values, dict):
|
|
1651
|
+
if "id" not in values:
|
|
1652
|
+
values["id"] = str(uuid.uuid4())
|
|
1653
|
+
if "model_encoding_type" not in values:
|
|
1654
|
+
values["model_encoding_type"] = ModelEncodingType.auto
|
|
1655
|
+
if "included" not in values:
|
|
1656
|
+
values["included"] = True
|
|
1654
1657
|
return values
|
|
1655
1658
|
|
|
1656
1659
|
|
|
@@ -1802,15 +1805,15 @@ class ProgressStep(CustomBaseModel):
|
|
|
1802
1805
|
progress: ProgressValue | None = None
|
|
1803
1806
|
status: ProgressStatus | None = None
|
|
1804
1807
|
|
|
1805
|
-
@model_validator(mode="
|
|
1808
|
+
@model_validator(mode="after")
|
|
1806
1809
|
@classmethod
|
|
1807
1810
|
def add_required_fields(cls, values):
|
|
1808
|
-
if
|
|
1809
|
-
values
|
|
1810
|
-
if
|
|
1811
|
-
values
|
|
1812
|
-
if
|
|
1813
|
-
values
|
|
1811
|
+
if values.id is None:
|
|
1812
|
+
values.id = str(uuid.uuid4())
|
|
1813
|
+
if values.status is None:
|
|
1814
|
+
values.status = ProgressStatus.new
|
|
1815
|
+
if values.compute_name is None:
|
|
1816
|
+
values.compute_name = "SDK"
|
|
1814
1817
|
return values
|
|
1815
1818
|
|
|
1816
1819
|
|
|
@@ -1854,7 +1857,7 @@ class SyntheticTableConfiguration(CustomBaseModel):
|
|
|
1854
1857
|
sample_size: int | None = Field(
|
|
1855
1858
|
None,
|
|
1856
1859
|
alias="sampleSize",
|
|
1857
|
-
description="Number of generated samples. Only applicable for subject tables.\nIf neither size nor seed is provided, then the default behavior for Synthetic Datasets is to generate the\nsame size of samples as the original, and the default behavior for Synthetic
|
|
1860
|
+
description="Number of generated samples. Only applicable for subject tables.\nIf neither size nor seed is provided, then the default behavior for Synthetic Datasets is to generate the\nsame size of samples as the original, and the default behavior for Synthetic Probes is to generate one\nsubject only.\n",
|
|
1858
1861
|
ge=1,
|
|
1859
1862
|
)
|
|
1860
1863
|
sample_seed_connector_id: str | None = Field(
|
|
@@ -1904,13 +1907,13 @@ class SyntheticTableConfiguration(CustomBaseModel):
|
|
|
1904
1907
|
def convert_data_before(cls, value):
|
|
1905
1908
|
return convert_to_base64(value) if isinstance(value, pd.DataFrame) else value
|
|
1906
1909
|
|
|
1907
|
-
@model_validator(mode="
|
|
1910
|
+
@model_validator(mode="after")
|
|
1908
1911
|
@classmethod
|
|
1909
1912
|
def add_required_fields(cls, values):
|
|
1910
|
-
if
|
|
1911
|
-
values
|
|
1912
|
-
if
|
|
1913
|
-
values
|
|
1913
|
+
if values.sampling_temperature is None:
|
|
1914
|
+
values.sampling_temperature = 1.0
|
|
1915
|
+
if values.sampling_top_p is None:
|
|
1916
|
+
values.sampling_top_p = 1.0
|
|
1914
1917
|
return values
|
|
1915
1918
|
|
|
1916
1919
|
|
|
@@ -1933,6 +1936,13 @@ class SyntheticTableConfig(CustomBaseModel):
|
|
|
1933
1936
|
)
|
|
1934
1937
|
configuration: SyntheticTableConfiguration | None = None
|
|
1935
1938
|
|
|
1939
|
+
@model_validator(mode="after")
|
|
1940
|
+
@classmethod
|
|
1941
|
+
def add_configuration(cls, values):
|
|
1942
|
+
if values.configuration is None:
|
|
1943
|
+
values.configuration = SyntheticTableConfiguration()
|
|
1944
|
+
return values
|
|
1945
|
+
|
|
1936
1946
|
|
|
1937
1947
|
class AssistantThreadListItem(CustomBaseModel):
|
|
1938
1948
|
"""
|
|
@@ -2049,8 +2059,9 @@ class SourceTable(CustomBaseModel):
|
|
|
2049
2059
|
@model_validator(mode="before")
|
|
2050
2060
|
@classmethod
|
|
2051
2061
|
def add_required_fields(cls, values):
|
|
2052
|
-
if
|
|
2053
|
-
|
|
2062
|
+
if isinstance(values, dict):
|
|
2063
|
+
if "id" not in values:
|
|
2064
|
+
values["id"] = str(uuid.uuid4())
|
|
2054
2065
|
return values
|
|
2055
2066
|
|
|
2056
2067
|
|
|
@@ -2274,8 +2285,9 @@ class SyntheticTable(CustomBaseModel):
|
|
|
2274
2285
|
@model_validator(mode="before")
|
|
2275
2286
|
@classmethod
|
|
2276
2287
|
def add_required_fields(cls, values):
|
|
2277
|
-
if
|
|
2278
|
-
|
|
2288
|
+
if isinstance(values, dict):
|
|
2289
|
+
if "id" not in values:
|
|
2290
|
+
values["id"] = str(uuid.uuid4())
|
|
2279
2291
|
return values
|
|
2280
2292
|
|
|
2281
2293
|
|
|
@@ -2290,6 +2302,19 @@ class SyntheticDatasetConfig(CustomBaseModel):
|
|
|
2290
2302
|
tables: list[SyntheticTableConfig] | None = None
|
|
2291
2303
|
delivery: SyntheticDatasetDelivery | None = None
|
|
2292
2304
|
|
|
2305
|
+
@field_validator("tables", mode="after")
|
|
2306
|
+
@classmethod
|
|
2307
|
+
def validate_unique_table_names(cls, tables):
|
|
2308
|
+
if not tables:
|
|
2309
|
+
return tables
|
|
2310
|
+
defined_tables = [t.name for t in tables]
|
|
2311
|
+
if len(defined_tables) != len(set(defined_tables)):
|
|
2312
|
+
raise ValueError("Table names must be unique.")
|
|
2313
|
+
return tables
|
|
2314
|
+
|
|
2315
|
+
def validate_against_generator(self, generator: Generator) -> None:
|
|
2316
|
+
_SyntheticConfigValidation(synthetic_config=self, generator=generator)
|
|
2317
|
+
|
|
2293
2318
|
|
|
2294
2319
|
class SyntheticProbeConfig(CustomBaseModel):
|
|
2295
2320
|
"""
|
|
@@ -2299,6 +2324,19 @@ class SyntheticProbeConfig(CustomBaseModel):
|
|
|
2299
2324
|
generator_id: str | None = Field(None, alias="generatorId", description="The unique identifier of a generator.")
|
|
2300
2325
|
tables: list[SyntheticTableConfig] | None = None
|
|
2301
2326
|
|
|
2327
|
+
@field_validator("tables", mode="after")
|
|
2328
|
+
@classmethod
|
|
2329
|
+
def validate_unique_table_names(cls, tables):
|
|
2330
|
+
if not tables:
|
|
2331
|
+
return tables
|
|
2332
|
+
defined_tables = [t.name for t in tables]
|
|
2333
|
+
if len(defined_tables) != len(set(defined_tables)):
|
|
2334
|
+
raise ValueError("Table names must be unique.")
|
|
2335
|
+
return tables
|
|
2336
|
+
|
|
2337
|
+
def validate_against_generator(self, generator: Generator) -> None:
|
|
2338
|
+
_SyntheticConfigValidation(synthetic_config=self, generator=generator)
|
|
2339
|
+
|
|
2302
2340
|
|
|
2303
2341
|
class Generator(CustomBaseModel):
|
|
2304
2342
|
"""
|
|
@@ -2330,10 +2368,11 @@ class Generator(CustomBaseModel):
|
|
|
2330
2368
|
@model_validator(mode="before")
|
|
2331
2369
|
@classmethod
|
|
2332
2370
|
def add_required_fields(cls, values):
|
|
2333
|
-
if
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2371
|
+
if isinstance(values, dict):
|
|
2372
|
+
if "id" not in values:
|
|
2373
|
+
values["id"] = str(uuid.uuid4())
|
|
2374
|
+
if "training_status" not in values:
|
|
2375
|
+
values["training_status"] = ProgressStatus.new
|
|
2337
2376
|
return values
|
|
2338
2377
|
|
|
2339
2378
|
def __init__(self, *args, **kwargs):
|
|
@@ -2582,10 +2621,11 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2582
2621
|
@model_validator(mode="before")
|
|
2583
2622
|
@classmethod
|
|
2584
2623
|
def add_required_fields(cls, values):
|
|
2585
|
-
if
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2624
|
+
if isinstance(values, dict):
|
|
2625
|
+
if "id" not in values:
|
|
2626
|
+
values["id"] = str(uuid.uuid4())
|
|
2627
|
+
if "generation_status" not in values:
|
|
2628
|
+
values["generation_status"] = ProgressStatus.new
|
|
2589
2629
|
return values
|
|
2590
2630
|
|
|
2591
2631
|
def __init__(self, *args, **kwargs):
|
|
@@ -2769,3 +2809,120 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2769
2809
|
"Use it to consume the generated data. "
|
|
2770
2810
|
"Publish it so others can do the same."
|
|
2771
2811
|
)
|
|
2812
|
+
|
|
2813
|
+
|
|
2814
|
+
class _SyntheticConfigValidation(CustomBaseModel):
|
|
2815
|
+
"""
|
|
2816
|
+
Shared validation logic for SyntheticDatasetConfig and SyntheticProbeConfig against Generator.
|
|
2817
|
+
"""
|
|
2818
|
+
|
|
2819
|
+
synthetic_config: SyntheticDatasetConfig | SyntheticProbeConfig
|
|
2820
|
+
generator: Generator
|
|
2821
|
+
|
|
2822
|
+
@model_validator(mode="after")
|
|
2823
|
+
def add_missing_tables(cls, validation):
|
|
2824
|
+
generator_table_map = {t.name: t for t in validation.generator.tables}
|
|
2825
|
+
if validation.synthetic_config.tables is None:
|
|
2826
|
+
validation.synthetic_config.tables = []
|
|
2827
|
+
synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables}
|
|
2828
|
+
missing_tables = set(generator_table_map.keys()) - set(synthetic_table_map.keys())
|
|
2829
|
+
for t in missing_tables:
|
|
2830
|
+
validation.synthetic_config.tables.append(SyntheticTableConfig(name=t))
|
|
2831
|
+
return validation
|
|
2832
|
+
|
|
2833
|
+
@model_validator(mode="after")
|
|
2834
|
+
def validate_no_extra_tables(cls, validation):
|
|
2835
|
+
generator_table_map = {t.name: t for t in validation.generator.tables}
|
|
2836
|
+
synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
|
|
2837
|
+
extra_tables = set(synthetic_table_map.keys()) - set(generator_table_map.keys())
|
|
2838
|
+
if extra_tables:
|
|
2839
|
+
raise ValueError(f"Extra tables in synthetic config not present in generator: {extra_tables}")
|
|
2840
|
+
return validation
|
|
2841
|
+
|
|
2842
|
+
@model_validator(mode="after")
|
|
2843
|
+
def validate_rebalancing_configs(cls, validation):
|
|
2844
|
+
generator_table_map = {t.name: t for t in validation.generator.tables}
|
|
2845
|
+
synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
|
|
2846
|
+
for table_name, synthetic_table in synthetic_table_map.items():
|
|
2847
|
+
generator_table = generator_table_map[table_name]
|
|
2848
|
+
config = synthetic_table.configuration
|
|
2849
|
+
if config and config.rebalancing:
|
|
2850
|
+
has_tabular_model = generator_table.tabular_model_configuration is not None
|
|
2851
|
+
if not has_tabular_model:
|
|
2852
|
+
raise ValueError(f"Table '{table_name}' specifies rebalancing but has no tabular model")
|
|
2853
|
+
rebalancing_column = config.rebalancing.column
|
|
2854
|
+
rebalancing_col = next(
|
|
2855
|
+
(col for col in generator_table.columns or [] if col.name == rebalancing_column), None
|
|
2856
|
+
)
|
|
2857
|
+
if not rebalancing_col:
|
|
2858
|
+
raise ValueError(f"Rebalancing column '{rebalancing_column}' not found in table '{table_name}'")
|
|
2859
|
+
if not rebalancing_col.model_encoding_type == ModelEncodingType.tabular_categorical:
|
|
2860
|
+
raise ValueError(
|
|
2861
|
+
f"Rebalancing column '{rebalancing_column}' in table '{table_name}' must be categorical"
|
|
2862
|
+
)
|
|
2863
|
+
for value in config.rebalancing.probabilities.keys():
|
|
2864
|
+
if value not in rebalancing_col.value_range.values:
|
|
2865
|
+
raise ValueError(
|
|
2866
|
+
f"Rebalancing value '{value}' not found in table '{table_name}' column '{rebalancing_column}'"
|
|
2867
|
+
)
|
|
2868
|
+
return validation
|
|
2869
|
+
|
|
2870
|
+
@model_validator(mode="after")
|
|
2871
|
+
def validate_imputation_configs(cls, validation):
|
|
2872
|
+
generator_table_map = {t.name: t for t in validation.generator.tables}
|
|
2873
|
+
synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
|
|
2874
|
+
for table_name, synthetic_table in synthetic_table_map.items():
|
|
2875
|
+
generator_table = generator_table_map[table_name]
|
|
2876
|
+
config = synthetic_table.configuration
|
|
2877
|
+
if config and config.imputation:
|
|
2878
|
+
has_tabular_model = generator_table.tabular_model_configuration is not None
|
|
2879
|
+
if not has_tabular_model:
|
|
2880
|
+
raise ValueError(f"Table '{table_name}' specifies imputation but has no tabular model")
|
|
2881
|
+
for col in config.imputation.columns:
|
|
2882
|
+
if not any(gcol.name == col for gcol in generator_table.columns or []):
|
|
2883
|
+
raise ValueError(f"Imputation column '{col}' not found in table '{table_name}'")
|
|
2884
|
+
return validation
|
|
2885
|
+
|
|
2886
|
+
@model_validator(mode="after")
|
|
2887
|
+
def validate_fairness_configs(cls, validation):
|
|
2888
|
+
generator_table_map = {t.name: t for t in validation.generator.tables}
|
|
2889
|
+
synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
|
|
2890
|
+
for table_name, synthetic_table in synthetic_table_map.items():
|
|
2891
|
+
generator_table = generator_table_map[table_name]
|
|
2892
|
+
config = synthetic_table.configuration
|
|
2893
|
+
if config and config.fairness:
|
|
2894
|
+
has_tabular_model = generator_table.tabular_model_configuration is not None
|
|
2895
|
+
if not has_tabular_model:
|
|
2896
|
+
raise ValueError(f"Table '{table_name}' specifies fairness but has no tabular model")
|
|
2897
|
+
target_col = config.fairness.target_column
|
|
2898
|
+
if not any(col.name == target_col for col in generator_table.columns or []):
|
|
2899
|
+
raise ValueError(f"Fairness target column '{target_col}' not found in table '{table_name}'")
|
|
2900
|
+
for col in config.fairness.sensitive_columns:
|
|
2901
|
+
if not any(gcol.name == col for gcol in generator_table.columns or []):
|
|
2902
|
+
raise ValueError(f"Fairness sensitive column '{col}' not found in table '{table_name}'")
|
|
2903
|
+
if target_col in config.fairness.sensitive_columns:
|
|
2904
|
+
raise ValueError(f"Target column '{target_col}' cannot be a sensitive column")
|
|
2905
|
+
return validation
|
|
2906
|
+
|
|
2907
|
+
@model_validator(mode="after")
|
|
2908
|
+
def set_default_sample_sizes(cls, validation):
|
|
2909
|
+
generator_table_map = {t.name: t for t in validation.generator.tables}
|
|
2910
|
+
synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
|
|
2911
|
+
for table_name, synthetic_table in synthetic_table_map.items():
|
|
2912
|
+
generator_table = generator_table_map[table_name]
|
|
2913
|
+
config = synthetic_table.configuration
|
|
2914
|
+
if config:
|
|
2915
|
+
is_subject = not any(fk.is_context for fk in generator_table.foreign_keys or [])
|
|
2916
|
+
if (
|
|
2917
|
+
not config.sample_size
|
|
2918
|
+
and is_subject
|
|
2919
|
+
and (not (config.sample_seed_connector_id or config.sample_seed_dict or config.sample_seed_data))
|
|
2920
|
+
):
|
|
2921
|
+
config.sample_size = (
|
|
2922
|
+
1
|
|
2923
|
+
if isinstance(validation.synthetic_config, SyntheticProbeConfig)
|
|
2924
|
+
else generator_table.total_rows
|
|
2925
|
+
)
|
|
2926
|
+
elif not is_subject:
|
|
2927
|
+
config.sample_size = None
|
|
2928
|
+
return validation
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mostlyai"
|
|
3
|
-
version = "4.0.
|
|
3
|
+
version = "4.0.6"
|
|
4
4
|
description = "Synthetic Data SDK"
|
|
5
5
|
authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
|
|
6
|
-
requires-python = ">=3.10"
|
|
6
|
+
requires-python = ">=3.10,<3.14"
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
license = "Apache-2.0"
|
|
9
9
|
classifiers = [
|
|
@@ -25,28 +25,23 @@ classifiers = [
|
|
|
25
25
|
]
|
|
26
26
|
dependencies = [
|
|
27
27
|
"pydantic>=2.4.2,<3",
|
|
28
|
-
"httpx>=0.25.0
|
|
29
|
-
"pandas>=
|
|
28
|
+
"httpx>=0.25.0",
|
|
29
|
+
"pandas>=2.0.0",
|
|
30
30
|
"pyarrow>=16.0.0",
|
|
31
31
|
"smart_open>=6.0.0",
|
|
32
32
|
"rich>=13.7.0",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"environs>=9.5.0,<10",
|
|
44
|
-
"gputil>=1.4.0,<2",
|
|
45
|
-
"schema>=0.7.5,<0.8",
|
|
46
|
-
"xxhash>=3.2.0,<4",
|
|
47
|
-
"networkx~=3.1",
|
|
33
|
+
"psutil>=5.9.5",
|
|
34
|
+
"requests>=2.31.0",
|
|
35
|
+
"sqlalchemy>=2.0.0",
|
|
36
|
+
"typer>=0.9.0",
|
|
37
|
+
"semantic-version>=2.10.0",
|
|
38
|
+
"joblib>=1.2.0",
|
|
39
|
+
"gunicorn>=23.0.0",
|
|
40
|
+
"environs>=9.5.0",
|
|
41
|
+
"schema>=0.7.5",
|
|
42
|
+
"xxhash>=3.2.0",
|
|
48
43
|
"greenlet>=3.1.1,<4",
|
|
49
|
-
"pycryptodomex>=3.
|
|
44
|
+
"pycryptodomex>=3.10.0,<4",
|
|
50
45
|
"sshtunnel>=0.4.0,<0.5",
|
|
51
46
|
"xlsxwriter>=3.1.9,<4",
|
|
52
47
|
"openpyxl>=3.1.5",
|
|
@@ -63,27 +58,29 @@ dependencies = [
|
|
|
63
58
|
[project.optional-dependencies]
|
|
64
59
|
local = [
|
|
65
60
|
# local
|
|
66
|
-
"mostlyai-engine==1.0.
|
|
67
|
-
"mostlyai-qa==1.5.
|
|
61
|
+
"mostlyai-engine==1.0.3",
|
|
62
|
+
"mostlyai-qa==1.5.2",
|
|
68
63
|
"fastapi>=0.115.6,<0.116",
|
|
69
64
|
"uvicorn>=0.34.0,<0.35",
|
|
70
65
|
"python-multipart>=0.0.20",
|
|
66
|
+
"torch>=2.5.1,<2.6.0",
|
|
71
67
|
]
|
|
72
68
|
local-gpu = [
|
|
73
|
-
"mostlyai-engine[gpu]==1.0.
|
|
74
|
-
"mostlyai-qa==1.5.
|
|
69
|
+
"mostlyai-engine[gpu]==1.0.3",
|
|
70
|
+
"mostlyai-qa[gpu]==1.5.2",
|
|
75
71
|
"fastapi>=0.115.6,<0.116",
|
|
76
72
|
"uvicorn>=0.34.0,<0.35",
|
|
77
73
|
"python-multipart>=0.0.20",
|
|
78
|
-
"torch>=2.5.1",
|
|
74
|
+
"torch>=2.5.1,<2.6.0",
|
|
79
75
|
]
|
|
80
76
|
local-cpu = [
|
|
81
|
-
"mostlyai-engine[cpu]==1.0.
|
|
82
|
-
"mostlyai-qa==1.5.
|
|
77
|
+
"mostlyai-engine[cpu]==1.0.3",
|
|
78
|
+
"mostlyai-qa[cpu]==1.5.2",
|
|
83
79
|
"fastapi>=0.115.6,<0.116",
|
|
84
80
|
"uvicorn>=0.34.0,<0.35",
|
|
85
81
|
"python-multipart>=0.0.20",
|
|
86
|
-
"torch
|
|
82
|
+
"torch==2.5.1+cpu; sys_platform == 'linux'",
|
|
83
|
+
"torch>=2.5.1,<2.6.0; sys_platform != 'linux'",
|
|
87
84
|
]
|
|
88
85
|
# connectors
|
|
89
86
|
databricks = ["databricks-sql-connector>=3.2.0,<4"]
|
|
@@ -110,6 +107,7 @@ dev = [
|
|
|
110
107
|
"twine>=6.0.1,<7",
|
|
111
108
|
"pkginfo>=1.12.0,<2",
|
|
112
109
|
"poetry-bumpversion>=0.3.2,<0.4",
|
|
110
|
+
"httpx<0.28",
|
|
113
111
|
]
|
|
114
112
|
docs = [
|
|
115
113
|
"mkdocs>=1.5.3",
|
|
@@ -140,9 +138,15 @@ name = "pytorch-cpu"
|
|
|
140
138
|
url = "https://download.pytorch.org/whl/cpu"
|
|
141
139
|
explicit = true
|
|
142
140
|
|
|
141
|
+
#[[tool.uv.index]]
|
|
142
|
+
#name = "pytorch-gpu"
|
|
143
|
+
#url = "https://pypi.org/simple"
|
|
144
|
+
#explicit = true
|
|
145
|
+
|
|
143
146
|
[tool.uv.sources]
|
|
144
147
|
torch = [
|
|
145
|
-
{ index = "pytorch-cpu", extra = "local-cpu"},
|
|
148
|
+
{ index = "pytorch-cpu", extra = "local-cpu", marker = "sys_platform == 'linux'"},
|
|
149
|
+
# { index = "pytorch-gpu", extra = "local-gpu", marker = "sys_platform != 'linux' or platform_machine != 'x86_64'"},
|
|
146
150
|
]
|
|
147
151
|
|
|
148
152
|
[tool.hatch.build.targets.sdist]
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_analyze_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_encode_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.0.5 → mostlyai-4.0.6}/mostlyai/sdk/_local/execution/step_generate_model_report_data.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|