mostlyai 4.2.6__tar.gz → 4.2.8__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.8}/PKG-INFO +76 -69
  2. {mostlyai-4.2.6 → mostlyai-4.2.8}/README.md +75 -68
  3. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/__init__.py +1 -1
  4. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/plan.py +3 -4
  5. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/routes.py +5 -1
  6. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/server.py +22 -4
  7. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/client/_base_utils.py +6 -0
  8. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/client/_utils.py +1 -1
  9. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/client/api.py +37 -27
  10. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/client/base.py +1 -1
  11. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/domain.py +89 -59
  12. {mostlyai-4.2.6 → mostlyai-4.2.8}/pyproject.toml +1 -1
  13. {mostlyai-4.2.6 → mostlyai-4.2.8}/.gitignore +0 -0
  14. {mostlyai-4.2.6 → mostlyai-4.2.8}/LICENSE +0 -0
  15. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/__init__.py +0 -0
  16. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/auto_detect.py +0 -0
  17. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/base.py +0 -0
  18. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/context.py +0 -0
  19. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/conversions.py +0 -0
  20. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/__init__.py +0 -0
  21. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/base.py +0 -0
  22. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/bigquery.py +0 -0
  23. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/databricks.py +0 -0
  24. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/hive.py +0 -0
  25. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/mssql.py +0 -0
  26. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/mysql.py +0 -0
  27. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/oracle.py +0 -0
  28. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/postgresql.py +0 -0
  29. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/snowflake.py +0 -0
  30. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/sqlite.py +0 -0
  31. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
  32. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/dtype.py +0 -0
  33. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/exceptions.py +0 -0
  34. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/__init__.py +0 -0
  35. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/base.py +0 -0
  36. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
  37. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/container/aws.py +0 -0
  38. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/container/azure.py +0 -0
  39. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
  40. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
  41. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/container/minio.py +0 -0
  42. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
  43. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/table/csv.py +0 -0
  44. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/table/feather.py +0 -0
  45. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/table/json.py +0 -0
  46. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
  47. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/file/utils.py +0 -0
  48. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/language_model.py +0 -0
  49. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/metadata_objects.py +0 -0
  50. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/non_context.py +0 -0
  51. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/progress_callback.py +0 -0
  52. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/pull.py +0 -0
  53. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/pull_context.py +0 -0
  54. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/pull_utils.py +0 -0
  55. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/push.py +0 -0
  56. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/util/__init__.py +0 -0
  57. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/util/common.py +0 -0
  58. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_data/util/kerberos.py +0 -0
  59. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/__init__.py +0 -0
  60. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/cli.py +0 -0
  61. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/connectors.py +0 -0
  62. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/__init__.py +0 -0
  63. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/jobs.py +0 -0
  64. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
  65. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
  66. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
  67. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
  68. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
  69. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
  70. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
  71. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
  72. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
  73. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
  74. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
  75. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/generators.py +0 -0
  76. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/progress.py +0 -0
  77. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/storage.py +0 -0
  78. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
  79. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/client/__init__.py +0 -0
  80. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/client/_naming_conventions.py +0 -0
  81. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/client/connectors.py +0 -0
  82. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/client/exceptions.py +0 -0
  83. {mostlyai-4.2.6 → mostlyai-4.2.8}/mostlyai/sdk/client/generators.py +0 -0
  84. {mostlyai-4.2.6 → mostlyai-4.2.8}/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.8
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.8" # Do not set this manually. Use poetry version [params].
@@ -151,9 +151,9 @@ def make_synthetic_dataset_execution_plan(generator: Generator, is_probe: bool =
151
151
  )
152
152
 
153
153
  # Traverse child tables in tree level order traversal
154
- queue = deque([(root_table.name, generate_task)])
154
+ queue = deque([root_table.name])
155
155
  while queue:
156
- current_table_name, parent_task = queue.popleft()
156
+ current_table_name = queue.popleft()
157
157
 
158
158
  # Find child tables
159
159
  child_tables = sorted(
@@ -162,7 +162,6 @@ def make_synthetic_dataset_execution_plan(generator: Generator, is_probe: bool =
162
162
  )
163
163
  # Process each child table
164
164
  for child_table in child_tables:
165
- generate_task = parent_task
166
165
  if has_tabular_model(child_table):
167
166
  generate_task = execution_plan.add_task(
168
167
  generate_tabular_task_type, parent=generate_task, target_table_name=child_table.name
@@ -172,7 +171,7 @@ def make_synthetic_dataset_execution_plan(generator: Generator, is_probe: bool =
172
171
  generate_language_task_type, parent=generate_task, target_table_name=child_table.name
173
172
  )
174
173
 
175
- queue.append((child_table.name, generate_task))
174
+ queue.append(child_table.name)
176
175
 
177
176
  post_generation_sync_task = execution_plan.add_task(TaskType.sync)
178
177
  finalize_task = execution_plan.add_task(finalize_task_type, parent=post_generation_sync_task)
@@ -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-28T14:40:37+00:00
17
17
 
18
18
  from __future__ import annotations
19
19
 
@@ -55,6 +55,10 @@ class PermissionLevel(str, Enum):
55
55
 
56
56
 
57
57
  class UserSettingsProfileUpdateConfig(CustomBaseModel):
58
+ name: str | None = Field(
59
+ None,
60
+ description="The name of a user.\nContains only alphanumeric characters, hyphens, and underscores. Must start or end with alphanumeric.\nIt must be globally case-insensitive unique considering organizations and users.\n",
61
+ )
58
62
  first_name: str | None = Field(None, alias="firstName", description="First name of a user", max_length=30)
59
63
  last_name: str | None = Field(None, alias="lastName", description="Last name of a user", max_length=30)
60
64
  avatar: str | None = Field(None, description="The base64-encoded image of the user's avatar")
@@ -837,22 +841,6 @@ class ComputePatchConfig(CustomBaseModel):
837
841
  )
838
842
 
839
843
 
840
- class OrganizationListItem(CustomBaseModel):
841
- """
842
- Essential organization details for listings.
843
- """
844
-
845
- id: str = Field(..., description="The unique identifier of an organization.")
846
- name: str | None = Field(
847
- None,
848
- description="The name of an organization.\nContains only alphanumeric characters, hyphens, and underscores. Must start or end with alphanumeric.\nIt must be globally case-insensitive unique.\n",
849
- max_length=64,
850
- )
851
- display_name: str = Field(..., alias="displayName", description="The display name of an organization.")
852
- description: str | None = Field(None, description="The description of an organization. Supports markdown.")
853
- logo: str | None = Field(None, description="The URL of the organization's logo.")
854
-
855
-
856
844
  class MemberRole(str, Enum):
857
845
  """
858
846
  The role of the user in the organization
@@ -1316,22 +1304,6 @@ class Distances(CustomBaseModel):
1316
1304
  )
1317
1305
 
1318
1306
 
1319
- class User(CustomBaseModel):
1320
- """
1321
- A user of the service.
1322
- """
1323
-
1324
- id: str | None = Field(None, description="The unique identifier of a user.")
1325
- name: str | None = Field(
1326
- None,
1327
- description="The name of a user. As of now, it is the concatenation of the first name and last name.",
1328
- )
1329
- first_name: str | None = Field(None, alias="firstName", description="First name of a user", max_length=30)
1330
- last_name: str | None = Field(None, alias="lastName", description="Last name of a user", max_length=30)
1331
- email: str | None = Field(None, description="The email of a user")
1332
- avatar: str | None = Field(None, description="The URL of the user's avatar")
1333
-
1334
-
1335
1307
  class UserListItem(CustomBaseModel):
1336
1308
  """
1337
1309
  Essential information about a user for public listings.
@@ -1340,29 +1312,11 @@ class UserListItem(CustomBaseModel):
1340
1312
  id: str | None = Field(None, description="The unique identifier of a user.")
1341
1313
  name: str | None = Field(
1342
1314
  None,
1343
- description="The name of a user. As of now, it is the concatenation of the first name and last name.",
1315
+ description="The name of a user.\nContains only alphanumeric characters, hyphens, and underscores. Must start or end with alphanumeric.\nIt must be globally case-insensitive unique considering organizations and users.\n",
1344
1316
  )
1345
- avatar: str | None = Field(None, description="The URL of the user's avatar")
1346
-
1347
-
1348
- class CurrentUser(CustomBaseModel):
1349
- """
1350
- Information on the current user.
1351
- """
1352
-
1353
- id: str | None = Field(None, description="The unique identifier of a user.")
1354
1317
  first_name: str | None = Field(None, alias="firstName", description="First name of a user", max_length=30)
1355
1318
  last_name: str | None = Field(None, alias="lastName", description="Last name of a user", max_length=30)
1356
- email: str | None = Field(None, description="The email of a user")
1357
1319
  avatar: str | None = Field(None, description="The URL of the user's avatar")
1358
- settings: dict[str, Any] | None = None
1359
- usage: UserUsage | None = None
1360
- unread_notifications: int | None = Field(
1361
- None,
1362
- alias="unreadNotifications",
1363
- description="Number of unread notifications for the user",
1364
- )
1365
- organizations: list[OrganizationListItem] | None = Field(None, description="The organizations the user belongs to")
1366
1320
 
1367
1321
 
1368
1322
  class UserSettingsUpdateConfig(CustomBaseModel):
@@ -1421,7 +1375,7 @@ class Metadata(CustomBaseModel):
1421
1375
  creator_name: str | None = Field(
1422
1376
  None,
1423
1377
  alias="creatorName",
1424
- description="The name of a user. As of now, it is the concatenation of the first name and last name.",
1378
+ description="The name of a user.\nContains only alphanumeric characters, hyphens, and underscores. Must start or end with alphanumeric.\nIt must be globally case-insensitive unique considering organizations and users.\n",
1425
1379
  )
1426
1380
  created_at: datetime | None = Field(
1427
1381
  None,
@@ -2011,6 +1965,14 @@ class AssistantThread(CustomBaseModel):
2011
1965
  usage: AssistantThreadUsage | None = None
2012
1966
 
2013
1967
 
1968
+ class OrganizationMetadata(CustomBaseModel):
1969
+ """
1970
+ The metadata of an organization.
1971
+ """
1972
+
1973
+ current_user_member_role: MemberRole | None = Field(None, alias="currentUserMemberRole")
1974
+
1975
+
2014
1976
  class Organization(CustomBaseModel):
2015
1977
  """
2016
1978
  An organization that owns resources.
@@ -2028,6 +1990,7 @@ class Organization(CustomBaseModel):
2028
1990
  email: str | None = Field(None, description="The email address of the organization.")
2029
1991
  website: str | None = Field(None, description="The URL of the organization's website.")
2030
1992
  members: list[UserListItem] | None = None
1993
+ metadata: OrganizationMetadata | None = None
2031
1994
 
2032
1995
 
2033
1996
  class OrganizationMember(CustomBaseModel):
@@ -2035,7 +1998,7 @@ class OrganizationMember(CustomBaseModel):
2035
1998
  A member of an organization.
2036
1999
  """
2037
2000
 
2038
- user: User | None = None
2001
+ user: UserListItem | None = None
2039
2002
  role: MemberRole | None = None
2040
2003
 
2041
2004
 
@@ -2171,11 +2134,12 @@ class SourceTableConfig(CustomBaseModel):
2171
2134
  @classmethod
2172
2135
  def add_model_configuration(cls, values):
2173
2136
  # 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]
2137
+ columns = values.columns or []
2138
+ keys = [fk.column for fk in values.foreign_keys or []]
2139
+ if values.primary_key:
2140
+ keys.append(values.primary_key)
2141
+ model_columns = [c for c in columns if c.name not in keys]
2142
+ if model_columns:
2179
2143
  enc_types = [c.model_encoding_type or ModelEncodingType.auto for c in model_columns]
2180
2144
  has_tabular_model = any(not enc_type.startswith(ModelType.language) for enc_type in enc_types)
2181
2145
  has_language_model = any(enc_type.startswith(ModelType.language) for enc_type in enc_types)
@@ -2246,6 +2210,15 @@ class SourceTableConfig(CustomBaseModel):
2246
2210
  raise ValueError(f"Foreign key column '{fk.column}' does not exist in the table's columns.")
2247
2211
  return values
2248
2212
 
2213
+ @model_validator(mode="after")
2214
+ @classmethod
2215
+ def validate_pk_and_fks_are_not_overlapping(cls, values):
2216
+ primary_key = values.primary_key
2217
+ foreign_keys = [fk.column for fk in values.foreign_keys or []]
2218
+ if primary_key is not None and primary_key in foreign_keys:
2219
+ raise ValueError(f"Column '{primary_key}' is both a primary key and a foreign key.")
2220
+ return values
2221
+
2249
2222
 
2250
2223
  class SourceTablePatchConfig(CustomBaseModel):
2251
2224
  """
@@ -2405,6 +2378,63 @@ class SyntheticProbeConfig(CustomBaseModel):
2405
2378
  _SyntheticDataConfigValidation(synthetic_config=self, generator=generator)
2406
2379
 
2407
2380
 
2381
+ class OrganizationListItem(CustomBaseModel):
2382
+ """
2383
+ Essential organization details for listings.
2384
+ """
2385
+
2386
+ id: str = Field(..., description="The unique identifier of an organization.")
2387
+ name: str | None = Field(
2388
+ None,
2389
+ description="The name of an organization.\nContains only alphanumeric characters, hyphens, and underscores. Must start or end with alphanumeric.\nIt must be globally case-insensitive unique.\n",
2390
+ max_length=64,
2391
+ )
2392
+ display_name: str = Field(..., alias="displayName", description="The display name of an organization.")
2393
+ description: str | None = Field(None, description="The description of an organization. Supports markdown.")
2394
+ logo: str | None = Field(None, description="The URL of the organization's logo.")
2395
+ metadata: OrganizationMetadata | None = None
2396
+
2397
+
2398
+ class User(CustomBaseModel):
2399
+ """
2400
+ The public attributes of a user of the service.
2401
+ """
2402
+
2403
+ id: str | None = Field(None, description="The unique identifier of a user.")
2404
+ name: str | None = Field(
2405
+ None,
2406
+ description="The name of a user.\nContains only alphanumeric characters, hyphens, and underscores. Must start or end with alphanumeric.\nIt must be globally case-insensitive unique considering organizations and users.\n",
2407
+ )
2408
+ first_name: str | None = Field(None, alias="firstName", description="First name of a user", max_length=30)
2409
+ last_name: str | None = Field(None, alias="lastName", description="Last name of a user", max_length=30)
2410
+ avatar: str | None = Field(None, description="The URL of the user's avatar")
2411
+ organizations: list[OrganizationListItem] | None = Field(None, description="The organizations the user belongs to")
2412
+
2413
+
2414
+ class CurrentUser(CustomBaseModel):
2415
+ """
2416
+ Information on the current user.
2417
+ """
2418
+
2419
+ id: str | None = Field(None, description="The unique identifier of a user.")
2420
+ name: str | None = Field(
2421
+ None,
2422
+ description="The name of a user.\nContains only alphanumeric characters, hyphens, and underscores. Must start or end with alphanumeric.\nIt must be globally case-insensitive unique considering organizations and users.\n",
2423
+ )
2424
+ first_name: str | None = Field(None, alias="firstName", description="First name of a user", max_length=30)
2425
+ last_name: str | None = Field(None, alias="lastName", description="Last name of a user", max_length=30)
2426
+ email: str | None = Field(None, description="The email of a user")
2427
+ avatar: str | None = Field(None, description="The URL of the user's avatar")
2428
+ settings: dict[str, Any] | None = None
2429
+ usage: UserUsage | None = None
2430
+ unread_notifications: int | None = Field(
2431
+ None,
2432
+ alias="unreadNotifications",
2433
+ description="Number of unread notifications for the user",
2434
+ )
2435
+ organizations: list[OrganizationListItem] | None = Field(None, description="The organizations the user belongs to")
2436
+
2437
+
2408
2438
  class Generator(CustomBaseModel):
2409
2439
  """
2410
2440
  A generator is a set models that can generate synthetic data.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mostlyai"
3
- version = "4.2.6"
3
+ version = "4.2.8"
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