mostlyai 4.3.1__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.1 → mostlyai-4.3.3}/PKG-INFO +16 -28
- {mostlyai-4.3.1 → mostlyai-4.3.3}/README.md +12 -24
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/__init__.py +1 -1
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/client/_utils.py +3 -1
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/client/api.py +169 -108
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/client/base.py +13 -13
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/client/generators.py +73 -41
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/domain.py +40 -48
- mostlyai-4.3.3/mostlyai/sdk/py.typed +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/pyproject.toml +4 -4
- mostlyai-4.3.1/mostlyai/sdk/py.typed +0 -1
- {mostlyai-4.3.1 → mostlyai-4.3.3}/.gitignore +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/LICENSE +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/__init__.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/auto_detect.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/base.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/context.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/conversions.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/__init__.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/base.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/bigquery.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/databricks.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/hive.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/mssql.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/mysql.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/oracle.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/postgresql.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/snowflake.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/sqlite.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/dtype.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/exceptions.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/__init__.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/base.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/aws.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/azure.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/container/minio.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/table/csv.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/table/feather.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/table/json.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/file/utils.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/language_model.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/metadata_objects.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/non_context.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/progress_callback.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/pull.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/pull_context.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/pull_utils.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/push.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/util/__init__.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/util/common.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_data/util/kerberos.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/__init__.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/cli.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/connectors.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/__init__.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/jobs.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/plan.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/generators.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/progress.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/routes.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/server.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/storage.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/client/__init__.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/client/_base_utils.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/client/_naming_conventions.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/client/connectors.py +6 -6
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/client/exceptions.py +0 -0
- {mostlyai-4.3.1 → mostlyai-4.3.3}/mostlyai/sdk/client/synthetic_datasets.py +22 -22
|
@@ -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:
|
|
@@ -54,7 +54,17 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
54
54
|
"""
|
|
55
55
|
Instantiate an SDK instance, either in CLIENT or in LOCAL mode.
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
Args:
|
|
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
|
+
|
|
67
|
+
Example for SDK in CLIENT mode with explicit arguments:
|
|
58
68
|
```python
|
|
59
69
|
from mostlyai.sdk import MostlyAI
|
|
60
70
|
mostly = MostlyAI(
|
|
@@ -65,7 +75,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
65
75
|
# MostlyAI(base_url='https://app.mostly.ai', api_key='***')
|
|
66
76
|
```
|
|
67
77
|
|
|
68
|
-
Example for
|
|
78
|
+
Example for SDK in CLIENT mode with environment variables:
|
|
69
79
|
```python
|
|
70
80
|
import os
|
|
71
81
|
from mostlyai.sdk import MostlyAI
|
|
@@ -76,7 +86,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
76
86
|
# MostlyAI(base_url='https://app.mostly.ai', api_key='***')
|
|
77
87
|
```
|
|
78
88
|
|
|
79
|
-
Example for
|
|
89
|
+
Example for SDK in LOCAL mode connecting via UDS:
|
|
80
90
|
```python
|
|
81
91
|
from mostlyai.sdk import MostlyAI
|
|
82
92
|
mostly = MostlyAI(local=True)
|
|
@@ -84,23 +94,13 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
84
94
|
# MostlyAI(local=True)
|
|
85
95
|
```
|
|
86
96
|
|
|
87
|
-
Example for
|
|
97
|
+
Example for SDK in LOCAL mode connecting via TCP:
|
|
88
98
|
```python
|
|
89
99
|
from mostlyai.sdk import MostlyAI
|
|
90
100
|
mostly = MostlyAI(local=True, local_port=8080)
|
|
91
101
|
mostly
|
|
92
102
|
# MostlyAI(local=True, local_port=8080)
|
|
93
103
|
```
|
|
94
|
-
|
|
95
|
-
Args:
|
|
96
|
-
base_url: The base URL. If not provided, a default value is used.
|
|
97
|
-
api_key: The API key for authenticating. If not provided, it would rely on environment variables.
|
|
98
|
-
local: Whether to run in local mode or not.
|
|
99
|
-
local_dir: The directory to use for local mode. If not provided, `~/mostlyai` will be used.
|
|
100
|
-
local_port: The port to use for local mode with TCP transport. If not provided, UDS transport is used by default.
|
|
101
|
-
timeout: Timeout for HTTPS requests in seconds.
|
|
102
|
-
ssl_verify: Whether to verify SSL certificates.
|
|
103
|
-
quiet: Whether to suppress rich output.
|
|
104
104
|
"""
|
|
105
105
|
|
|
106
106
|
def __init__(
|
|
@@ -241,7 +241,12 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
241
241
|
"""
|
|
242
242
|
Create a connector and optionally validate the connection before saving.
|
|
243
243
|
|
|
244
|
-
|
|
244
|
+
Args:
|
|
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.
|
|
247
|
+
|
|
248
|
+
Returns:
|
|
249
|
+
Connector: The created connector.
|
|
245
250
|
|
|
246
251
|
Example for creating a connector to a AWS S3 storage:
|
|
247
252
|
```python
|
|
@@ -260,10 +265,6 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
260
265
|
)
|
|
261
266
|
```
|
|
262
267
|
|
|
263
|
-
Args:
|
|
264
|
-
config: Configuration for the connector. Can be either a ConnectorConfig object or an equivalent dictionary.
|
|
265
|
-
test_connection: Whether to validate the connection before saving.
|
|
266
|
-
|
|
267
268
|
The structures of the `config`, `secrets` and `ssl` parameters depend on the connector `type`:
|
|
268
269
|
|
|
269
270
|
- Cloud storage:
|
|
@@ -380,9 +381,6 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
380
381
|
secrets:
|
|
381
382
|
password: string
|
|
382
383
|
```
|
|
383
|
-
|
|
384
|
-
Returns:
|
|
385
|
-
Connector: The created connector.
|
|
386
384
|
"""
|
|
387
385
|
c = self.connectors.create(config=config, test_connection=test_connection)
|
|
388
386
|
return c
|
|
@@ -399,87 +397,155 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
399
397
|
"""
|
|
400
398
|
Train a generator.
|
|
401
399
|
|
|
402
|
-
|
|
400
|
+
Args:
|
|
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.
|
|
403
407
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
from mostlyai.sdk import MostlyAI
|
|
407
|
-
mostly = MostlyAI()
|
|
408
|
-
g = mostly.train(
|
|
409
|
-
data='https://github.com/mostly-ai/public-demo-data/raw/dev/census/census.csv.gz',
|
|
410
|
-
)
|
|
411
|
-
```
|
|
408
|
+
Returns:
|
|
409
|
+
Generator: The created generator.
|
|
412
410
|
|
|
413
|
-
Example of
|
|
411
|
+
Example of single table with default configurations:
|
|
414
412
|
```python
|
|
415
413
|
# read original data
|
|
416
414
|
import pandas as pd
|
|
417
|
-
|
|
415
|
+
df = pd.read_csv('https://github.com/mostly-ai/public-demo-data/raw/dev/census/census.csv.gz')
|
|
418
416
|
# instantiate client
|
|
419
417
|
from mostlyai.sdk import MostlyAI
|
|
420
418
|
mostly = MostlyAI()
|
|
421
419
|
# train generator
|
|
422
420
|
g = mostly.train(
|
|
423
421
|
name='census',
|
|
424
|
-
data=
|
|
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
|
|
425
425
|
)
|
|
426
426
|
```
|
|
427
427
|
|
|
428
|
-
Example
|
|
428
|
+
Example of single table with custom configurations:
|
|
429
429
|
```python
|
|
430
430
|
# read original data
|
|
431
431
|
import pandas as pd
|
|
432
|
-
|
|
432
|
+
df = pd.read_csv('https://github.com/mostly-ai/public-demo-data/raw/dev/baseball/players.csv.gz')
|
|
433
433
|
# instantiate client
|
|
434
434
|
from mostlyai.sdk import MostlyAI
|
|
435
435
|
mostly = MostlyAI()
|
|
436
|
-
# configure generator via
|
|
437
|
-
from mostlyai.sdk.domain import GeneratorConfig, SourceTableConfig
|
|
436
|
+
# configure generator via dictionary
|
|
438
437
|
g = mostly.train(
|
|
439
|
-
config=GeneratorConfig
|
|
440
|
-
name
|
|
441
|
-
tables
|
|
442
|
-
SourceTableConfig
|
|
443
|
-
name
|
|
444
|
-
data
|
|
445
|
-
|
|
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
|
+
}
|
|
446
472
|
]
|
|
447
|
-
|
|
473
|
+
},
|
|
474
|
+
start=True, # start training immediately
|
|
475
|
+
wait=True, # wait for training to finish
|
|
448
476
|
)
|
|
449
477
|
```
|
|
450
478
|
|
|
451
|
-
Example
|
|
479
|
+
Example of multi-table with custom configurations:
|
|
452
480
|
```python
|
|
453
481
|
# read original data
|
|
454
482
|
import pandas as pd
|
|
455
|
-
|
|
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()
|
|
456
485
|
# instantiate client
|
|
457
486
|
from mostlyai.sdk import MostlyAI
|
|
458
487
|
mostly = MostlyAI()
|
|
459
|
-
#
|
|
460
|
-
g = mostly.train(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
'
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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)
|
|
471
510
|
```
|
|
472
511
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
wait: Whether to wait for training to finish.
|
|
479
|
-
progress_bar: Whether to display a progress bar during training.
|
|
512
|
+
Example of multi-model with TABULAR and LANGUAGE models:
|
|
513
|
+
```python
|
|
514
|
+
# read original data
|
|
515
|
+
import pandas as pd
|
|
516
|
+
df = pd.read_parquet('https://github.com/mostly-ai/public-demo-data/raw/refs/heads/dev/headlines/headlines.parquet')
|
|
480
517
|
|
|
481
|
-
|
|
482
|
-
|
|
518
|
+
# instantiate SDK
|
|
519
|
+
from mostlyai.sdk import MostlyAI
|
|
520
|
+
mostly = MostlyAI()
|
|
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)
|
|
548
|
+
```
|
|
483
549
|
"""
|
|
484
550
|
if data is None and config is None:
|
|
485
551
|
raise ValueError("Either config or data must be provided")
|
|
@@ -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,7 +592,18 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
526
592
|
"""
|
|
527
593
|
Generate synthetic data.
|
|
528
594
|
|
|
529
|
-
|
|
595
|
+
Args:
|
|
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.
|
|
604
|
+
|
|
605
|
+
Returns:
|
|
606
|
+
SyntheticDataset: The created synthetic dataset.
|
|
530
607
|
|
|
531
608
|
Example configuration using short-hand notation:
|
|
532
609
|
```python
|
|
@@ -574,19 +651,6 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
574
651
|
}
|
|
575
652
|
)
|
|
576
653
|
```
|
|
577
|
-
|
|
578
|
-
Args:
|
|
579
|
-
generator: The generator instance or its UUID.
|
|
580
|
-
config: Configuration for the synthetic dataset.
|
|
581
|
-
size : Sample size(s) for the subject table(s).
|
|
582
|
-
seed: Seed data for the subject table(s).
|
|
583
|
-
name: Name of the synthetic dataset.
|
|
584
|
-
start: Whether to start generation immediately.
|
|
585
|
-
wait: Whether to wait for generation to finish.
|
|
586
|
-
progress_bar: Whether to display a progress bar during generation.
|
|
587
|
-
|
|
588
|
-
Returns:
|
|
589
|
-
SyntheticDataset: The created synthetic dataset.
|
|
590
654
|
"""
|
|
591
655
|
config = harmonize_sd_config(
|
|
592
656
|
generator,
|
|
@@ -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,7 +679,15 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
615
679
|
"""
|
|
616
680
|
Probe a generator.
|
|
617
681
|
|
|
618
|
-
|
|
682
|
+
Args:
|
|
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".
|
|
688
|
+
|
|
689
|
+
Returns:
|
|
690
|
+
pd.DataFrame | dict[str, pd.DataFrame]: The created synthetic probe.
|
|
619
691
|
|
|
620
692
|
Example for probing a generator for 10 synthetic samples:
|
|
621
693
|
```python
|
|
@@ -647,16 +719,6 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
647
719
|
}),
|
|
648
720
|
)
|
|
649
721
|
```
|
|
650
|
-
|
|
651
|
-
Args:
|
|
652
|
-
generator: The generator instance or its UUID.
|
|
653
|
-
size: Sample size(s) for the subject table(s).
|
|
654
|
-
seed: Seed data for the subject table(s).
|
|
655
|
-
config: Configuration for the probe.
|
|
656
|
-
return_type: Format of the return value. "auto" for pandas DataFrame if a single table, otherwise a dictionary.
|
|
657
|
-
|
|
658
|
-
Returns:
|
|
659
|
-
The created synthetic probe.
|
|
660
722
|
"""
|
|
661
723
|
config = harmonize_sd_config(
|
|
662
724
|
generator,
|
|
@@ -676,6 +738,9 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
676
738
|
"""
|
|
677
739
|
Retrieve information about the current user.
|
|
678
740
|
|
|
741
|
+
Returns:
|
|
742
|
+
CurrentUser: Information about the current user.
|
|
743
|
+
|
|
679
744
|
Example for retrieving information about the current user:
|
|
680
745
|
```python
|
|
681
746
|
from mostlyai.sdk import MostlyAI
|
|
@@ -683,9 +748,6 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
683
748
|
mostly.me()
|
|
684
749
|
# {'id': '488f2f26-...', 'first_name': 'Tom', ...}
|
|
685
750
|
```
|
|
686
|
-
|
|
687
|
-
Returns:
|
|
688
|
-
Information about the current user.
|
|
689
751
|
"""
|
|
690
752
|
return self.request(verb=GET, path=["users", "me"], response_type=CurrentUser)
|
|
691
753
|
|
|
@@ -693,6 +755,9 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
693
755
|
"""
|
|
694
756
|
Retrieve information about the platform.
|
|
695
757
|
|
|
758
|
+
Returns:
|
|
759
|
+
AboutService: Information about the platform.
|
|
760
|
+
|
|
696
761
|
Example for retrieving information about the platform:
|
|
697
762
|
```python
|
|
698
763
|
from mostlyai.sdk import MostlyAI
|
|
@@ -700,9 +765,6 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
700
765
|
mostly.about()
|
|
701
766
|
# {'version': 'v316', 'assistant': True}
|
|
702
767
|
```
|
|
703
|
-
|
|
704
|
-
Returns:
|
|
705
|
-
Information about the platform.
|
|
706
768
|
"""
|
|
707
769
|
return self.request(verb=GET, path=["about"], response_type=AboutService)
|
|
708
770
|
|
|
@@ -710,6 +772,9 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
710
772
|
"""
|
|
711
773
|
Retrieve a list of available models of a specific type.
|
|
712
774
|
|
|
775
|
+
Returns:
|
|
776
|
+
dict[str, list[str]]: A dictionary with list of available models for each ModelType.
|
|
777
|
+
|
|
713
778
|
Example for retrieving available models:
|
|
714
779
|
```python
|
|
715
780
|
from mostlyai.sdk import MostlyAI
|
|
@@ -720,15 +785,14 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
720
785
|
# 'LANGUAGE": ['MOSTLY_AI/LSTMFromScratch-3m', 'microsoft/phi-1_5', ..],
|
|
721
786
|
# }
|
|
722
787
|
```
|
|
723
|
-
|
|
724
|
-
Returns:
|
|
725
|
-
A dictionary with list of available models for each ModelType.
|
|
726
788
|
"""
|
|
727
789
|
return {model_type.value: self.request(verb=GET, path=["models", model_type.value]) for model_type in ModelType}
|
|
728
790
|
|
|
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.
|
|
794
|
+
Returns:
|
|
795
|
+
list[dict[str, Any]]: A list of available compute resources.
|
|
732
796
|
|
|
733
797
|
Example for retrieving available compute resources:
|
|
734
798
|
```python
|
|
@@ -737,8 +801,5 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
737
801
|
mostly.computes()
|
|
738
802
|
# [{'id': '...', 'name': 'CPU Large',...]
|
|
739
803
|
```
|
|
740
|
-
|
|
741
|
-
Returns:
|
|
742
|
-
A list of available compute resources.
|
|
743
804
|
"""
|
|
744
805
|
return self.request(verb=GET, path=["computes"])
|