mostlyai 4.2.5__tar.gz → 4.2.7__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.2.5 → mostlyai-4.2.7}/PKG-INFO +76 -69
- {mostlyai-4.2.5 → mostlyai-4.2.7}/README.md +75 -68
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/__init__.py +1 -1
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/routes.py +5 -1
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/server.py +25 -4
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/client/_base_utils.py +6 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/client/_utils.py +1 -1
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/client/api.py +71 -42
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/client/base.py +1 -1
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/domain.py +16 -6
- {mostlyai-4.2.5 → mostlyai-4.2.7}/pyproject.toml +1 -1
- {mostlyai-4.2.5 → mostlyai-4.2.7}/.gitignore +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/LICENSE +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/__init__.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/auto_detect.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/base.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/context.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/conversions.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/__init__.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/base.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/bigquery.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/databricks.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/hive.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/mssql.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/mysql.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/oracle.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/postgresql.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/snowflake.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/sqlite.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/dtype.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/exceptions.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/__init__.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/base.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/aws.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/azure.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/minio.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/table/csv.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/table/feather.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/table/json.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/utils.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/language_model.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/metadata_objects.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/non_context.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/progress_callback.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/pull.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/pull_context.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/pull_utils.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/push.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/util/__init__.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/util/common.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_data/util/kerberos.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/__init__.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/cli.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/connectors.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/__init__.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/jobs.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/plan.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/generators.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/progress.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/storage.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/client/__init__.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/client/_naming_conventions.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/client/connectors.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/client/exceptions.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/client/generators.py +0 -0
- {mostlyai-4.2.5 → mostlyai-4.2.7}/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.2.
|
|
3
|
+
Version: 4.2.7
|
|
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
|
|
@@ -122,19 +122,18 @@ Provides-Extra: snowflake
|
|
|
122
122
|
Requires-Dist: snowflake-sqlalchemy<2,>=1.6.1; extra == 'snowflake'
|
|
123
123
|
Description-Content-Type: text/markdown
|
|
124
124
|
|
|
125
|
-
|
|
126
125
|
# Synthetic Data SDK ✨
|
|
127
126
|
|
|
128
|
-
[](https://pypi.org/project/mostlyai/)
|
|
127
|
+
[](https://github.com/mostly-ai/mostlyai/releases)
|
|
128
|
+
[](https://mostly-ai.github.io/mostlyai/)
|
|
129
|
+
[](https://pepy.tech/projects/mostlyai)
|
|
130
|
+
[](https://github.com/mostly-ai/mostlyai/blob/main/LICENSE)
|
|
131
|
+
[](https://pypi.org/project/mostlyai/)
|
|
133
132
|
[](https://github.com/mostly-ai/mostlyai/stargazers)
|
|
134
133
|
|
|
135
|
-
[
|
|
134
|
+
[Documentation](https://mostly-ai.github.io/mostlyai/) | [Usage Examples](https://mostly-ai.github.io/mostlyai/usage/) | [Free Cloud Service](https://app.mostly.ai/)
|
|
136
135
|
|
|
137
|
-
The Synthetic Data SDK is a Python toolkit for high-fidelity, privacy-safe **Synthetic Data**.
|
|
136
|
+
The **Synthetic Data SDK** is a Python toolkit for high-fidelity, privacy-safe **Synthetic Data**.
|
|
138
137
|
|
|
139
138
|
- **LOCAL** mode trains and generates synthetic data locally on your own compute resources.
|
|
140
139
|
- **CLIENT** mode connects to a remote MOSTLY AI platform for training & generating synthetic data there.
|
|
@@ -155,39 +154,44 @@ The SDK allows you to programmatically create, browse and manage 3 key resources
|
|
|
155
154
|
| Live probe the generator on demand | `df = mostly.probe(g, config)` | [mostly.probe](https://mostly-ai.github.io/mostlyai/api_client/#mostlyai.sdk.client.api.MostlyAI.probe) |
|
|
156
155
|
| Connect to any data source within your org | `c = mostly.connect(config)` | [mostly.connect](https://mostly-ai.github.io/mostlyai/api_client/#mostlyai.sdk.client.api.MostlyAI.connect) |
|
|
157
156
|
|
|
158
|
-
https://github.com/user-attachments/assets/d1613636-06e4-4147-bef7-25bb4699e8fc
|
|
159
|
-
|
|
160
|
-
## Installation
|
|
161
|
-
|
|
162
|
-
**CLIENT mode only**
|
|
163
|
-
|
|
164
|
-
```shell
|
|
165
|
-
pip install -U mostlyai
|
|
166
|
-
```
|
|
157
|
+
<https://github.com/user-attachments/assets/d1613636-06e4-4147-bef7-25bb4699e8fc>
|
|
167
158
|
|
|
168
|
-
|
|
159
|
+
## Key Features
|
|
169
160
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
161
|
+
- **Broad Data Support**
|
|
162
|
+
- Mixed-type data (categorical, numerical, geospatial, text, etc.)
|
|
163
|
+
- Single-table, multi-table, and time-series
|
|
164
|
+
- **Multiple Model Types**
|
|
165
|
+
- TabularARGN for SOTA tabular performance
|
|
166
|
+
- Fine-tune HuggingFace-based language models
|
|
167
|
+
- Efficient LSTM for text synthesis from scratch
|
|
168
|
+
- **Advanced Training Options**
|
|
169
|
+
- GPU/CPU support
|
|
170
|
+
- Differential Privacy
|
|
171
|
+
- Progress Monitoring
|
|
172
|
+
- **Automated Quality Assurance**
|
|
173
|
+
- Quality metrics for fidelity and privacy
|
|
174
|
+
- In-depth HTML reports for visual analysis
|
|
175
|
+
- **Flexible Sampling**
|
|
176
|
+
- Up-sample to any data volumes
|
|
177
|
+
- Conditional generation by any columns
|
|
178
|
+
- Re-balance underrepresented segments
|
|
179
|
+
- Context-aware data imputation
|
|
180
|
+
- Statistical fairness controls
|
|
181
|
+
- Rule-adherence via temperature
|
|
182
|
+
- **Seamless Integration**
|
|
183
|
+
- Connect to external data sources (DBs, cloud storages)
|
|
184
|
+
- Fully permissive open-source license
|
|
178
185
|
|
|
179
|
-
|
|
186
|
+
## Quick Start <a href="https://colab.research.google.com/github/mostly-ai/mostlyai/blob/main/docs/tutorials/getting-started/getting-started.ipynb" target="_blank"><img src="https://img.shields.io/badge/Open%20in-Colab-blue?logo=google-colab" alt="Run on Colab"></a>
|
|
180
187
|
|
|
181
|
-
|
|
188
|
+
Install the SDK via pip:
|
|
182
189
|
|
|
183
|
-
E.g.
|
|
184
190
|
```shell
|
|
185
|
-
pip install
|
|
191
|
+
pip install mostlyai
|
|
186
192
|
```
|
|
187
193
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
Generate your first samples based on your own trained generator with a few lines of code. For LOCAL mode, initialize the SDK with `local=True`. For CLIENT mode, initialize the SDK with `base_url` and `api_key` obtained from your [account settings page](https://app.mostly.ai/settings/api-keys).
|
|
194
|
+
Train your first generator:
|
|
191
195
|
|
|
192
196
|
```python
|
|
193
197
|
import pandas as pd
|
|
@@ -197,9 +201,8 @@ from mostlyai.sdk import MostlyAI
|
|
|
197
201
|
repo_url = "https://github.com/mostly-ai/public-demo-data/raw/refs/heads/dev"
|
|
198
202
|
df_original = pd.read_csv(f"{repo_url}/census/census.csv.gz")
|
|
199
203
|
|
|
200
|
-
# initialize the SDK
|
|
201
|
-
mostly = MostlyAI(
|
|
202
|
-
# mostly = MostlyAI(base_url='xxx', api_key='xxx') # client mode
|
|
204
|
+
# initialize the SDK
|
|
205
|
+
mostly = MostlyAI()
|
|
203
206
|
|
|
204
207
|
# train a synthetic data generator
|
|
205
208
|
g = mostly.train(
|
|
@@ -210,14 +213,14 @@ g = mostly.train(
|
|
|
210
213
|
"name": "census",
|
|
211
214
|
"data": df_original,
|
|
212
215
|
"tabular_model_configuration": { # tabular model configuration (optional)
|
|
213
|
-
"max_training_time": 1,
|
|
214
|
-
# model, max_epochs,,..
|
|
215
|
-
# 'differential_privacy': {
|
|
216
|
-
# 'max_epsilon': 5.0,
|
|
217
|
-
# 'delta': 1e-5,
|
|
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
|
|
218
221
|
# }
|
|
219
222
|
},
|
|
220
|
-
# columns, keys, compute,..
|
|
223
|
+
# columns, keys, compute,.. # further table configurations (optional)
|
|
221
224
|
}
|
|
222
225
|
],
|
|
223
226
|
},
|
|
@@ -229,7 +232,7 @@ g = mostly.train(
|
|
|
229
232
|
g.reports(display=True)
|
|
230
233
|
```
|
|
231
234
|
|
|
232
|
-
Once the generator has been trained,
|
|
235
|
+
Once the generator has been trained, generate synthetic data samples. Either via probing:
|
|
233
236
|
|
|
234
237
|
```python
|
|
235
238
|
# probe for some representative synthetic samples
|
|
@@ -259,32 +262,36 @@ df_samples = mostly.probe(g, seed=df_seed)
|
|
|
259
262
|
df_samples
|
|
260
263
|
```
|
|
261
264
|
|
|
262
|
-
##
|
|
265
|
+
## Installation
|
|
263
266
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
267
|
+
Use `pip` (or better `uv pip`) to install the official `mostlyai` package via PyPI. Python 3.10 or higher is required. It is recommended to install the package within a dedicated virtual environment.
|
|
268
|
+
|
|
269
|
+
### CLIENT mode
|
|
270
|
+
|
|
271
|
+
This is a light-weight installation for using the SDK in CLIENT mode only. It communicates to a MOSTLY AI platform to perform requested tasks. See e.g. [app.mostly.ai](https://app.mostly.ai/) for a free-to-use hosted version.
|
|
272
|
+
|
|
273
|
+
```shell
|
|
274
|
+
pip install -U mostlyai
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### CLIENT + LOCAL mode
|
|
278
|
+
|
|
279
|
+
This is a full installation for using the SDK in both CLIENT and LOCAL mode. It includes all dependencies, incl. PyTorch, for training and generating synthetic data locally.
|
|
280
|
+
|
|
281
|
+
```shell
|
|
282
|
+
# for CPU on macOS
|
|
283
|
+
pip install -U 'mostlyai[local]'
|
|
284
|
+
# for CPU on Linux
|
|
285
|
+
pip install -U 'mostlyai[local-cpu]' --extra-index-url https://download.pytorch.org/whl/cpu
|
|
286
|
+
# for GPU on Linux
|
|
287
|
+
pip install -U 'mostlyai[local-gpu]'
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Add any of the following extras for further data connectors support in LOCAL mode: `databricks`, `googlebigquery`, `hive`, `mssql`, `mysql`, `oracle`, `postgres`, `snowflake`. E.g.
|
|
291
|
+
|
|
292
|
+
```shell
|
|
293
|
+
pip install -U 'mostlyai[local, databricks, snowflake]'
|
|
294
|
+
```
|
|
288
295
|
|
|
289
296
|
## Citation
|
|
290
297
|
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
1
|
# Synthetic Data SDK ✨
|
|
3
2
|
|
|
4
|
-
[](https://pypi.org/project/mostlyai/)
|
|
3
|
+
[](https://github.com/mostly-ai/mostlyai/releases)
|
|
4
|
+
[](https://mostly-ai.github.io/mostlyai/)
|
|
5
|
+
[](https://pepy.tech/projects/mostlyai)
|
|
6
|
+
[](https://github.com/mostly-ai/mostlyai/blob/main/LICENSE)
|
|
7
|
+
[](https://pypi.org/project/mostlyai/)
|
|
9
8
|
[](https://github.com/mostly-ai/mostlyai/stargazers)
|
|
10
9
|
|
|
11
|
-
[
|
|
10
|
+
[Documentation](https://mostly-ai.github.io/mostlyai/) | [Usage Examples](https://mostly-ai.github.io/mostlyai/usage/) | [Free Cloud Service](https://app.mostly.ai/)
|
|
12
11
|
|
|
13
|
-
The Synthetic Data SDK is a Python toolkit for high-fidelity, privacy-safe **Synthetic Data**.
|
|
12
|
+
The **Synthetic Data SDK** is a Python toolkit for high-fidelity, privacy-safe **Synthetic Data**.
|
|
14
13
|
|
|
15
14
|
- **LOCAL** mode trains and generates synthetic data locally on your own compute resources.
|
|
16
15
|
- **CLIENT** mode connects to a remote MOSTLY AI platform for training & generating synthetic data there.
|
|
@@ -31,39 +30,44 @@ The SDK allows you to programmatically create, browse and manage 3 key resources
|
|
|
31
30
|
| Live probe the generator on demand | `df = mostly.probe(g, config)` | [mostly.probe](https://mostly-ai.github.io/mostlyai/api_client/#mostlyai.sdk.client.api.MostlyAI.probe) |
|
|
32
31
|
| Connect to any data source within your org | `c = mostly.connect(config)` | [mostly.connect](https://mostly-ai.github.io/mostlyai/api_client/#mostlyai.sdk.client.api.MostlyAI.connect) |
|
|
33
32
|
|
|
34
|
-
https://github.com/user-attachments/assets/d1613636-06e4-4147-bef7-25bb4699e8fc
|
|
35
|
-
|
|
36
|
-
## Installation
|
|
37
|
-
|
|
38
|
-
**CLIENT mode only**
|
|
39
|
-
|
|
40
|
-
```shell
|
|
41
|
-
pip install -U mostlyai
|
|
42
|
-
```
|
|
33
|
+
<https://github.com/user-attachments/assets/d1613636-06e4-4147-bef7-25bb4699e8fc>
|
|
43
34
|
|
|
44
|
-
|
|
35
|
+
## Key Features
|
|
45
36
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
37
|
+
- **Broad Data Support**
|
|
38
|
+
- Mixed-type data (categorical, numerical, geospatial, text, etc.)
|
|
39
|
+
- Single-table, multi-table, and time-series
|
|
40
|
+
- **Multiple Model Types**
|
|
41
|
+
- TabularARGN for SOTA tabular performance
|
|
42
|
+
- Fine-tune HuggingFace-based language models
|
|
43
|
+
- Efficient LSTM for text synthesis from scratch
|
|
44
|
+
- **Advanced Training Options**
|
|
45
|
+
- GPU/CPU support
|
|
46
|
+
- Differential Privacy
|
|
47
|
+
- Progress Monitoring
|
|
48
|
+
- **Automated Quality Assurance**
|
|
49
|
+
- Quality metrics for fidelity and privacy
|
|
50
|
+
- In-depth HTML reports for visual analysis
|
|
51
|
+
- **Flexible Sampling**
|
|
52
|
+
- Up-sample to any data volumes
|
|
53
|
+
- Conditional generation by any columns
|
|
54
|
+
- Re-balance underrepresented segments
|
|
55
|
+
- Context-aware data imputation
|
|
56
|
+
- Statistical fairness controls
|
|
57
|
+
- Rule-adherence via temperature
|
|
58
|
+
- **Seamless Integration**
|
|
59
|
+
- Connect to external data sources (DBs, cloud storages)
|
|
60
|
+
- Fully permissive open-source license
|
|
54
61
|
|
|
55
|
-
|
|
62
|
+
## Quick Start <a href="https://colab.research.google.com/github/mostly-ai/mostlyai/blob/main/docs/tutorials/getting-started/getting-started.ipynb" target="_blank"><img src="https://img.shields.io/badge/Open%20in-Colab-blue?logo=google-colab" alt="Run on Colab"></a>
|
|
56
63
|
|
|
57
|
-
|
|
64
|
+
Install the SDK via pip:
|
|
58
65
|
|
|
59
|
-
E.g.
|
|
60
66
|
```shell
|
|
61
|
-
pip install
|
|
67
|
+
pip install mostlyai
|
|
62
68
|
```
|
|
63
69
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Generate your first samples based on your own trained generator with a few lines of code. For LOCAL mode, initialize the SDK with `local=True`. For CLIENT mode, initialize the SDK with `base_url` and `api_key` obtained from your [account settings page](https://app.mostly.ai/settings/api-keys).
|
|
70
|
+
Train your first generator:
|
|
67
71
|
|
|
68
72
|
```python
|
|
69
73
|
import pandas as pd
|
|
@@ -73,9 +77,8 @@ from mostlyai.sdk import MostlyAI
|
|
|
73
77
|
repo_url = "https://github.com/mostly-ai/public-demo-data/raw/refs/heads/dev"
|
|
74
78
|
df_original = pd.read_csv(f"{repo_url}/census/census.csv.gz")
|
|
75
79
|
|
|
76
|
-
# initialize the SDK
|
|
77
|
-
mostly = MostlyAI(
|
|
78
|
-
# mostly = MostlyAI(base_url='xxx', api_key='xxx') # client mode
|
|
80
|
+
# initialize the SDK
|
|
81
|
+
mostly = MostlyAI()
|
|
79
82
|
|
|
80
83
|
# train a synthetic data generator
|
|
81
84
|
g = mostly.train(
|
|
@@ -86,14 +89,14 @@ g = mostly.train(
|
|
|
86
89
|
"name": "census",
|
|
87
90
|
"data": df_original,
|
|
88
91
|
"tabular_model_configuration": { # tabular model configuration (optional)
|
|
89
|
-
"max_training_time": 1,
|
|
90
|
-
# model, max_epochs,,..
|
|
91
|
-
# 'differential_privacy': {
|
|
92
|
-
# 'max_epsilon': 5.0,
|
|
93
|
-
# 'delta': 1e-5,
|
|
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
|
|
94
97
|
# }
|
|
95
98
|
},
|
|
96
|
-
# columns, keys, compute,..
|
|
99
|
+
# columns, keys, compute,.. # further table configurations (optional)
|
|
97
100
|
}
|
|
98
101
|
],
|
|
99
102
|
},
|
|
@@ -105,7 +108,7 @@ g = mostly.train(
|
|
|
105
108
|
g.reports(display=True)
|
|
106
109
|
```
|
|
107
110
|
|
|
108
|
-
Once the generator has been trained,
|
|
111
|
+
Once the generator has been trained, generate synthetic data samples. Either via probing:
|
|
109
112
|
|
|
110
113
|
```python
|
|
111
114
|
# probe for some representative synthetic samples
|
|
@@ -135,32 +138,36 @@ df_samples = mostly.probe(g, seed=df_seed)
|
|
|
135
138
|
df_samples
|
|
136
139
|
```
|
|
137
140
|
|
|
138
|
-
##
|
|
141
|
+
## Installation
|
|
139
142
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
143
|
+
Use `pip` (or better `uv pip`) to install the official `mostlyai` package via PyPI. Python 3.10 or higher is required. It is recommended to install the package within a dedicated virtual environment.
|
|
144
|
+
|
|
145
|
+
### CLIENT mode
|
|
146
|
+
|
|
147
|
+
This is a light-weight installation for using the SDK in CLIENT mode only. It communicates to a MOSTLY AI platform to perform requested tasks. See e.g. [app.mostly.ai](https://app.mostly.ai/) for a free-to-use hosted version.
|
|
148
|
+
|
|
149
|
+
```shell
|
|
150
|
+
pip install -U mostlyai
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### CLIENT + LOCAL mode
|
|
154
|
+
|
|
155
|
+
This is a full installation for using the SDK in both CLIENT and LOCAL mode. It includes all dependencies, incl. PyTorch, for training and generating synthetic data locally.
|
|
156
|
+
|
|
157
|
+
```shell
|
|
158
|
+
# for CPU on macOS
|
|
159
|
+
pip install -U 'mostlyai[local]'
|
|
160
|
+
# for CPU on Linux
|
|
161
|
+
pip install -U 'mostlyai[local-cpu]' --extra-index-url https://download.pytorch.org/whl/cpu
|
|
162
|
+
# for GPU on Linux
|
|
163
|
+
pip install -U 'mostlyai[local-gpu]'
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Add any of the following extras for further data connectors support in LOCAL mode: `databricks`, `googlebigquery`, `hive`, `mssql`, `mysql`, `oracle`, `postgres`, `snowflake`. E.g.
|
|
167
|
+
|
|
168
|
+
```shell
|
|
169
|
+
pip install -U 'mostlyai[local, databricks, snowflake]'
|
|
170
|
+
```
|
|
164
171
|
|
|
165
172
|
## Citation
|
|
166
173
|
|
|
@@ -22,7 +22,7 @@ from pathlib import Path
|
|
|
22
22
|
|
|
23
23
|
from fastapi import APIRouter, Body, HTTPException, UploadFile, File
|
|
24
24
|
from fastapi.encoders import jsonable_encoder
|
|
25
|
-
from fastapi.responses import FileResponse, JSONResponse, StreamingResponse, HTMLResponse
|
|
25
|
+
from fastapi.responses import FileResponse, JSONResponse, StreamingResponse, HTMLResponse, RedirectResponse
|
|
26
26
|
|
|
27
27
|
from mostlyai import sdk
|
|
28
28
|
from mostlyai.sdk._data.conversions import create_container_from_connector
|
|
@@ -104,6 +104,10 @@ class Routes:
|
|
|
104
104
|
"""
|
|
105
105
|
|
|
106
106
|
def _initialize_routes(self):
|
|
107
|
+
@self.router.get("/", include_in_schema=False)
|
|
108
|
+
async def root() -> RedirectResponse:
|
|
109
|
+
return RedirectResponse(url="/docs")
|
|
110
|
+
|
|
107
111
|
## GENERAL
|
|
108
112
|
|
|
109
113
|
@self.router.get("/about", response_model=AboutService)
|
|
@@ -28,14 +28,33 @@ import os
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
class LocalServer:
|
|
31
|
+
"""
|
|
32
|
+
Instantiate a local server for the Synthetic Data SDK.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
home_dir: The directory where the SDK stores its data. Defaults to `~/mostlyai`.
|
|
36
|
+
port: The port to bind the server to. If `None`, a Unix Domain Socket (UDS) will be used. Defaults to `None`.
|
|
37
|
+
"""
|
|
38
|
+
|
|
31
39
|
def __init__(
|
|
32
40
|
self,
|
|
33
41
|
home_dir: str | Path | None = None,
|
|
42
|
+
port: int | None = None,
|
|
34
43
|
):
|
|
35
44
|
self.home_dir = Path(home_dir or "~/mostlyai").expanduser()
|
|
36
45
|
self.home_dir.mkdir(parents=True, exist_ok=True)
|
|
37
|
-
|
|
38
|
-
self.
|
|
46
|
+
# check read/write access to `home_dir`
|
|
47
|
+
if not os.access(self.home_dir, os.R_OK) or not os.access(self.home_dir, os.W_OK):
|
|
48
|
+
raise PermissionError(f"Cannot read/write to {self.home_dir}")
|
|
49
|
+
self.port = port
|
|
50
|
+
# binding to all interfaces (0.0.0.0) is required for docker use case
|
|
51
|
+
self.host = "0.0.0.0" if port is not None else None
|
|
52
|
+
self.uds = (
|
|
53
|
+
tempfile.NamedTemporaryFile(prefix=".mostlyai-", suffix=".sock", delete=False).name
|
|
54
|
+
if port is None
|
|
55
|
+
else None
|
|
56
|
+
)
|
|
57
|
+
self.base_url = "http://127.0.0.1" + (f":{port}" if port else "")
|
|
39
58
|
self._app = FastAPI(
|
|
40
59
|
root_path="/api/v2",
|
|
41
60
|
title="Synthetic Data SDK ✨",
|
|
@@ -52,12 +71,14 @@ class LocalServer:
|
|
|
52
71
|
self.start() # Automatically start the server during initialization
|
|
53
72
|
|
|
54
73
|
def _clear_socket_file(self):
|
|
55
|
-
if os.path.exists(self.uds):
|
|
74
|
+
if self.uds and os.path.exists(self.uds):
|
|
56
75
|
os.remove(self.uds)
|
|
57
76
|
|
|
58
77
|
def _create_server(self):
|
|
59
78
|
self._clear_socket_file()
|
|
60
|
-
config = uvicorn.Config(
|
|
79
|
+
config = uvicorn.Config(
|
|
80
|
+
self._app, host=self.host, port=self.port, uds=self.uds, log_level="error", reload=False
|
|
81
|
+
)
|
|
61
82
|
self._server = uvicorn.Server(config)
|
|
62
83
|
|
|
63
84
|
def _run_server(self):
|
|
@@ -46,9 +46,15 @@ def convert_to_base64(
|
|
|
46
46
|
# Save the DataFrame to a buffer in Parquet / JSONL format
|
|
47
47
|
buffer = io.BytesIO()
|
|
48
48
|
if format == "parquet":
|
|
49
|
+
# clear any (potentially non-serializable) attributes that might stop us from saving to PQT
|
|
50
|
+
if df.attrs:
|
|
51
|
+
df.attrs.clear()
|
|
52
|
+
# persist the DataFrame to Parquet format
|
|
49
53
|
df.to_parquet(buffer, index=False)
|
|
50
54
|
else: # format == "jsonl"
|
|
55
|
+
# persist the DataFrame to JSONL format
|
|
51
56
|
df.to_json(buffer, orient="records", date_format="iso", lines=True, index=False)
|
|
57
|
+
# read in persisted file as base64 encoded string
|
|
52
58
|
buffer.seek(0)
|
|
53
59
|
binary_data = buffer.read()
|
|
54
60
|
base64_encoded_str = base64.b64encode(binary_data).decode()
|
|
@@ -52,17 +52,9 @@ from mostlyai.sdk.client._utils import (
|
|
|
52
52
|
|
|
53
53
|
class MostlyAI(_MostlyBaseClient):
|
|
54
54
|
"""
|
|
55
|
-
Instantiate an SDK instance, either in
|
|
55
|
+
Instantiate an SDK instance, either in CLIENT or in LOCAL mode.
|
|
56
56
|
|
|
57
|
-
Example for instantiating the SDK in
|
|
58
|
-
```python
|
|
59
|
-
from mostlyai.sdk import MostlyAI
|
|
60
|
-
mostly = MostlyAI(local=True)
|
|
61
|
-
mostly
|
|
62
|
-
# MostlyAI(local=True)
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Example for instantiating the SDK in client mode with explicit arguments:
|
|
57
|
+
Example for instantiating the SDK in CLIENT mode with explicit arguments:
|
|
66
58
|
```python
|
|
67
59
|
from mostlyai.sdk import MostlyAI
|
|
68
60
|
mostly = MostlyAI(
|
|
@@ -73,22 +65,39 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
73
65
|
# MostlyAI(base_url='https://app.mostly.ai', api_key='***')
|
|
74
66
|
```
|
|
75
67
|
|
|
76
|
-
Example for instantiating the SDK with environment variables:
|
|
68
|
+
Example for instantiating the SDK in CLIENT mode with environment variables:
|
|
77
69
|
```python
|
|
78
70
|
import os
|
|
79
71
|
from mostlyai.sdk import MostlyAI
|
|
80
|
-
os.environ["
|
|
81
|
-
os.environ["
|
|
72
|
+
os.environ["MOSTLY_API_KEY"] = "INSERT_YOUR_API_KEY"
|
|
73
|
+
os.environ["MOSTLY_BASE_URL"] = "https://app.mostly.ai"
|
|
82
74
|
mostly = MostlyAI()
|
|
83
75
|
mostly
|
|
84
76
|
# MostlyAI(base_url='https://app.mostly.ai', api_key='***')
|
|
85
77
|
```
|
|
86
78
|
|
|
79
|
+
Example for instantiating the SDK in LOCAL mode, and connect via Unix Domain Socket (UDS):
|
|
80
|
+
```python
|
|
81
|
+
from mostlyai.sdk import MostlyAI
|
|
82
|
+
mostly = MostlyAI(local=True)
|
|
83
|
+
mostly
|
|
84
|
+
# MostlyAI(local=True)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Example for instantiating the SDK in LOCAL mode, and connect via Transmission Control Protocol (TCP):
|
|
88
|
+
```python
|
|
89
|
+
from mostlyai.sdk import MostlyAI
|
|
90
|
+
mostly = MostlyAI(local=True, local_port=8080)
|
|
91
|
+
mostly
|
|
92
|
+
# MostlyAI(local=True, local_port=8080)
|
|
93
|
+
```
|
|
94
|
+
|
|
87
95
|
Args:
|
|
88
96
|
base_url: The base URL. If not provided, a default value is used.
|
|
89
97
|
api_key: The API key for authenticating. If not provided, it would rely on environment variables.
|
|
90
98
|
local: Whether to run in local mode or not.
|
|
91
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.
|
|
92
101
|
timeout: Timeout for HTTPS requests in seconds.
|
|
93
102
|
ssl_verify: Whether to verify SSL certificates.
|
|
94
103
|
quiet: Whether to suppress rich output.
|
|
@@ -98,8 +107,9 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
98
107
|
self,
|
|
99
108
|
base_url: str | None = None,
|
|
100
109
|
api_key: str | None = None,
|
|
101
|
-
local: bool =
|
|
110
|
+
local: bool | None = None,
|
|
102
111
|
local_dir: str | Path | None = None,
|
|
112
|
+
local_port: int | None = None,
|
|
103
113
|
timeout: float = 60.0,
|
|
104
114
|
ssl_verify: bool = True,
|
|
105
115
|
quiet: bool = False,
|
|
@@ -109,11 +119,18 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
109
119
|
# suppress deprecation warnings, also those stemming from external libs
|
|
110
120
|
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
111
121
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
# determine SDK mode: either CLIENT or LOCAL mode
|
|
123
|
+
mode: Literal["CLIENT", "LOCAL", None] = None
|
|
124
|
+
if base_url is not None or api_key is not None:
|
|
125
|
+
mode = "CLIENT"
|
|
126
|
+
elif local is not None:
|
|
127
|
+
mode = "LOCAL" if bool(local) else "CLIENT"
|
|
128
|
+
elif os.getenv("MOSTLY_LOCAL"):
|
|
129
|
+
mode = "LOCAL" if os.getenv("MOSTLY_LOCAL").lower()[:1] in ["1", "t", "y"] else "CLIENT"
|
|
130
|
+
elif os.getenv("MOSTLY_API_KEY"):
|
|
131
|
+
mode = "CLIENT"
|
|
132
|
+
else:
|
|
133
|
+
# prompt for CLIENT or LOCAL setup, if not yet determined
|
|
117
134
|
choice = Prompt.ask(
|
|
118
135
|
"Select your desired SDK mode:\n\n"
|
|
119
136
|
"1) Run in [bold]CLIENT mode[/bold] 📡, connecting to a remote MOSTLY AI platform\n\n"
|
|
@@ -123,6 +140,8 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
123
140
|
default="1",
|
|
124
141
|
)
|
|
125
142
|
if choice == "1":
|
|
143
|
+
mode = "CLIENT"
|
|
144
|
+
base_url = os.getenv("MOSTLY_BASE_URL", DEFAULT_BASE_URL).rstrip("/")
|
|
126
145
|
base_url = Prompt.ask("Enter the [bold]Base URL[/bold] 🌐 of the MOSTLY AI platform", default=base_url)
|
|
127
146
|
api_key_url = f"{base_url}/settings/api-keys"
|
|
128
147
|
api_key = Prompt.ask(
|
|
@@ -131,31 +150,36 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
131
150
|
password=True,
|
|
132
151
|
)
|
|
133
152
|
rich.print(
|
|
134
|
-
"[dim][bold]Note[/bold]:
|
|
153
|
+
"[dim][bold]Note[/bold]: To skip this prompt in the future, instantiate via [bold]MostlyAI(base_url=..., api_key=...)[/bold].\n\n"
|
|
135
154
|
"Alternatively set [bold]MOSTLY_BASE_URL[/bold] and [bold]MOSTLY_API_KEY[/bold] as environment variables.[/dim]"
|
|
136
155
|
)
|
|
137
156
|
else:
|
|
138
|
-
|
|
157
|
+
mode = "LOCAL"
|
|
139
158
|
rich.print(
|
|
140
|
-
"[dim][bold]Note[/bold]:
|
|
159
|
+
"[dim][bold]Note[/bold]: To skip this prompt in the future, instantiate via [bold]MostlyAI(local=True)[/bold].\n\n"
|
|
160
|
+
"Alternatively set [bold]MOSTLY_LOCAL=1[/bold] as an environment variable.[/dim]"
|
|
141
161
|
)
|
|
142
162
|
|
|
143
|
-
if
|
|
144
|
-
rich.get_console().quiet = True
|
|
145
|
-
if local:
|
|
163
|
+
if mode == "LOCAL":
|
|
146
164
|
check_local_mode_available()
|
|
147
165
|
from mostlyai.sdk._local.server import LocalServer # noqa
|
|
148
166
|
|
|
149
|
-
self.
|
|
150
|
-
home_dir = self.
|
|
151
|
-
base_url = self.
|
|
167
|
+
self.local_server = LocalServer(home_dir=local_dir, port=local_port)
|
|
168
|
+
home_dir = self.local_server.home_dir
|
|
169
|
+
base_url = self.local_server.base_url
|
|
152
170
|
api_key = "local"
|
|
153
|
-
uds = self.
|
|
154
|
-
|
|
171
|
+
uds = self.local_server.uds
|
|
172
|
+
elif mode == "CLIENT":
|
|
173
|
+
if base_url is None:
|
|
174
|
+
base_url = os.getenv("MOSTLY_BASE_URL", DEFAULT_BASE_URL).rstrip("/")
|
|
155
175
|
validate_base_url(base_url)
|
|
176
|
+
if api_key is None:
|
|
177
|
+
api_key = os.getenv("MOSTLY_API_KEY")
|
|
156
178
|
validate_api_key(api_key)
|
|
157
179
|
home_dir = None
|
|
158
180
|
uds = None
|
|
181
|
+
else:
|
|
182
|
+
raise ValueError("Invalid SDK mode")
|
|
159
183
|
|
|
160
184
|
client_kwargs = {
|
|
161
185
|
"base_url": base_url,
|
|
@@ -169,9 +193,12 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
169
193
|
self.generators = _MostlyGeneratorsClient(**client_kwargs)
|
|
170
194
|
self.synthetic_datasets = _MostlySyntheticDatasetsClient(**client_kwargs)
|
|
171
195
|
self.synthetic_probes = _MostlySyntheticProbesClient(**client_kwargs)
|
|
172
|
-
if
|
|
196
|
+
if mode == "LOCAL":
|
|
173
197
|
rich.print(f"Initializing [bold]Synthetic Data SDK[/bold] {sdk.__version__} in [bold]LOCAL mode[/bold] 🏠")
|
|
174
|
-
|
|
198
|
+
if self.local_server.uds:
|
|
199
|
+
msg = f"Connected to [link=file://{home_dir} dodger_blue2 underline]{home_dir}[/]"
|
|
200
|
+
else:
|
|
201
|
+
msg = f"Connected to [link={self.base_url} dodger_blue2 underline]{self.base_url}[/]"
|
|
175
202
|
import torch # noqa
|
|
176
203
|
import psutil # noqa
|
|
177
204
|
|
|
@@ -183,26 +210,28 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
183
210
|
msg += ", 0 GPUs"
|
|
184
211
|
msg += " available"
|
|
185
212
|
rich.print(msg)
|
|
186
|
-
|
|
213
|
+
elif mode == "CLIENT":
|
|
187
214
|
rich.print(f"Initializing [bold]Synthetic Data SDK[/bold] {sdk.__version__} in [bold]CLIENT mode[/bold] 📡")
|
|
188
215
|
try:
|
|
189
216
|
server_version = self.about().version
|
|
190
217
|
email = self.me().email
|
|
191
|
-
msg =
|
|
192
|
-
|
|
193
|
-
f" {server_version}"
|
|
194
|
-
f" as [bold]{email}[/bold]"
|
|
195
|
-
)
|
|
218
|
+
msg = f"Connected to [link={self.base_url} dodger_blue2 underline]{self.base_url}[/] {server_version}"
|
|
219
|
+
msg += f" as [bold]{email}[/bold]" if email else ""
|
|
196
220
|
rich.print(msg)
|
|
197
221
|
except Exception as e:
|
|
198
222
|
rich.print(f"Failed to connect to {self.base_url}: {e}.")
|
|
223
|
+
else:
|
|
224
|
+
raise ValueError("Invalid SDK mode")
|
|
225
|
+
|
|
226
|
+
if quiet:
|
|
227
|
+
rich.get_console().quiet = True
|
|
199
228
|
|
|
200
229
|
def __repr__(self) -> str:
|
|
201
230
|
if self.local:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
231
|
+
if self.local_server.uds:
|
|
232
|
+
return "MostlyAI(local=True)"
|
|
233
|
+
return f"MostlyAI(local=True, local_port={self.local_server.port})"
|
|
234
|
+
return f"MostlyAI(base_url='{self.base_url}', api_key=***)"
|
|
206
235
|
|
|
207
236
|
def connect(
|
|
208
237
|
self,
|
|
@@ -69,7 +69,7 @@ class _MostlyBaseClient:
|
|
|
69
69
|
):
|
|
70
70
|
self.base_url = (base_url or os.getenv("MOSTLY_BASE_URL") or DEFAULT_BASE_URL).rstrip("/")
|
|
71
71
|
self.api_key = api_key or os.getenv("MOSTLY_API_KEY")
|
|
72
|
-
self.local =
|
|
72
|
+
self.local = self.api_key == "local"
|
|
73
73
|
self.transport = httpx.HTTPTransport(uds=uds) if uds else None
|
|
74
74
|
self.timeout = timeout
|
|
75
75
|
self.ssl_verify = ssl_verify
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
# generated by datamodel-codegen:
|
|
16
|
-
# timestamp: 2025-02-
|
|
16
|
+
# timestamp: 2025-02-27T10:11:09+00:00
|
|
17
17
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
@@ -2171,11 +2171,12 @@ class SourceTableConfig(CustomBaseModel):
|
|
|
2171
2171
|
@classmethod
|
|
2172
2172
|
def add_model_configuration(cls, values):
|
|
2173
2173
|
# Check if the table has a tabular and/or a language model
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2174
|
+
columns = values.columns or []
|
|
2175
|
+
keys = [fk.column for fk in values.foreign_keys or []]
|
|
2176
|
+
if values.primary_key:
|
|
2177
|
+
keys.append(values.primary_key)
|
|
2178
|
+
model_columns = [c for c in columns if c.name not in keys]
|
|
2179
|
+
if model_columns:
|
|
2179
2180
|
enc_types = [c.model_encoding_type or ModelEncodingType.auto for c in model_columns]
|
|
2180
2181
|
has_tabular_model = any(not enc_type.startswith(ModelType.language) for enc_type in enc_types)
|
|
2181
2182
|
has_language_model = any(enc_type.startswith(ModelType.language) for enc_type in enc_types)
|
|
@@ -2246,6 +2247,15 @@ class SourceTableConfig(CustomBaseModel):
|
|
|
2246
2247
|
raise ValueError(f"Foreign key column '{fk.column}' does not exist in the table's columns.")
|
|
2247
2248
|
return values
|
|
2248
2249
|
|
|
2250
|
+
@model_validator(mode="after")
|
|
2251
|
+
@classmethod
|
|
2252
|
+
def validate_pk_and_fks_are_not_overlapping(cls, values):
|
|
2253
|
+
primary_key = values.primary_key
|
|
2254
|
+
foreign_keys = [fk.column for fk in values.foreign_keys or []]
|
|
2255
|
+
if primary_key is not None and primary_key in foreign_keys:
|
|
2256
|
+
raise ValueError(f"Column '{primary_key}' is both a primary key and a foreign key.")
|
|
2257
|
+
return values
|
|
2258
|
+
|
|
2249
2259
|
|
|
2250
2260
|
class SourceTablePatchConfig(CustomBaseModel):
|
|
2251
2261
|
"""
|
|
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.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_analyze_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.2.5 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_encode_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.2.5 → mostlyai-4.2.7}/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
|