mostlyai 4.2.6__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.
Files changed (84) hide show
  1. {mostlyai-4.2.6 → mostlyai-4.2.7}/PKG-INFO +76 -69
  2. {mostlyai-4.2.6 → mostlyai-4.2.7}/README.md +75 -68
  3. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/__init__.py +1 -1
  4. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/routes.py +5 -1
  5. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/server.py +22 -4
  6. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/client/_base_utils.py +6 -0
  7. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/client/_utils.py +1 -1
  8. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/client/api.py +37 -27
  9. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/client/base.py +1 -1
  10. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/domain.py +16 -6
  11. {mostlyai-4.2.6 → mostlyai-4.2.7}/pyproject.toml +1 -1
  12. {mostlyai-4.2.6 → mostlyai-4.2.7}/.gitignore +0 -0
  13. {mostlyai-4.2.6 → mostlyai-4.2.7}/LICENSE +0 -0
  14. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/__init__.py +0 -0
  15. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/auto_detect.py +0 -0
  16. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/base.py +0 -0
  17. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/context.py +0 -0
  18. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/conversions.py +0 -0
  19. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/__init__.py +0 -0
  20. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/base.py +0 -0
  21. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/bigquery.py +0 -0
  22. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/databricks.py +0 -0
  23. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/hive.py +0 -0
  24. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/mssql.py +0 -0
  25. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/mysql.py +0 -0
  26. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/oracle.py +0 -0
  27. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/postgresql.py +0 -0
  28. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/snowflake.py +0 -0
  29. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/sqlite.py +0 -0
  30. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
  31. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/dtype.py +0 -0
  32. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/exceptions.py +0 -0
  33. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/__init__.py +0 -0
  34. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/base.py +0 -0
  35. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
  36. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/aws.py +0 -0
  37. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/azure.py +0 -0
  38. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
  39. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
  40. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/container/minio.py +0 -0
  41. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
  42. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/table/csv.py +0 -0
  43. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/table/feather.py +0 -0
  44. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/table/json.py +0 -0
  45. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
  46. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/file/utils.py +0 -0
  47. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/language_model.py +0 -0
  48. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/metadata_objects.py +0 -0
  49. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/non_context.py +0 -0
  50. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/progress_callback.py +0 -0
  51. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/pull.py +0 -0
  52. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/pull_context.py +0 -0
  53. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/pull_utils.py +0 -0
  54. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/push.py +0 -0
  55. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/util/__init__.py +0 -0
  56. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/util/common.py +0 -0
  57. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_data/util/kerberos.py +0 -0
  58. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/__init__.py +0 -0
  59. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/cli.py +0 -0
  60. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/connectors.py +0 -0
  61. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/__init__.py +0 -0
  62. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/jobs.py +0 -0
  63. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/plan.py +0 -0
  64. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
  65. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
  66. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
  67. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
  68. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
  69. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
  70. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
  71. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
  72. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
  73. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
  74. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
  75. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/generators.py +0 -0
  76. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/progress.py +0 -0
  77. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/storage.py +0 -0
  78. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
  79. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/client/__init__.py +0 -0
  80. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/client/_naming_conventions.py +0 -0
  81. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/client/connectors.py +0 -0
  82. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/client/exceptions.py +0 -0
  83. {mostlyai-4.2.6 → mostlyai-4.2.7}/mostlyai/sdk/client/generators.py +0 -0
  84. {mostlyai-4.2.6 → 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.6
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
- [![Documentation](https://img.shields.io/badge/docs-latest-green)](https://mostly-ai.github.io/mostlyai/)
129
- [![PyPI Downloads](https://static.pepy.tech/badge/mostlyai)](https://pepy.tech/projects/mostlyai)
130
- [![License](https://img.shields.io/github/license/mostly-ai/mostlyai)](https://github.com/mostly-ai/mostlyai/blob/main/LICENSE)
131
- [![GitHub Release](https://img.shields.io/github/v/release/mostly-ai/mostlyai)](https://github.com/mostly-ai/mostlyai/releases)
132
- [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mostlyai)](https://pypi.org/project/mostlyai/)
127
+ [![GitHub Release](https://img.shields.io/github/v/release/mostly-ai/mostlyai)](https://github.com/mostly-ai/mostlyai/releases)
128
+ [![Documentation](https://img.shields.io/badge/docs-latest-green)](https://mostly-ai.github.io/mostlyai/)
129
+ [![PyPI Downloads](https://static.pepy.tech/badge/mostlyai)](https://pepy.tech/projects/mostlyai)
130
+ [![License](https://img.shields.io/github/license/mostly-ai/mostlyai)](https://github.com/mostly-ai/mostlyai/blob/main/LICENSE)
131
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mostlyai)](https://pypi.org/project/mostlyai/)
133
132
  [![GitHub stars](https://img.shields.io/github/stars/mostly-ai/mostlyai?style=social)](https://github.com/mostly-ai/mostlyai/stargazers)
134
133
 
135
- [SDK Documentation](https://mostly-ai.github.io/mostlyai/) | [Platform Documentation](https://mostly.ai/docs) | [Usage Examples](https://mostly-ai.github.io/mostlyai/usage/)
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
- **CLIENT + LOCAL mode**
159
+ ## Key Features
169
160
 
170
- ```shell
171
- # for CPU on macOS
172
- pip install -U 'mostlyai[local]'
173
- # for CPU on Linux
174
- #pip install -U mostlyai[local-cpu] --extra-index-url https://download.pytorch.org/whl/cpu
175
- # for GPU on Linux
176
- #pip install -U mostlyai[local-gpu]
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
- **Optional Connectors**
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
- Add any of the following extras for further data connectors support: `databricks`, `googlebigquery`, `hive`, `mssql`, `mysql`, `oracle`, `postgres`, `snowflake`.
188
+ Install the SDK via pip:
182
189
 
183
- E.g.
184
190
  ```shell
185
- pip install -U 'mostlyai[local, databricks, snowflake]'
191
+ pip install mostlyai
186
192
  ```
187
193
 
188
- ## 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>
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 in local or client mode
201
- mostly = MostlyAI(local=True) # local mode
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, # - limit training time (in minutes)
214
- # model, max_epochs,,.. # further model configurations (optional)
215
- # 'differential_privacy': { # differential privacy configuration (optional)
216
- # 'max_epsilon': 5.0, # - max epsilon value, used as stopping criterion
217
- # 'delta': 1e-5, # - delta value
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,.. # further table configurations (optional)
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, you can use it to generate synthetic data samples. Either via probing:
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
- ## Key Features
265
+ ## Installation
263
266
 
264
- - **Broad Data Support**
265
- - Mixed-type data (categorical, numerical, geospatial, text, etc.)
266
- - Single-table, multi-table, and time-series
267
- - **Multiple Model Types**
268
- - TabularARGN for SOTA tabular performance
269
- - Fine-tune HuggingFace-based language models
270
- - Efficient LSTM for text synthesis from scratch
271
- - **Advanced Training Options**
272
- - GPU/CPU support
273
- - Differential Privacy
274
- - Progress Monitoring
275
- - **Automated Quality Assurance**
276
- - Quality metrics for fidelity and privacy
277
- - In-depth HTML reports for visual analysis
278
- - **Flexible Sampling**
279
- - Up-sample to any data volumes
280
- - Conditional generation by any columns
281
- - Re-balance underrepresented segments
282
- - Context-aware data imputation
283
- - Statistical fairness controls
284
- - Rule-adherence via temperature
285
- - **Seamless Integration**
286
- - Connect to external data sources (DBs, cloud storages)
287
- - Fully permissive open-source license
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
- [![Documentation](https://img.shields.io/badge/docs-latest-green)](https://mostly-ai.github.io/mostlyai/)
5
- [![PyPI Downloads](https://static.pepy.tech/badge/mostlyai)](https://pepy.tech/projects/mostlyai)
6
- [![License](https://img.shields.io/github/license/mostly-ai/mostlyai)](https://github.com/mostly-ai/mostlyai/blob/main/LICENSE)
7
- [![GitHub Release](https://img.shields.io/github/v/release/mostly-ai/mostlyai)](https://github.com/mostly-ai/mostlyai/releases)
8
- [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mostlyai)](https://pypi.org/project/mostlyai/)
3
+ [![GitHub Release](https://img.shields.io/github/v/release/mostly-ai/mostlyai)](https://github.com/mostly-ai/mostlyai/releases)
4
+ [![Documentation](https://img.shields.io/badge/docs-latest-green)](https://mostly-ai.github.io/mostlyai/)
5
+ [![PyPI Downloads](https://static.pepy.tech/badge/mostlyai)](https://pepy.tech/projects/mostlyai)
6
+ [![License](https://img.shields.io/github/license/mostly-ai/mostlyai)](https://github.com/mostly-ai/mostlyai/blob/main/LICENSE)
7
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mostlyai)](https://pypi.org/project/mostlyai/)
9
8
  [![GitHub stars](https://img.shields.io/github/stars/mostly-ai/mostlyai?style=social)](https://github.com/mostly-ai/mostlyai/stargazers)
10
9
 
11
- [SDK Documentation](https://mostly-ai.github.io/mostlyai/) | [Platform Documentation](https://mostly.ai/docs) | [Usage Examples](https://mostly-ai.github.io/mostlyai/usage/)
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
- **CLIENT + LOCAL mode**
35
+ ## Key Features
45
36
 
46
- ```shell
47
- # for CPU on macOS
48
- pip install -U 'mostlyai[local]'
49
- # for CPU on Linux
50
- #pip install -U mostlyai[local-cpu] --extra-index-url https://download.pytorch.org/whl/cpu
51
- # for GPU on Linux
52
- #pip install -U mostlyai[local-gpu]
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
- **Optional Connectors**
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
- Add any of the following extras for further data connectors support: `databricks`, `googlebigquery`, `hive`, `mssql`, `mysql`, `oracle`, `postgres`, `snowflake`.
64
+ Install the SDK via pip:
58
65
 
59
- E.g.
60
66
  ```shell
61
- pip install -U 'mostlyai[local, databricks, snowflake]'
67
+ pip install mostlyai
62
68
  ```
63
69
 
64
- ## 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>
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 in local or client mode
77
- mostly = MostlyAI(local=True) # local mode
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, # - limit training time (in minutes)
90
- # model, max_epochs,,.. # further model configurations (optional)
91
- # 'differential_privacy': { # differential privacy configuration (optional)
92
- # 'max_epsilon': 5.0, # - max epsilon value, used as stopping criterion
93
- # 'delta': 1e-5, # - delta value
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,.. # further table configurations (optional)
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, you can use it to generate synthetic data samples. Either via probing:
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
- ## Key Features
141
+ ## Installation
139
142
 
140
- - **Broad Data Support**
141
- - Mixed-type data (categorical, numerical, geospatial, text, etc.)
142
- - Single-table, multi-table, and time-series
143
- - **Multiple Model Types**
144
- - TabularARGN for SOTA tabular performance
145
- - Fine-tune HuggingFace-based language models
146
- - Efficient LSTM for text synthesis from scratch
147
- - **Advanced Training Options**
148
- - GPU/CPU support
149
- - Differential Privacy
150
- - Progress Monitoring
151
- - **Automated Quality Assurance**
152
- - Quality metrics for fidelity and privacy
153
- - In-depth HTML reports for visual analysis
154
- - **Flexible Sampling**
155
- - Up-sample to any data volumes
156
- - Conditional generation by any columns
157
- - Re-balance underrepresented segments
158
- - Context-aware data imputation
159
- - Statistical fairness controls
160
- - Rule-adherence via temperature
161
- - **Seamless Integration**
162
- - Connect to external data sources (DBs, cloud storages)
163
- - Fully permissive open-source license
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
 
@@ -15,4 +15,4 @@
15
15
  from mostlyai.sdk.client.api import MostlyAI
16
16
 
17
17
  __all__ = ["MostlyAI"]
18
- __version__ = "4.2.6" # Do not set this manually. Use poetry version [params].
18
+ __version__ = "4.2.7" # Do not set this manually. Use poetry version [params].
@@ -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,17 +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
46
  # check read/write access to `home_dir`
38
47
  if not os.access(self.home_dir, os.R_OK) or not os.access(self.home_dir, os.W_OK):
39
48
  raise PermissionError(f"Cannot read/write to {self.home_dir}")
40
- self.uds = tempfile.NamedTemporaryFile(prefix=".mostlyai-", suffix=".sock", delete=False).name
41
- self.base_url = "http://127.0.0.1"
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 "")
42
58
  self._app = FastAPI(
43
59
  root_path="/api/v2",
44
60
  title="Synthetic Data SDK ✨",
@@ -55,12 +71,14 @@ class LocalServer:
55
71
  self.start() # Automatically start the server during initialization
56
72
 
57
73
  def _clear_socket_file(self):
58
- if os.path.exists(self.uds):
74
+ if self.uds and os.path.exists(self.uds):
59
75
  os.remove(self.uds)
60
76
 
61
77
  def _create_server(self):
62
78
  self._clear_socket_file()
63
- config = uvicorn.Config(self._app, uds=self.uds, log_level="error", reload=False)
79
+ config = uvicorn.Config(
80
+ self._app, host=self.host, port=self.port, uds=self.uds, log_level="error", reload=False
81
+ )
64
82
  self._server = uvicorn.Server(config)
65
83
 
66
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()
@@ -183,7 +183,7 @@ def job_wait(
183
183
  -1,
184
184
  )
185
185
  training_log = Table(
186
- title=f"Latest training log for `{step.model_label}`",
186
+ title=f"Training log for `{step.model_label}`",
187
187
  box=box.SIMPLE_HEAD,
188
188
  expand=True,
189
189
  header_style="none",
@@ -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 client or in local mode.
55
+ Instantiate an SDK instance, either in CLIENT or in LOCAL mode.
56
56
 
57
- Example for instantiating the SDK in local mode:
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["MOSTLYAI_API_KEY"] = "INSERT_YOUR_API_KEY"
81
- os.environ["MOSTLYAI_BASE_URL"] = "https://app.mostly.ai"
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.
@@ -100,6 +109,7 @@ class MostlyAI(_MostlyBaseClient):
100
109
  api_key: str | None = None,
101
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,
@@ -154,11 +164,11 @@ class MostlyAI(_MostlyBaseClient):
154
164
  check_local_mode_available()
155
165
  from mostlyai.sdk._local.server import LocalServer # noqa
156
166
 
157
- self.local = LocalServer(home_dir=local_dir)
158
- home_dir = self.local.home_dir
159
- base_url = self.local.base_url
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
160
170
  api_key = "local"
161
- uds = self.local.uds
171
+ uds = self.local_server.uds
162
172
  elif mode == "CLIENT":
163
173
  if base_url is None:
164
174
  base_url = os.getenv("MOSTLY_BASE_URL", DEFAULT_BASE_URL).rstrip("/")
@@ -185,7 +195,10 @@ class MostlyAI(_MostlyBaseClient):
185
195
  self.synthetic_probes = _MostlySyntheticProbesClient(**client_kwargs)
186
196
  if mode == "LOCAL":
187
197
  rich.print(f"Initializing [bold]Synthetic Data SDK[/bold] {sdk.__version__} in [bold]LOCAL mode[/bold] 🏠")
188
- msg = f"Connected to [link=file://{home_dir} dodger_blue2 underline]{home_dir}[/]"
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}[/]"
189
202
  import torch # noqa
190
203
  import psutil # noqa
191
204
 
@@ -202,11 +215,8 @@ class MostlyAI(_MostlyBaseClient):
202
215
  try:
203
216
  server_version = self.about().version
204
217
  email = self.me().email
205
- msg = (
206
- f"Connected to [link={self.base_url} dodger_blue2 underline]{self.base_url}[/]"
207
- f" {server_version}"
208
- f" as [bold]{email}[/bold]"
209
- )
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 ""
210
220
  rich.print(msg)
211
221
  except Exception as e:
212
222
  rich.print(f"Failed to connect to {self.base_url}: {e}.")
@@ -218,10 +228,10 @@ class MostlyAI(_MostlyBaseClient):
218
228
 
219
229
  def __repr__(self) -> str:
220
230
  if self.local:
221
- return "MostlyAI(local=True)"
222
- else:
223
- api_key = "'***'" if self.api_key else "None"
224
- return f"MostlyAI(base_url='{self.base_url}', api_key={api_key})"
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=***)"
225
235
 
226
236
  def connect(
227
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 = uds is not None
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-19T14:55:11+00:00
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
- if values.columns:
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 values.columns if c.name not in keys]
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
  """
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mostlyai"
3
- version = "4.2.6"
3
+ version = "4.2.7"
4
4
  description = "Synthetic Data SDK"
5
5
  authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
6
6
  requires-python = ">=3.10,<3.14"
File without changes
File without changes