mostlyai 4.3.2__tar.gz → 4.3.3__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.3.2 → mostlyai-4.3.3}/PKG-INFO +16 -28
- {mostlyai-4.3.2 → mostlyai-4.3.3}/README.md +12 -24
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/__init__.py +1 -1
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/client/_utils.py +3 -1
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/client/api.py +146 -85
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/client/base.py +13 -13
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/client/generators.py +50 -18
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/domain.py +35 -44
- {mostlyai-4.3.2 → mostlyai-4.3.3}/pyproject.toml +4 -4
- {mostlyai-4.3.2 → mostlyai-4.3.3}/.gitignore +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/LICENSE +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/__init__.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/auto_detect.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/base.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/context.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/conversions.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/__init__.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/base.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/bigquery.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/databricks.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/hive.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/mssql.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/mysql.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/oracle.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/postgresql.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/snowflake.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/sqlite.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/dtype.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/exceptions.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/__init__.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/base.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/aws.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/azure.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/minio.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/table/csv.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/table/feather.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/table/json.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/utils.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/language_model.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/metadata_objects.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/non_context.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/progress_callback.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/pull.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/pull_context.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/pull_utils.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/push.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/util/__init__.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/util/common.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_data/util/kerberos.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/__init__.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/cli.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/connectors.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/__init__.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/jobs.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/plan.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/generators.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/progress.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/routes.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/server.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/storage.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/client/__init__.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/client/_base_utils.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/client/_naming_conventions.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/client/connectors.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/client/exceptions.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/client/synthetic_datasets.py +0 -0
- {mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mostlyai
|
|
3
|
-
Version: 4.3.
|
|
3
|
+
Version: 4.3.3
|
|
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
|
|
@@ -58,7 +58,7 @@ Requires-Dist: filelock>=3.16.1; extra == 'local'
|
|
|
58
58
|
Requires-Dist: gcsfs>=2023.1.0; extra == 'local'
|
|
59
59
|
Requires-Dist: joblib>=1.2.0; extra == 'local'
|
|
60
60
|
Requires-Dist: mostlyai-engine==1.1.6; extra == 'local'
|
|
61
|
-
Requires-Dist: mostlyai-qa==1.5.
|
|
61
|
+
Requires-Dist: mostlyai-qa==1.5.7; extra == 'local'
|
|
62
62
|
Requires-Dist: networkx<4,>=3.0; extra == 'local'
|
|
63
63
|
Requires-Dist: openpyxl>=3.1.5; extra == 'local'
|
|
64
64
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local'
|
|
@@ -78,7 +78,7 @@ Requires-Dist: filelock>=3.16.1; extra == 'local-cpu'
|
|
|
78
78
|
Requires-Dist: gcsfs>=2023.1.0; extra == 'local-cpu'
|
|
79
79
|
Requires-Dist: joblib>=1.2.0; extra == 'local-cpu'
|
|
80
80
|
Requires-Dist: mostlyai-engine[cpu]==1.1.6; extra == 'local-cpu'
|
|
81
|
-
Requires-Dist: mostlyai-qa[cpu]==1.5.
|
|
81
|
+
Requires-Dist: mostlyai-qa[cpu]==1.5.7; extra == 'local-cpu'
|
|
82
82
|
Requires-Dist: networkx<4,>=3.0; extra == 'local-cpu'
|
|
83
83
|
Requires-Dist: openpyxl>=3.1.5; extra == 'local-cpu'
|
|
84
84
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local-cpu'
|
|
@@ -99,7 +99,7 @@ Requires-Dist: filelock>=3.16.1; extra == 'local-gpu'
|
|
|
99
99
|
Requires-Dist: gcsfs>=2023.1.0; extra == 'local-gpu'
|
|
100
100
|
Requires-Dist: joblib>=1.2.0; extra == 'local-gpu'
|
|
101
101
|
Requires-Dist: mostlyai-engine[gpu]==1.1.6; extra == 'local-gpu'
|
|
102
|
-
Requires-Dist: mostlyai-qa[gpu]==1.5.
|
|
102
|
+
Requires-Dist: mostlyai-qa[gpu]==1.5.7; extra == 'local-gpu'
|
|
103
103
|
Requires-Dist: networkx<4,>=3.0; extra == 'local-gpu'
|
|
104
104
|
Requires-Dist: openpyxl>=3.1.5; extra == 'local-gpu'
|
|
105
105
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local-gpu'
|
|
@@ -200,33 +200,13 @@ from mostlyai.sdk import MostlyAI
|
|
|
200
200
|
# load original data
|
|
201
201
|
repo_url = "https://github.com/mostly-ai/public-demo-data/raw/refs/heads/dev"
|
|
202
202
|
df_original = pd.read_csv(f"{repo_url}/census/census.csv.gz")
|
|
203
|
+
df_original = df_original.sample(n=10_000) # sub-sample to speed up demo
|
|
203
204
|
|
|
204
205
|
# initialize the SDK
|
|
205
206
|
mostly = MostlyAI()
|
|
206
207
|
|
|
207
|
-
# train a synthetic data generator
|
|
208
|
-
g = mostly.train(
|
|
209
|
-
config={
|
|
210
|
-
"name": "US Census Income",
|
|
211
|
-
"tables": [
|
|
212
|
-
{
|
|
213
|
-
"name": "census",
|
|
214
|
-
"data": df_original,
|
|
215
|
-
"tabular_model_configuration": { # tabular model configuration (optional)
|
|
216
|
-
"max_training_time": 1, # - cap time to 1 min for demo; increase for max accuracy
|
|
217
|
-
# model, max_epochs,,.. # further model configurations (optional)
|
|
218
|
-
# 'differential_privacy': { # differential privacy configuration (optional)
|
|
219
|
-
# 'max_epsilon': 5.0, # - max epsilon value, used as stopping criterion
|
|
220
|
-
# 'delta': 1e-5, # - delta value
|
|
221
|
-
# }
|
|
222
|
-
},
|
|
223
|
-
# columns, keys, compute,.. # further table configurations (optional)
|
|
224
|
-
}
|
|
225
|
-
],
|
|
226
|
-
},
|
|
227
|
-
start=True, # start training immediately (default: True)
|
|
228
|
-
wait=True, # wait for completion (default: True)
|
|
229
|
-
)
|
|
208
|
+
# train a synthetic data generator, with default configs
|
|
209
|
+
g = mostly.train(name="Quick Start Demo", data=df_original)
|
|
230
210
|
|
|
231
211
|
# display the quality assurance report
|
|
232
212
|
g.reports(display=True)
|
|
@@ -264,7 +244,13 @@ df_samples
|
|
|
264
244
|
|
|
265
245
|
## Installation
|
|
266
246
|
|
|
267
|
-
Use `pip` (or better `uv pip`) to install the official `mostlyai` package via PyPI. Python 3.10 or higher is required.
|
|
247
|
+
Use `pip` (or better `uv pip`) to install the official `mostlyai` package via PyPI. Python 3.10 or higher is required.
|
|
248
|
+
|
|
249
|
+
It is highly recommended to install the package within a dedicated virtual environment, such as **venv**, **uv**, or **conda**. E.g.
|
|
250
|
+
```shell
|
|
251
|
+
conda create -n mostlyai python=3.12
|
|
252
|
+
conda activate mostlyai
|
|
253
|
+
```
|
|
268
254
|
|
|
269
255
|
### CLIENT mode
|
|
270
256
|
|
|
@@ -285,6 +271,8 @@ pip install -U 'mostlyai[local]'
|
|
|
285
271
|
pip install -U 'mostlyai[local-cpu]' --extra-index-url https://download.pytorch.org/whl/cpu
|
|
286
272
|
# for GPU on Linux
|
|
287
273
|
pip install -U 'mostlyai[local-gpu]'
|
|
274
|
+
# if torch>=2.6.0 is pre-installed (like Google Colab) run this
|
|
275
|
+
pip install torch==2.5.1 torchaudio==2.5.1 torchvision==0.20.1
|
|
288
276
|
```
|
|
289
277
|
|
|
290
278
|
Add any of the following extras for further data connectors support in LOCAL mode: `databricks`, `googlebigquery`, `hive`, `mssql`, `mysql`, `oracle`, `postgres`, `snowflake`. E.g.
|
|
@@ -76,33 +76,13 @@ from mostlyai.sdk import MostlyAI
|
|
|
76
76
|
# load original data
|
|
77
77
|
repo_url = "https://github.com/mostly-ai/public-demo-data/raw/refs/heads/dev"
|
|
78
78
|
df_original = pd.read_csv(f"{repo_url}/census/census.csv.gz")
|
|
79
|
+
df_original = df_original.sample(n=10_000) # sub-sample to speed up demo
|
|
79
80
|
|
|
80
81
|
# initialize the SDK
|
|
81
82
|
mostly = MostlyAI()
|
|
82
83
|
|
|
83
|
-
# train a synthetic data generator
|
|
84
|
-
g = mostly.train(
|
|
85
|
-
config={
|
|
86
|
-
"name": "US Census Income",
|
|
87
|
-
"tables": [
|
|
88
|
-
{
|
|
89
|
-
"name": "census",
|
|
90
|
-
"data": df_original,
|
|
91
|
-
"tabular_model_configuration": { # tabular model configuration (optional)
|
|
92
|
-
"max_training_time": 1, # - cap time to 1 min for demo; increase for max accuracy
|
|
93
|
-
# model, max_epochs,,.. # further model configurations (optional)
|
|
94
|
-
# 'differential_privacy': { # differential privacy configuration (optional)
|
|
95
|
-
# 'max_epsilon': 5.0, # - max epsilon value, used as stopping criterion
|
|
96
|
-
# 'delta': 1e-5, # - delta value
|
|
97
|
-
# }
|
|
98
|
-
},
|
|
99
|
-
# columns, keys, compute,.. # further table configurations (optional)
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
start=True, # start training immediately (default: True)
|
|
104
|
-
wait=True, # wait for completion (default: True)
|
|
105
|
-
)
|
|
84
|
+
# train a synthetic data generator, with default configs
|
|
85
|
+
g = mostly.train(name="Quick Start Demo", data=df_original)
|
|
106
86
|
|
|
107
87
|
# display the quality assurance report
|
|
108
88
|
g.reports(display=True)
|
|
@@ -140,7 +120,13 @@ df_samples
|
|
|
140
120
|
|
|
141
121
|
## Installation
|
|
142
122
|
|
|
143
|
-
Use `pip` (or better `uv pip`) to install the official `mostlyai` package via PyPI. Python 3.10 or higher is required.
|
|
123
|
+
Use `pip` (or better `uv pip`) to install the official `mostlyai` package via PyPI. Python 3.10 or higher is required.
|
|
124
|
+
|
|
125
|
+
It is highly recommended to install the package within a dedicated virtual environment, such as **venv**, **uv**, or **conda**. E.g.
|
|
126
|
+
```shell
|
|
127
|
+
conda create -n mostlyai python=3.12
|
|
128
|
+
conda activate mostlyai
|
|
129
|
+
```
|
|
144
130
|
|
|
145
131
|
### CLIENT mode
|
|
146
132
|
|
|
@@ -161,6 +147,8 @@ pip install -U 'mostlyai[local]'
|
|
|
161
147
|
pip install -U 'mostlyai[local-cpu]' --extra-index-url https://download.pytorch.org/whl/cpu
|
|
162
148
|
# for GPU on Linux
|
|
163
149
|
pip install -U 'mostlyai[local-gpu]'
|
|
150
|
+
# if torch>=2.6.0 is pre-installed (like Google Colab) run this
|
|
151
|
+
pip install torch==2.5.1 torchaudio==2.5.1 torchvision==0.20.1
|
|
164
152
|
```
|
|
165
153
|
|
|
166
154
|
Add any of the following extras for further data connectors support in LOCAL mode: `databricks`, `googlebigquery`, `hive`, `mssql`, `mysql`, `oracle`, `postgres`, `snowflake`. E.g.
|
|
@@ -58,7 +58,9 @@ def check_local_mode_available() -> None:
|
|
|
58
58
|
|
|
59
59
|
return
|
|
60
60
|
except ImportError:
|
|
61
|
-
raise APIError(
|
|
61
|
+
raise APIError(
|
|
62
|
+
"LOCAL mode requires additional packages to be installed. Run `pip install -U 'mostlyai[local]'`."
|
|
63
|
+
)
|
|
62
64
|
|
|
63
65
|
|
|
64
66
|
def validate_base_url(base_url: str) -> None:
|
|
@@ -55,14 +55,14 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
55
55
|
Instantiate an SDK instance, either in CLIENT or in LOCAL mode.
|
|
56
56
|
|
|
57
57
|
Args:
|
|
58
|
-
base_url: The base URL. If not provided,
|
|
59
|
-
api_key: The API key for authenticating. If not provided,
|
|
60
|
-
local: Whether to run in local mode or not.
|
|
61
|
-
local_dir: The directory to use for local mode. If not provided, `~/mostlyai`
|
|
62
|
-
local_port: The port to use for local mode with TCP transport. If not provided, UDS transport is used
|
|
63
|
-
timeout: Timeout for HTTPS requests in seconds.
|
|
64
|
-
ssl_verify: Whether to verify SSL certificates.
|
|
65
|
-
quiet: Whether to suppress rich output.
|
|
58
|
+
base_url (str | None): The base URL. If not provided, env var `MOSTLY_BASE_URL` is used if available, otherwise `https://app.mostly.ai`.
|
|
59
|
+
api_key (str | None): The API key for authenticating. If not provided, env var `MOSTLY_API_KEY` is used if available.
|
|
60
|
+
local (bool | None): Whether to run in local mode or not. If not provided, user is prompted to choose between CLIENT and LOCAL mode.
|
|
61
|
+
local_dir (str | Path | None): The directory to use for local mode. If not provided, `~/mostlyai` is used.
|
|
62
|
+
local_port (int | None): The port to use for local mode with TCP transport. If not provided, UDS transport is used.
|
|
63
|
+
timeout (float): Timeout for HTTPS requests in seconds. Default is 60 seconds.
|
|
64
|
+
ssl_verify (bool): Whether to verify SSL certificates. Default is True.
|
|
65
|
+
quiet (bool): Whether to suppress rich output. Default is False.
|
|
66
66
|
|
|
67
67
|
Example for SDK in CLIENT mode with explicit arguments:
|
|
68
68
|
```python
|
|
@@ -241,14 +241,12 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
241
241
|
"""
|
|
242
242
|
Create a connector and optionally validate the connection before saving.
|
|
243
243
|
|
|
244
|
-
See [ConnectorConfig](api_domain.md#mostlyai.sdk.domain.ConnectorConfig) for more information on the available configuration parameters.
|
|
245
|
-
|
|
246
244
|
Args:
|
|
247
|
-
config: Configuration for the connector. Can be either a ConnectorConfig object or an equivalent dictionary.
|
|
248
|
-
test_connection: Whether to validate the connection before saving.
|
|
245
|
+
config (ConnectorConfig | dict[str, Any]): Configuration for the connector. Can be either a ConnectorConfig object or an equivalent dictionary.
|
|
246
|
+
test_connection (bool | None): Whether to validate the connection before saving. Default is True.
|
|
249
247
|
|
|
250
248
|
Returns:
|
|
251
|
-
The created connector.
|
|
249
|
+
Connector: The created connector.
|
|
252
250
|
|
|
253
251
|
Example for creating a connector to a AWS S3 storage:
|
|
254
252
|
```python
|
|
@@ -399,86 +397,154 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
399
397
|
"""
|
|
400
398
|
Train a generator.
|
|
401
399
|
|
|
402
|
-
See [GeneratorConfig](api_domain.md#mostlyai.sdk.domain.GeneratorConfig) for more information on the available configuration parameters.
|
|
403
|
-
|
|
404
400
|
Args:
|
|
405
|
-
config: The configuration parameters of the generator to be created. Either `config` or `data` must be provided.
|
|
406
|
-
data: A single pandas DataFrame, or a path to a CSV or PARQUET file. Either `config` or `data` must be provided.
|
|
407
|
-
name: Name of the generator.
|
|
408
|
-
start: Whether to start training immediately.
|
|
409
|
-
wait: Whether to wait for training to finish.
|
|
410
|
-
progress_bar: Whether to display a progress bar during training.
|
|
401
|
+
config (GeneratorConfig | dict | None): The configuration parameters of the generator to be created. Either `config` or `data` must be provided.
|
|
402
|
+
data (pd.DataFrame | str | Path | None): A single pandas DataFrame, or a path to a CSV or PARQUET file. Either `config` or `data` must be provided.
|
|
403
|
+
name (str | None): Name of the generator.
|
|
404
|
+
start (bool): Whether to start training immediately. Default is True.
|
|
405
|
+
wait (bool): Whether to wait for training to finish. Default is True.
|
|
406
|
+
progress_bar (bool): Whether to display a progress bar during training. Default is True.
|
|
411
407
|
|
|
412
408
|
Returns:
|
|
413
|
-
The created generator.
|
|
409
|
+
Generator: The created generator.
|
|
414
410
|
|
|
415
|
-
Example of
|
|
411
|
+
Example of single table with default configurations:
|
|
416
412
|
```python
|
|
413
|
+
# read original data
|
|
414
|
+
import pandas as pd
|
|
415
|
+
df = pd.read_csv('https://github.com/mostly-ai/public-demo-data/raw/dev/census/census.csv.gz')
|
|
416
|
+
# instantiate client
|
|
417
417
|
from mostlyai.sdk import MostlyAI
|
|
418
418
|
mostly = MostlyAI()
|
|
419
|
+
# train generator
|
|
419
420
|
g = mostly.train(
|
|
420
|
-
|
|
421
|
+
name='census',
|
|
422
|
+
data=df, # alternatively, pass a path to a CSV or PARQUET file
|
|
423
|
+
start=True, # start training immediately
|
|
424
|
+
wait=True, # wait for training to finish
|
|
421
425
|
)
|
|
422
426
|
```
|
|
423
427
|
|
|
424
|
-
Example of
|
|
428
|
+
Example of single table with custom configurations:
|
|
425
429
|
```python
|
|
426
430
|
# read original data
|
|
427
431
|
import pandas as pd
|
|
428
|
-
|
|
432
|
+
df = pd.read_csv('https://github.com/mostly-ai/public-demo-data/raw/dev/baseball/players.csv.gz')
|
|
429
433
|
# instantiate client
|
|
430
434
|
from mostlyai.sdk import MostlyAI
|
|
431
435
|
mostly = MostlyAI()
|
|
432
|
-
#
|
|
436
|
+
# configure generator via dictionary
|
|
433
437
|
g = mostly.train(
|
|
434
|
-
|
|
435
|
-
|
|
438
|
+
config={ # see `mostlyai.sdk.domain.GeneratorConfig`
|
|
439
|
+
'name': 'Baseball Players',
|
|
440
|
+
'tables': [
|
|
441
|
+
{ # see `mostlyai.sdk.domain.SourceTableConfig`
|
|
442
|
+
'name': 'players', # name of the table (required)
|
|
443
|
+
'data': df, # either provide data as a pandas DataFrame
|
|
444
|
+
'source_connector_id': None, # - or pass a source_connector_id
|
|
445
|
+
'location': None, # - together with a table location
|
|
446
|
+
'primary_key': 'id', # specify the primary key column, if one is present
|
|
447
|
+
'tabular_model_configuration': { # see `mostlyai.sdk.domain.ModelConfiguration`; all settings are optional!
|
|
448
|
+
'model': 'MOSTLY_AI/Medium', # check `mostly.models()` for available models
|
|
449
|
+
'batch_size': None, # set a custom physical training batch size
|
|
450
|
+
'max_sample_size': 10_000, # cap sample size to 10k; set to None for max accuracy
|
|
451
|
+
'max_epochs': 20, # cap training to 20 epochs; set to None for max accuracy
|
|
452
|
+
'max_training_time': 10, # cap runtime to 10min; set to None for max accuracy
|
|
453
|
+
'enable_flexible_generation': True, # allow seed, imputation, rebalancing and fairness; set to False for max accuracy
|
|
454
|
+
'value_protection': True, # privacy protect value ranges; set to False for allowing all seen values
|
|
455
|
+
'differential_privacy': { # set DP configs if explicitly requested
|
|
456
|
+
'max_epsilon': 5.0, # - max epsilon value, used as stopping criterion
|
|
457
|
+
'noise_multiplier': 0.8, # - DP noise multiplier
|
|
458
|
+
'max_grad_norm': 1.0, # - DP max grad norm
|
|
459
|
+
'delta': 1e-5, # - DP delta value
|
|
460
|
+
},
|
|
461
|
+
'enable_model_report': True, # generate a model report, including quality metrics
|
|
462
|
+
},
|
|
463
|
+
'columns': [ # list columns (optional); see `mostlyai.sdk.domain.ModelEncodingType`
|
|
464
|
+
{'name': 'id', 'model_encoding_type': 'TABULAR_CATEGORICAL'},
|
|
465
|
+
{'name': 'bats', 'model_encoding_type': 'TABULAR_CATEGORICAL'},
|
|
466
|
+
{'name': 'throws', 'model_encoding_type': 'TABULAR_CATEGORICAL'},
|
|
467
|
+
{'name': 'birthDate', 'model_encoding_type': 'TABULAR_DATETIME'},
|
|
468
|
+
{'name': 'weight', 'model_encoding_type': 'TABULAR_NUMERIC_AUTO'},
|
|
469
|
+
{'name': 'height', 'model_encoding_type': 'TABULAR_NUMERIC_AUTO'},
|
|
470
|
+
],
|
|
471
|
+
}
|
|
472
|
+
]
|
|
473
|
+
},
|
|
474
|
+
start=True, # start training immediately
|
|
475
|
+
wait=True, # wait for training to finish
|
|
436
476
|
)
|
|
437
477
|
```
|
|
438
478
|
|
|
439
|
-
Example
|
|
479
|
+
Example of multi-table with custom configurations:
|
|
440
480
|
```python
|
|
441
481
|
# read original data
|
|
442
482
|
import pandas as pd
|
|
443
|
-
|
|
483
|
+
df_purchases = pd.read_csv('https://github.com/mostly-ai/public-demo-data/raw/refs/heads/dev/cdnow/purchases.csv.gz')
|
|
484
|
+
df_users = df_purchases[['users_id']].drop_duplicates()
|
|
444
485
|
# instantiate client
|
|
445
486
|
from mostlyai.sdk import MostlyAI
|
|
446
487
|
mostly = MostlyAI()
|
|
447
|
-
#
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
name
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
488
|
+
# train generator
|
|
489
|
+
g = mostly.train(config={
|
|
490
|
+
'name': 'CDNOW', # name of the generator
|
|
491
|
+
'tables': [{ # provide list of all tables
|
|
492
|
+
'name': 'users',
|
|
493
|
+
'data': df_users,
|
|
494
|
+
'primary_key': 'users_id', # define PK column
|
|
495
|
+
}, {
|
|
496
|
+
'name': 'purchases',
|
|
497
|
+
'data': df_purchases,
|
|
498
|
+
'foreign_keys': [{ # define FK columns, with one providing the context
|
|
499
|
+
'column': 'users_id',
|
|
500
|
+
'referenced_table': 'users',
|
|
501
|
+
'is_context': True
|
|
502
|
+
}],
|
|
503
|
+
'tabular_model_configuration': {
|
|
504
|
+
'max_sample_size': 1000, # cap sample size to 1k users; set to None for max accuracy
|
|
505
|
+
'max_training_time': 1, # cap runtime to 1min; set to None for max accuracy
|
|
506
|
+
'max_sequence_window': 10, # optionally limit the sequence window
|
|
507
|
+
},
|
|
508
|
+
}],
|
|
509
|
+
}, start=True, wait=True)
|
|
460
510
|
```
|
|
461
511
|
|
|
462
|
-
Example
|
|
512
|
+
Example of multi-model with TABULAR and LANGUAGE models:
|
|
463
513
|
```python
|
|
464
514
|
# read original data
|
|
465
515
|
import pandas as pd
|
|
466
|
-
|
|
467
|
-
|
|
516
|
+
df = pd.read_parquet('https://github.com/mostly-ai/public-demo-data/raw/refs/heads/dev/headlines/headlines.parquet')
|
|
517
|
+
|
|
518
|
+
# instantiate SDK
|
|
468
519
|
from mostlyai.sdk import MostlyAI
|
|
469
520
|
mostly = MostlyAI()
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
521
|
+
|
|
522
|
+
# print out available LANGUAGE models
|
|
523
|
+
print(mostly.models()["LANGUAGE"])
|
|
524
|
+
|
|
525
|
+
# train a generator; increase max_training_time to improve quality
|
|
526
|
+
g = mostly.train(config={
|
|
527
|
+
'name': 'Headlines',
|
|
528
|
+
'tables': [{
|
|
529
|
+
'name': 'headlines',
|
|
530
|
+
'data': df,
|
|
531
|
+
'columns': [ # configure TABULAR + LANGUAGE cols
|
|
532
|
+
{'name': 'category', 'model_encoding_type': 'TABULAR_CATEGORICAL'},
|
|
533
|
+
{'name': 'date', 'model_encoding_type': 'TABULAR_DATETIME'},
|
|
534
|
+
{'name': 'headline', 'model_encoding_type': 'LANGUAGE_TEXT'},
|
|
535
|
+
],
|
|
536
|
+
'tabular_model_configuration': { # tabular model configuration (optional)
|
|
537
|
+
'max_sample_size': 2000, # cap sample size to 2k; set None for max accuracy
|
|
538
|
+
'max_training_time': 1, # cap runtime to 1min; set None for max accuracy
|
|
539
|
+
},
|
|
540
|
+
'language_model_configuration': { # language model configuration (optional)
|
|
541
|
+
'max_sample_size': 1000, # cap sample size to 1k; set None for max accuracy
|
|
542
|
+
'max_training_time': 5, # cap runtime to 5min; set None for max accuracy
|
|
543
|
+
'model': 'MOSTLY_AI/LSTMFromScratch-3m', # use a light-weight LSTM model, trained from scratch (GPU recommended)
|
|
544
|
+
#'model': 'microsoft/phi-1.5', # alternatively use a pre-trained HF-hosted LLM model (GPU required)
|
|
545
|
+
}
|
|
546
|
+
}],
|
|
547
|
+
}, start=True, wait=True)
|
|
482
548
|
```
|
|
483
549
|
"""
|
|
484
550
|
if data is None and config is None:
|
|
@@ -514,7 +580,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
514
580
|
|
|
515
581
|
def generate(
|
|
516
582
|
self,
|
|
517
|
-
generator: Generator | str
|
|
583
|
+
generator: Generator | str,
|
|
518
584
|
config: SyntheticDatasetConfig | dict | None = None,
|
|
519
585
|
size: int | dict[str, int] | None = None,
|
|
520
586
|
seed: Seed | dict[str, Seed] | None = None,
|
|
@@ -526,20 +592,18 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
526
592
|
"""
|
|
527
593
|
Generate synthetic data.
|
|
528
594
|
|
|
529
|
-
See [SyntheticDatasetConfig](api_domain.md#mostlyai.sdk.domain.SyntheticDatasetConfig) for more information on the available configuration parameters.
|
|
530
|
-
|
|
531
595
|
Args:
|
|
532
|
-
generator: The generator instance or its UUID.
|
|
533
|
-
config: Configuration for the synthetic dataset.
|
|
534
|
-
size : Sample size(s) for the subject table(s).
|
|
535
|
-
seed: Seed data for the subject table(s).
|
|
536
|
-
name: Name of the synthetic dataset.
|
|
537
|
-
start: Whether to start generation immediately.
|
|
538
|
-
wait: Whether to wait for generation to finish.
|
|
539
|
-
progress_bar: Whether to display a progress bar during generation.
|
|
596
|
+
generator (Generator | str): The generator instance or its UUID.
|
|
597
|
+
config (SyntheticDatasetConfig | dict | None): Configuration for the synthetic dataset.
|
|
598
|
+
size (int | dict[str, int] | None): Sample size(s) for the subject table(s).
|
|
599
|
+
seed (Seed | dict[str, Seed] | None): Seed data for the subject table(s).
|
|
600
|
+
name (str | None): Name of the synthetic dataset.
|
|
601
|
+
start (bool): Whether to start generation immediately. Default is True.
|
|
602
|
+
wait (bool): Whether to wait for generation to finish. Default is True.
|
|
603
|
+
progress_bar (bool): Whether to display a progress bar during generation. Default is True.
|
|
540
604
|
|
|
541
605
|
Returns:
|
|
542
|
-
The created synthetic dataset.
|
|
606
|
+
SyntheticDataset: The created synthetic dataset.
|
|
543
607
|
|
|
544
608
|
Example configuration using short-hand notation:
|
|
545
609
|
```python
|
|
@@ -606,7 +670,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
606
670
|
|
|
607
671
|
def probe(
|
|
608
672
|
self,
|
|
609
|
-
generator: Generator | str
|
|
673
|
+
generator: Generator | str,
|
|
610
674
|
size: int | dict[str, int] | None = None,
|
|
611
675
|
seed: Seed | dict[str, Seed] | None = None,
|
|
612
676
|
config: SyntheticProbeConfig | dict | None = None,
|
|
@@ -615,17 +679,15 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
615
679
|
"""
|
|
616
680
|
Probe a generator.
|
|
617
681
|
|
|
618
|
-
See [SyntheticProbeConfig](api_domain.md#mostlyai.sdk.domain.SyntheticProbeConfig) for more information on the available configuration parameters.
|
|
619
|
-
|
|
620
682
|
Args:
|
|
621
|
-
generator: The generator instance or its UUID.
|
|
622
|
-
size: Sample size(s) for the subject table(s).
|
|
623
|
-
seed: Seed data for the subject table(s).
|
|
624
|
-
config: Configuration for the probe.
|
|
625
|
-
return_type: Format of the return value. "auto" for pandas DataFrame if a single table, otherwise a dictionary.
|
|
683
|
+
generator (Generator | str): The generator instance or its UUID.
|
|
684
|
+
size (int | dict[str, int] | None): Sample size(s) for the subject table(s). Default is 1, if no seed is provided.
|
|
685
|
+
seed (Seed | dict[str, Seed] | None): Seed data for the subject table(s).
|
|
686
|
+
config (SyntheticProbeConfig | dict | None): Configuration for the probe.
|
|
687
|
+
return_type (Literal["auto", "dict"]): Format of the return value. "auto" for pandas DataFrame if a single table, otherwise a dictionary. Default is "auto".
|
|
626
688
|
|
|
627
689
|
Returns:
|
|
628
|
-
The created synthetic probe.
|
|
690
|
+
pd.DataFrame | dict[str, pd.DataFrame]: The created synthetic probe.
|
|
629
691
|
|
|
630
692
|
Example for probing a generator for 10 synthetic samples:
|
|
631
693
|
```python
|
|
@@ -677,7 +739,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
677
739
|
Retrieve information about the current user.
|
|
678
740
|
|
|
679
741
|
Returns:
|
|
680
|
-
Information about the current user.
|
|
742
|
+
CurrentUser: Information about the current user.
|
|
681
743
|
|
|
682
744
|
Example for retrieving information about the current user:
|
|
683
745
|
```python
|
|
@@ -694,7 +756,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
694
756
|
Retrieve information about the platform.
|
|
695
757
|
|
|
696
758
|
Returns:
|
|
697
|
-
Information about the platform.
|
|
759
|
+
AboutService: Information about the platform.
|
|
698
760
|
|
|
699
761
|
Example for retrieving information about the platform:
|
|
700
762
|
```python
|
|
@@ -711,7 +773,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
711
773
|
Retrieve a list of available models of a specific type.
|
|
712
774
|
|
|
713
775
|
Returns:
|
|
714
|
-
A dictionary with list of available models for each ModelType.
|
|
776
|
+
dict[str, list[str]]: A dictionary with list of available models for each ModelType.
|
|
715
777
|
|
|
716
778
|
Example for retrieving available models:
|
|
717
779
|
```python
|
|
@@ -729,9 +791,8 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
729
791
|
def computes(self) -> list[dict[str, Any]]:
|
|
730
792
|
"""
|
|
731
793
|
Retrieve a list of available compute resources, that can be used for executing tasks.
|
|
732
|
-
|
|
733
794
|
Returns:
|
|
734
|
-
A list of available compute resources.
|
|
795
|
+
list[dict[str, Any]]: A list of available compute resources.
|
|
735
796
|
|
|
736
797
|
Example for retrieving available compute resources:
|
|
737
798
|
```python
|
|
@@ -97,19 +97,19 @@ class _MostlyBaseClient:
|
|
|
97
97
|
Extended request helper method to send HTTP requests and process the response.
|
|
98
98
|
|
|
99
99
|
Args:
|
|
100
|
-
path: A single string or a list of parts of the path to concatenate.
|
|
101
|
-
verb: HTTP method (GET, POST, PATCH, DELETE).
|
|
102
|
-
response_type: Type to cast the response into. Defaults to
|
|
103
|
-
raw_response: Whether to return the raw response object. Defaults to
|
|
104
|
-
is_api_call: If
|
|
105
|
-
do_json_camel_case: Convert the provided JSON to camelCase. Defaults to
|
|
106
|
-
do_response_dict_snake_case: Convert the response dictionary to snake_case. Defaults to
|
|
107
|
-
do_include_client: Include the client property in the returned object. Defaults to
|
|
108
|
-
extra_key_values: Additional key-value pairs to include in the response object.
|
|
100
|
+
path (str | list[Any]): A single string or a list of parts of the path to concatenate.
|
|
101
|
+
verb (HttpVerb): HTTP method (GET, POST, PATCH, DELETE).
|
|
102
|
+
response_type (type | None): Type to cast the response into. Defaults to dict.
|
|
103
|
+
raw_response (bool): Whether to return the raw response object. Defaults to False.
|
|
104
|
+
is_api_call (bool): If False, skips prefixing API_SECTION and SECTION. Defaults to True.
|
|
105
|
+
do_json_camel_case (bool): Convert the provided JSON to camelCase. Defaults to True.
|
|
106
|
+
do_response_dict_snake_case (bool): Convert the response dictionary to snake_case. Defaults to True.
|
|
107
|
+
do_include_client (bool): Include the client property in the returned object. Defaults to True.
|
|
108
|
+
extra_key_values (dict | None): Additional key-value pairs to include in the response object.
|
|
109
109
|
**kwargs: Additional arguments passed to the HTTP request.
|
|
110
110
|
|
|
111
111
|
Returns:
|
|
112
|
-
Processed response based on the
|
|
112
|
+
Processed response based on the response_type.
|
|
113
113
|
|
|
114
114
|
Raises:
|
|
115
115
|
APIStatusError: For HTTP errors (non-2XX responses).
|
|
@@ -179,9 +179,9 @@ class Paginator(Generic[T]):
|
|
|
179
179
|
Generic paginator for listing objects with pagination.
|
|
180
180
|
|
|
181
181
|
Args:
|
|
182
|
-
client: The client instance to use for the requests.
|
|
183
|
-
response_class: Class of the objects to be listed.
|
|
184
|
-
**kwargs: Additional filter parameters including 'offset' and 'limit'.
|
|
182
|
+
client (_MostlyBaseClient): The client instance to use for the requests.
|
|
183
|
+
response_class (type[T]): Class of the objects to be listed.
|
|
184
|
+
**kwargs (dict): Additional filter parameters including 'offset' and 'limit'.
|
|
185
185
|
"""
|
|
186
186
|
self.client = client
|
|
187
187
|
self.response_class = response_class
|
|
@@ -16,6 +16,10 @@ from pathlib import Path
|
|
|
16
16
|
from typing import Any
|
|
17
17
|
from collections.abc import Iterator
|
|
18
18
|
import re
|
|
19
|
+
import requests
|
|
20
|
+
from urllib.parse import urlparse
|
|
21
|
+
import tempfile
|
|
22
|
+
import os
|
|
19
23
|
|
|
20
24
|
import pandas as pd
|
|
21
25
|
import rich
|
|
@@ -190,34 +194,62 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
|
|
|
190
194
|
Import a generator from a file.
|
|
191
195
|
|
|
192
196
|
Args:
|
|
193
|
-
file_path:
|
|
197
|
+
file_path: Local file path or URL of the generator to import.
|
|
194
198
|
|
|
195
199
|
Returns:
|
|
196
200
|
The imported generator object.
|
|
197
201
|
|
|
198
|
-
Example
|
|
202
|
+
Example:
|
|
199
203
|
```python
|
|
200
204
|
from mostlyai.sdk import MostlyAI
|
|
201
205
|
mostly = MostlyAI()
|
|
206
|
+
|
|
207
|
+
# Import from local file
|
|
202
208
|
g = mostly.generators.import_from_file('path/to/generator')
|
|
203
|
-
|
|
209
|
+
|
|
210
|
+
# Or import from URL
|
|
211
|
+
g = mostly.generators.import_from_file('https://example.com/path/to/generator.zip')
|
|
204
212
|
```
|
|
205
213
|
"""
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
214
|
+
# check if file_path is a URL
|
|
215
|
+
parsed_url = urlparse(str(file_path))
|
|
216
|
+
is_url = parsed_url.scheme in ["http", "https"]
|
|
217
|
+
|
|
218
|
+
temp_file = None
|
|
219
|
+
try:
|
|
220
|
+
if is_url:
|
|
221
|
+
# download the file from URL to a temporary file
|
|
222
|
+
response = requests.get(str(file_path), stream=True)
|
|
223
|
+
response.raise_for_status() # raise an exception for HTTP errors
|
|
224
|
+
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".zip")
|
|
225
|
+
temp_file.write(response.content)
|
|
226
|
+
temp_file.close()
|
|
227
|
+
file_path = temp_file.name
|
|
228
|
+
|
|
229
|
+
with open(file_path, "rb") as f:
|
|
230
|
+
generator = self.request(
|
|
231
|
+
verb=POST,
|
|
232
|
+
path=["import-from-file"],
|
|
233
|
+
headers={
|
|
234
|
+
"Accept": "application/json, text/plain, */*",
|
|
235
|
+
},
|
|
236
|
+
files={"file": f},
|
|
237
|
+
response_type=Generator,
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
gid = generator.id
|
|
241
|
+
if self.local:
|
|
242
|
+
rich.print(f"Imported generator [dodger_blue2]{gid}[/]")
|
|
243
|
+
else:
|
|
244
|
+
rich.print(
|
|
245
|
+
f"Imported generator [link={self.base_url}/d/generators/{gid} dodger_blue2 underline]{gid}[/]"
|
|
246
|
+
)
|
|
247
|
+
return generator
|
|
248
|
+
|
|
249
|
+
finally:
|
|
250
|
+
# clean up the temporary file if it exists
|
|
251
|
+
if temp_file and os.path.exists(temp_file.name):
|
|
252
|
+
os.unlink(temp_file.name)
|
|
221
253
|
|
|
222
254
|
# PRIVATE METHODS #
|
|
223
255
|
def _export_to_file(
|
|
@@ -1491,11 +1491,11 @@ class Connector(CustomBaseModel):
|
|
|
1491
1491
|
Update a connector with specific parameters.
|
|
1492
1492
|
|
|
1493
1493
|
Args:
|
|
1494
|
-
name: The name of the connector.
|
|
1495
|
-
config (dict[str, Any]
|
|
1496
|
-
secrets (dict[str, str]
|
|
1497
|
-
ssl (dict[str, str]
|
|
1498
|
-
test_connection: If true, validates the connection before saving.
|
|
1494
|
+
name (str | None): The name of the connector.
|
|
1495
|
+
config (dict[str, Any] | None): Connector configuration.
|
|
1496
|
+
secrets (dict[str, str] | None): Secret values for the connector.
|
|
1497
|
+
ssl (dict[str, str] | None): SSL configuration for the connector.
|
|
1498
|
+
test_connection (bool | None): If true, validates the connection before saving.
|
|
1499
1499
|
"""
|
|
1500
1500
|
patch_config = ConnectorPatchConfig(
|
|
1501
1501
|
name=name,
|
|
@@ -1513,13 +1513,10 @@ class Connector(CustomBaseModel):
|
|
|
1513
1513
|
def delete(self) -> None:
|
|
1514
1514
|
"""
|
|
1515
1515
|
Delete the connector.
|
|
1516
|
-
|
|
1517
|
-
Returns:
|
|
1518
|
-
None
|
|
1519
1516
|
"""
|
|
1520
1517
|
return self.client._delete(connector_id=self.id)
|
|
1521
1518
|
|
|
1522
|
-
def locations(self, prefix: str = "") -> list:
|
|
1519
|
+
def locations(self, prefix: str = "") -> list[str]:
|
|
1523
1520
|
"""
|
|
1524
1521
|
List connector locations.
|
|
1525
1522
|
|
|
@@ -1545,10 +1542,10 @@ class Connector(CustomBaseModel):
|
|
|
1545
1542
|
- `SNOWFLAKE`: `schema.table`
|
|
1546
1543
|
|
|
1547
1544
|
Args:
|
|
1548
|
-
prefix: The prefix to filter the results by.
|
|
1545
|
+
prefix (str | None): The prefix to filter the results by.
|
|
1549
1546
|
|
|
1550
1547
|
Returns:
|
|
1551
|
-
list: A list of locations (schemas, databases, directories, etc.)."""
|
|
1548
|
+
list[str]: A list of locations (schemas, databases, directories, etc.)."""
|
|
1552
1549
|
return self.client._locations(connector_id=self.id, prefix=prefix)
|
|
1553
1550
|
|
|
1554
1551
|
def schema(self, location: str) -> list[dict[str, Any]]:
|
|
@@ -1557,7 +1554,7 @@ class Connector(CustomBaseModel):
|
|
|
1557
1554
|
Please refer to `locations()` for the format of the location.
|
|
1558
1555
|
|
|
1559
1556
|
Args:
|
|
1560
|
-
location: The location of the table.
|
|
1557
|
+
location (str): The location of the table.
|
|
1561
1558
|
|
|
1562
1559
|
Returns:
|
|
1563
1560
|
list[dict[str, Any]]: The retrieved schema.
|
|
@@ -2516,8 +2513,8 @@ class Generator(CustomBaseModel):
|
|
|
2516
2513
|
Update a generator with specific parameters.
|
|
2517
2514
|
|
|
2518
2515
|
Args:
|
|
2519
|
-
name: The name of the generator.
|
|
2520
|
-
description: The description of the generator.
|
|
2516
|
+
name (str | None): The name of the generator.
|
|
2517
|
+
description (str | None): The description of the generator.
|
|
2521
2518
|
"""
|
|
2522
2519
|
patch_config = GeneratorPatchConfig(
|
|
2523
2520
|
name=name,
|
|
@@ -2529,9 +2526,6 @@ class Generator(CustomBaseModel):
|
|
|
2529
2526
|
def delete(self) -> None:
|
|
2530
2527
|
"""
|
|
2531
2528
|
Delete the generator.
|
|
2532
|
-
|
|
2533
|
-
Returns:
|
|
2534
|
-
None
|
|
2535
2529
|
"""
|
|
2536
2530
|
return self.client._delete(generator_id=self.id)
|
|
2537
2531
|
|
|
@@ -2552,10 +2546,10 @@ class Generator(CustomBaseModel):
|
|
|
2552
2546
|
Export generator and save to file.
|
|
2553
2547
|
|
|
2554
2548
|
Args:
|
|
2555
|
-
file_path: The file path to save the generator.
|
|
2549
|
+
file_path (str | Path | None): The file path to save the generator.
|
|
2556
2550
|
|
|
2557
2551
|
Returns:
|
|
2558
|
-
The path to the saved file.
|
|
2552
|
+
Path: The path to the saved file.
|
|
2559
2553
|
"""
|
|
2560
2554
|
bytes, filename = self.client._export_to_file(generator_id=self.id)
|
|
2561
2555
|
file_path = Path(file_path or ".")
|
|
@@ -2569,7 +2563,7 @@ class Generator(CustomBaseModel):
|
|
|
2569
2563
|
Clone the generator.
|
|
2570
2564
|
|
|
2571
2565
|
Args:
|
|
2572
|
-
training_status (Literal["NEW", "CONTINUE"]): The training status of the cloned generator.
|
|
2566
|
+
training_status (Literal["NEW", "CONTINUE"]): The training status of the cloned generator. Default is "NEW".
|
|
2573
2567
|
|
|
2574
2568
|
Returns:
|
|
2575
2569
|
Generator: The cloned generator object.
|
|
@@ -2584,11 +2578,11 @@ class Generator(CustomBaseModel):
|
|
|
2584
2578
|
Otherwise, the report is downloaded and saved to file_path (or a default location if None).
|
|
2585
2579
|
|
|
2586
2580
|
Args:
|
|
2587
|
-
file_path: The file path to save the zipped reports (ignored if display=True).
|
|
2588
|
-
display: If True, render the report inline instead of downloading it.
|
|
2581
|
+
file_path (str | Path | None): The file path to save the zipped reports (ignored if display=True).
|
|
2582
|
+
display (bool): If True, render the report inline instead of downloading it.
|
|
2589
2583
|
|
|
2590
2584
|
Returns:
|
|
2591
|
-
The path to the saved file if downloading, or None if display=True.
|
|
2585
|
+
Path | None: The path to the saved file if downloading, or None if display=True.
|
|
2592
2586
|
"""
|
|
2593
2587
|
reports = {}
|
|
2594
2588
|
for table in self.tables:
|
|
@@ -2665,8 +2659,8 @@ class Generator(CustomBaseModel):
|
|
|
2665
2659
|
Poll training progress and loop until training has completed.
|
|
2666
2660
|
|
|
2667
2661
|
Args:
|
|
2668
|
-
progress_bar: If true, displays the progress bar.
|
|
2669
|
-
interval: The interval in seconds to poll the job progress.
|
|
2662
|
+
progress_bar (bool): If true, displays the progress bar. Default is True.
|
|
2663
|
+
interval (float): The interval in seconds to poll the job progress. Default is 2 seconds.
|
|
2670
2664
|
"""
|
|
2671
2665
|
self.generator.client._training_wait(self.generator.id, progress_bar=progress_bar, interval=interval)
|
|
2672
2666
|
self.generator.reload()
|
|
@@ -2682,10 +2676,10 @@ class Generator(CustomBaseModel):
|
|
|
2682
2676
|
Download the training logs and save to file.
|
|
2683
2677
|
|
|
2684
2678
|
Args:
|
|
2685
|
-
file_path: The file path to save the logs.
|
|
2679
|
+
file_path (str | Path | None): The file path to save the logs. Default is the current working directory.
|
|
2686
2680
|
|
|
2687
2681
|
Returns:
|
|
2688
|
-
The path to the saved file.
|
|
2682
|
+
Path: The path to the saved file.
|
|
2689
2683
|
"""
|
|
2690
2684
|
bytes, filename = self.generator.client._training_logs(
|
|
2691
2685
|
generator_id=self.generator.id,
|
|
@@ -2816,9 +2810,9 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2816
2810
|
Update a synthetic dataset with specific parameters.
|
|
2817
2811
|
|
|
2818
2812
|
Args:
|
|
2819
|
-
name: The name of the synthetic dataset.
|
|
2820
|
-
description: The description of the synthetic dataset.
|
|
2821
|
-
delivery: The delivery configuration for the synthetic dataset.
|
|
2813
|
+
name (str | None): The name of the synthetic dataset.
|
|
2814
|
+
description (str | None): The description of the synthetic dataset.
|
|
2815
|
+
delivery (SyntheticDatasetDelivery | None): The delivery configuration for the synthetic dataset.
|
|
2822
2816
|
"""
|
|
2823
2817
|
patch_config = SyntheticDatasetPatchConfig(
|
|
2824
2818
|
name=name,
|
|
@@ -2834,9 +2828,6 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2834
2828
|
def delete(self) -> None:
|
|
2835
2829
|
"""
|
|
2836
2830
|
Delete the synthetic dataset.
|
|
2837
|
-
|
|
2838
|
-
Returns:
|
|
2839
|
-
None
|
|
2840
2831
|
"""
|
|
2841
2832
|
return self.client._delete(synthetic_dataset_id=self.id)
|
|
2842
2833
|
|
|
@@ -2858,11 +2849,11 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2858
2849
|
Download synthetic dataset and save to file.
|
|
2859
2850
|
|
|
2860
2851
|
Args:
|
|
2861
|
-
file_path: The file path to save the synthetic dataset.
|
|
2862
|
-
format: The format of the synthetic dataset.
|
|
2852
|
+
file_path (str | Path | None): The file path to save the synthetic dataset.
|
|
2853
|
+
format (SyntheticDatasetFormat): The format of the synthetic dataset. Default is "PARQUET".
|
|
2863
2854
|
|
|
2864
2855
|
Returns:
|
|
2865
|
-
The path to the saved file.
|
|
2856
|
+
Path: The path to the saved file.
|
|
2866
2857
|
"""
|
|
2867
2858
|
bytes, filename = self.client._download(
|
|
2868
2859
|
synthetic_dataset_id=self.id,
|
|
@@ -2880,7 +2871,7 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2880
2871
|
Download synthetic dataset and return as dictionary of pandas DataFrames.
|
|
2881
2872
|
|
|
2882
2873
|
Args:
|
|
2883
|
-
return_type (Literal["auto", "dict"]): The format of the returned data.
|
|
2874
|
+
return_type (Literal["auto", "dict"]): The format of the returned data. Default is "auto".
|
|
2884
2875
|
|
|
2885
2876
|
Returns:
|
|
2886
2877
|
Union[pd.DataFrame, dict[str, pd.DataFrame]]: The synthetic dataset as a dictionary of pandas DataFrames.
|
|
@@ -2902,11 +2893,11 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2902
2893
|
Otherwise, the report is downloaded and saved to file_path (or a default location if None).
|
|
2903
2894
|
|
|
2904
2895
|
Args:
|
|
2905
|
-
file_path: The file path to save the zipped reports (ignored if display=True).
|
|
2906
|
-
display: If True, render the report inline instead of downloading it.
|
|
2896
|
+
file_path (str | Path | None): The file path to save the zipped reports (ignored if display=True).
|
|
2897
|
+
display (bool): If True, render the report inline instead of downloading it.
|
|
2907
2898
|
|
|
2908
2899
|
Returns:
|
|
2909
|
-
The path to the saved file if downloading, or None if display=True.
|
|
2900
|
+
Path | None: The path to the saved file if downloading, or None if display=True.
|
|
2910
2901
|
"""
|
|
2911
2902
|
reports = {}
|
|
2912
2903
|
for report_type in [
|
|
@@ -2990,8 +2981,8 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2990
2981
|
Poll the generation progress and wait until the process is complete.
|
|
2991
2982
|
|
|
2992
2983
|
Args:
|
|
2993
|
-
progress_bar: If true, displays a progress bar.
|
|
2994
|
-
interval: Interval in seconds to poll the job progress.
|
|
2984
|
+
progress_bar (bool): If true, displays a progress bar. Default is True.
|
|
2985
|
+
interval (float): Interval in seconds to poll the job progress. Default is 2 seconds.
|
|
2995
2986
|
"""
|
|
2996
2987
|
self.synthetic_dataset.client._generation_wait(
|
|
2997
2988
|
self.synthetic_dataset.id, progress_bar=progress_bar, interval=interval
|
|
@@ -3009,10 +3000,10 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
3009
3000
|
Download the generation logs and save to file.
|
|
3010
3001
|
|
|
3011
3002
|
Args:
|
|
3012
|
-
file_path: The file path to save the logs.
|
|
3003
|
+
file_path (str | Path | None): The file path to save the logs. Default is the current working directory.
|
|
3013
3004
|
|
|
3014
3005
|
Returns:
|
|
3015
|
-
The path to the saved file.
|
|
3006
|
+
Path: The path to the saved file.
|
|
3016
3007
|
"""
|
|
3017
3008
|
bytes, filename = self.synthetic_dataset.client._generation_logs(
|
|
3018
3009
|
synthetic_dataset_id=self.synthetic_dataset.id,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mostlyai"
|
|
3
|
-
version = "4.3.
|
|
3
|
+
version = "4.3.3"
|
|
4
4
|
description = "Synthetic Data SDK"
|
|
5
5
|
authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
|
|
6
6
|
requires-python = ">=3.10,<3.14"
|
|
@@ -47,7 +47,7 @@ dependencies = [
|
|
|
47
47
|
local = [
|
|
48
48
|
# local
|
|
49
49
|
"mostlyai-engine==1.1.6",
|
|
50
|
-
"mostlyai-qa==1.5.
|
|
50
|
+
"mostlyai-qa==1.5.7",
|
|
51
51
|
"fastapi>=0.115.6,<0.116",
|
|
52
52
|
"uvicorn>=0.34.0,<0.35",
|
|
53
53
|
"python-multipart>=0.0.20",
|
|
@@ -69,7 +69,7 @@ local = [
|
|
|
69
69
|
]
|
|
70
70
|
local-gpu = [
|
|
71
71
|
"mostlyai-engine[gpu]==1.1.6",
|
|
72
|
-
"mostlyai-qa[gpu]==1.5.
|
|
72
|
+
"mostlyai-qa[gpu]==1.5.7",
|
|
73
73
|
"fastapi>=0.115.6,<0.116",
|
|
74
74
|
"uvicorn>=0.34.0,<0.35",
|
|
75
75
|
"python-multipart>=0.0.20",
|
|
@@ -91,7 +91,7 @@ local-gpu = [
|
|
|
91
91
|
]
|
|
92
92
|
local-cpu = [
|
|
93
93
|
"mostlyai-engine[cpu]==1.1.6",
|
|
94
|
-
"mostlyai-qa[cpu]==1.5.
|
|
94
|
+
"mostlyai-qa[cpu]==1.5.7",
|
|
95
95
|
"fastapi>=0.115.6,<0.116",
|
|
96
96
|
"uvicorn>=0.34.0,<0.35",
|
|
97
97
|
"python-multipart>=0.0.20",
|
|
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
|
|
File without changes
|
{mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_analyze_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.3.2 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_encode_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.3.2 → mostlyai-4.3.3}/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
|
|
File without changes
|