mostlyai 4.5.6__tar.gz → 4.6.0__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 (86) hide show
  1. {mostlyai-4.5.6 → mostlyai-4.6.0}/PKG-INFO +50 -9
  2. {mostlyai-4.5.6 → mostlyai-4.6.0}/README.md +45 -4
  3. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/__init__.py +1 -1
  4. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/pull.py +4 -2
  5. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/pull_context.py +3 -2
  6. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/pull_utils.py +20 -8
  7. mostlyai-4.6.0/mostlyai/sdk/_local/execution/migration.py +32 -0
  8. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +9 -0
  9. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -1
  10. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_encode_training_data.py +5 -0
  11. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_generate_data.py +4 -0
  12. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/routes.py +40 -29
  13. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/client/_utils.py +1 -12
  14. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/client/api.py +2 -4
  15. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/client/base.py +1 -1
  16. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/client/connectors.py +16 -4
  17. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/client/generators.py +12 -0
  18. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/client/synthetic_datasets.py +12 -0
  19. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/domain.py +50 -18
  20. {mostlyai-4.5.6 → mostlyai-4.6.0}/pyproject.toml +5 -5
  21. {mostlyai-4.5.6 → mostlyai-4.6.0}/.gitignore +0 -0
  22. {mostlyai-4.5.6 → mostlyai-4.6.0}/LICENSE +0 -0
  23. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/__init__.py +0 -0
  24. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/auto_detect.py +0 -0
  25. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/base.py +0 -0
  26. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/context.py +0 -0
  27. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/conversions.py +0 -0
  28. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/__init__.py +0 -0
  29. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/base.py +0 -0
  30. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/bigquery.py +0 -0
  31. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/databricks.py +0 -0
  32. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/hive.py +0 -0
  33. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/mssql.py +0 -0
  34. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/mysql.py +0 -0
  35. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/oracle.py +0 -0
  36. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/postgresql.py +0 -0
  37. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/snowflake.py +0 -0
  38. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/sqlite.py +0 -0
  39. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
  40. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/dtype.py +0 -0
  41. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/exceptions.py +0 -0
  42. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/__init__.py +0 -0
  43. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/base.py +0 -0
  44. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
  45. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/container/aws.py +0 -0
  46. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/container/azure.py +0 -0
  47. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
  48. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
  49. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/container/minio.py +0 -0
  50. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
  51. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/table/csv.py +0 -0
  52. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/table/feather.py +0 -0
  53. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/table/json.py +0 -0
  54. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
  55. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/file/utils.py +0 -0
  56. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/language_model.py +0 -0
  57. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/metadata_objects.py +0 -0
  58. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/non_context.py +0 -0
  59. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/progress_callback.py +0 -0
  60. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/push.py +0 -0
  61. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/util/__init__.py +0 -0
  62. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/util/common.py +0 -0
  63. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_data/util/kerberos.py +0 -0
  64. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/__init__.py +0 -0
  65. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/cli.py +0 -0
  66. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/connectors.py +0 -0
  67. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/__init__.py +0 -0
  68. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/jobs.py +0 -0
  69. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/plan.py +0 -0
  70. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
  71. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
  72. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
  73. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
  74. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
  75. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
  76. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/execution/step_train_model.py +1 -1
  77. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/generators.py +0 -0
  78. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/progress.py +0 -0
  79. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/server.py +0 -0
  80. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/storage.py +0 -0
  81. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
  82. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/client/__init__.py +0 -0
  83. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/client/_base_utils.py +0 -0
  84. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/client/_naming_conventions.py +0 -0
  85. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/client/exceptions.py +0 -0
  86. {mostlyai-4.5.6 → mostlyai-4.6.0}/mostlyai/sdk/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mostlyai
3
- Version: 4.5.6
3
+ Version: 4.6.0
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
@@ -59,8 +59,8 @@ Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local'
59
59
  Requires-Dist: filelock>=3.16.1; extra == 'local'
60
60
  Requires-Dist: gcsfs>=2023.1.0; extra == 'local'
61
61
  Requires-Dist: joblib>=1.4.2; extra == 'local'
62
- Requires-Dist: mostlyai-engine==1.3.2; extra == 'local'
63
- Requires-Dist: mostlyai-qa==1.7.0; extra == 'local'
62
+ Requires-Dist: mostlyai-engine==1.4.0; extra == 'local'
63
+ Requires-Dist: mostlyai-qa==1.9.1; extra == 'local'
64
64
  Requires-Dist: networkx<4,>=3.0; extra == 'local'
65
65
  Requires-Dist: openpyxl>=3.1.5; extra == 'local'
66
66
  Requires-Dist: python-multipart>=0.0.20; extra == 'local'
@@ -81,8 +81,8 @@ Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-gpu'
81
81
  Requires-Dist: filelock>=3.16.1; extra == 'local-gpu'
82
82
  Requires-Dist: gcsfs>=2023.1.0; extra == 'local-gpu'
83
83
  Requires-Dist: joblib>=1.4.2; extra == 'local-gpu'
84
- Requires-Dist: mostlyai-engine[gpu]==1.3.2; extra == 'local-gpu'
85
- Requires-Dist: mostlyai-qa==1.7.0; extra == 'local-gpu'
84
+ Requires-Dist: mostlyai-engine[gpu]==1.4.0; extra == 'local-gpu'
85
+ Requires-Dist: mostlyai-qa==1.9.1; extra == 'local-gpu'
86
86
  Requires-Dist: networkx<4,>=3.0; extra == 'local-gpu'
87
87
  Requires-Dist: openpyxl>=3.1.5; extra == 'local-gpu'
88
88
  Requires-Dist: python-multipart>=0.0.20; extra == 'local-gpu'
@@ -148,7 +148,7 @@ https://github.com/user-attachments/assets/9e233213-a259-455c-b8ed-d1f1548b492f
148
148
  - Single-table, multi-table, and time-series
149
149
  - **Multiple Model Types**
150
150
  - State-of-the-art performance via TabularARGN
151
- - Fine-tune HuggingFace-based language models
151
+ - Fine-tune Hugging Face hosted language models
152
152
  - Efficient LSTM for text synthesis from scratch
153
153
  - **Advanced Training Options**
154
154
  - GPU/CPU support
@@ -250,7 +250,7 @@ In either case, a modern GPU is highly recommended when working with language mo
250
250
 
251
251
  Use `pip` (or better `uv pip`) to install the official `mostlyai` package via PyPI. Python 3.10 or higher is required.
252
252
 
253
- It is highly recommended to install the package within a dedicated virtual environment using `uv`.
253
+ It is highly recommended to install the package within a dedicated virtual environment using `uv` (see [here](https://docs.astral.sh/uv/)):
254
254
 
255
255
  <details>
256
256
 
@@ -343,6 +343,47 @@ Add any of the following extras for further data connectors support in LOCAL mod
343
343
  ```shell
344
344
  uv pip install -U 'mostlyai[local, databricks, snowflake]'
345
345
  ```
346
+
347
+ ### Using Docker
348
+
349
+ As an alternative, you can also build a Docker image, which provides you with an isolated environment for running the SDK in LOCAL mode, with all connector dependencies pre-installed. This approach ensures a consistent runtime environment across all systems. Before proceeding, make sure [Docker](https://docs.docker.com/get-started/get-docker/) is installed on your system.
350
+
351
+ <details>
352
+
353
+ <summary>Build the image</summary>
354
+
355
+ If your environment is capable of executing Makefile (see [here](https://github.com/mostly-ai/mostlyai/blob/main/Makefile#L47-L73)), then execute `make docker-build`.
356
+
357
+ Otherwise, use `DOCKER_BUILDKIT=1 docker build . --platform=linux/amd64 -t mostlyai/mostlyai` instead.
358
+
359
+ </details>
360
+
361
+ <details>
362
+
363
+ <summary>Start the container</summary>
364
+
365
+ This will launch the SDK in LOCAL mode on port 8080 inside the container.
366
+
367
+ If your environment is capable of executing Makefile, then execute `make docker-run`. Or `make docker-run HOST_PORT=8080` to forward to a host port of your choice. One could also mount the `local_dir` via `make docker-run HOST_LOCAL_DIR=/path/to/host/folder` to make the generators and synthetic datasets directly accessible from the host.
368
+
369
+ Otherwise, use `docker run --platform=linux/amd64 -p 8080:8080 mostlyai/mostlyai` instead. Optionally, you can use the `-v` flag to mount a [volume](https://docs.docker.com/engine/storage/volumes/#syntax) for passing files between the host and the container.
370
+
371
+ </details>
372
+
373
+ <details>
374
+
375
+ <summary>Connect to the container</summary>
376
+
377
+ You can now connect to the SDK running within the container by initializing the SDK in `CLIENT` mode on the host machine.
378
+
379
+ ```python
380
+ from mostlyai.sdk import MostlyAI
381
+
382
+ mostly = MostlyAI(base_url="http://localhost:8080")
383
+ ```
384
+
385
+ </details>
386
+
346
387
  ### Air-gapped Environments
347
388
 
348
389
  For air-gapped environments (without internet access), you must install the package using the provided wheel files, including any optional dependencies you require.
@@ -351,9 +392,9 @@ If your application depends on a Hugging Face language model, you’ll also need
351
392
 
352
393
  <details>
353
394
 
354
- <summary>Download HuggingFace LANGUAGE models</summary>
395
+ <summary>Download models from Hugging Face Hub</summary>
355
396
 
356
- <p>On a machine with internet access, run the following Python script, to download the HuggingFace model to your local HuggingFace cache.</p>
397
+ <p>On a machine with internet access, run the following Python script, to download the Hugging Face model to your local Hugging Face cache.</p>
357
398
 
358
399
  ```python
359
400
  #! uv pip install huggingface-hub
@@ -39,7 +39,7 @@ https://github.com/user-attachments/assets/9e233213-a259-455c-b8ed-d1f1548b492f
39
39
  - Single-table, multi-table, and time-series
40
40
  - **Multiple Model Types**
41
41
  - State-of-the-art performance via TabularARGN
42
- - Fine-tune HuggingFace-based language models
42
+ - Fine-tune Hugging Face hosted language models
43
43
  - Efficient LSTM for text synthesis from scratch
44
44
  - **Advanced Training Options**
45
45
  - GPU/CPU support
@@ -141,7 +141,7 @@ In either case, a modern GPU is highly recommended when working with language mo
141
141
 
142
142
  Use `pip` (or better `uv pip`) to install the official `mostlyai` package via PyPI. Python 3.10 or higher is required.
143
143
 
144
- It is highly recommended to install the package within a dedicated virtual environment using `uv`.
144
+ It is highly recommended to install the package within a dedicated virtual environment using `uv` (see [here](https://docs.astral.sh/uv/)):
145
145
 
146
146
  <details>
147
147
 
@@ -234,6 +234,47 @@ Add any of the following extras for further data connectors support in LOCAL mod
234
234
  ```shell
235
235
  uv pip install -U 'mostlyai[local, databricks, snowflake]'
236
236
  ```
237
+
238
+ ### Using Docker
239
+
240
+ As an alternative, you can also build a Docker image, which provides you with an isolated environment for running the SDK in LOCAL mode, with all connector dependencies pre-installed. This approach ensures a consistent runtime environment across all systems. Before proceeding, make sure [Docker](https://docs.docker.com/get-started/get-docker/) is installed on your system.
241
+
242
+ <details>
243
+
244
+ <summary>Build the image</summary>
245
+
246
+ If your environment is capable of executing Makefile (see [here](https://github.com/mostly-ai/mostlyai/blob/main/Makefile#L47-L73)), then execute `make docker-build`.
247
+
248
+ Otherwise, use `DOCKER_BUILDKIT=1 docker build . --platform=linux/amd64 -t mostlyai/mostlyai` instead.
249
+
250
+ </details>
251
+
252
+ <details>
253
+
254
+ <summary>Start the container</summary>
255
+
256
+ This will launch the SDK in LOCAL mode on port 8080 inside the container.
257
+
258
+ If your environment is capable of executing Makefile, then execute `make docker-run`. Or `make docker-run HOST_PORT=8080` to forward to a host port of your choice. One could also mount the `local_dir` via `make docker-run HOST_LOCAL_DIR=/path/to/host/folder` to make the generators and synthetic datasets directly accessible from the host.
259
+
260
+ Otherwise, use `docker run --platform=linux/amd64 -p 8080:8080 mostlyai/mostlyai` instead. Optionally, you can use the `-v` flag to mount a [volume](https://docs.docker.com/engine/storage/volumes/#syntax) for passing files between the host and the container.
261
+
262
+ </details>
263
+
264
+ <details>
265
+
266
+ <summary>Connect to the container</summary>
267
+
268
+ You can now connect to the SDK running within the container by initializing the SDK in `CLIENT` mode on the host machine.
269
+
270
+ ```python
271
+ from mostlyai.sdk import MostlyAI
272
+
273
+ mostly = MostlyAI(base_url="http://localhost:8080")
274
+ ```
275
+
276
+ </details>
277
+
237
278
  ### Air-gapped Environments
238
279
 
239
280
  For air-gapped environments (without internet access), you must install the package using the provided wheel files, including any optional dependencies you require.
@@ -242,9 +283,9 @@ If your application depends on a Hugging Face language model, you’ll also need
242
283
 
243
284
  <details>
244
285
 
245
- <summary>Download HuggingFace LANGUAGE models</summary>
286
+ <summary>Download models from Hugging Face Hub</summary>
246
287
 
247
- <p>On a machine with internet access, run the following Python script, to download the HuggingFace model to your local HuggingFace cache.</p>
288
+ <p>On a machine with internet access, run the following Python script, to download the Hugging Face model to your local Hugging Face cache.</p>
248
289
 
249
290
  ```python
250
291
  #! uv pip install huggingface-hub
@@ -15,4 +15,4 @@
15
15
  from mostlyai.sdk.client.api import MostlyAI
16
16
 
17
17
  __all__ = ["MostlyAI"]
18
- __version__ = "4.5.6" # Do not set this manually. Use poetry version [params].
18
+ __version__ = "4.6.0" # Do not set this manually. Use poetry version [params].
@@ -38,6 +38,7 @@ def pull(
38
38
  schema: Schema,
39
39
  model_type: str | ModelType = ModelType.tabular,
40
40
  max_sample_size: int | None = None,
41
+ trn_val_split: float | None = 0.9,
41
42
  workspace_dir: str | Path = "engine-ws",
42
43
  update_progress: ProgressCallback | None = None,
43
44
  ):
@@ -92,9 +93,10 @@ def pull(
92
93
  pull_split(
93
94
  tgt=tgt,
94
95
  schema=schema,
95
- workspace_dir=workspace_dir,
96
- do_ctx_only=False,
96
+ trn_val_split=trn_val_split,
97
97
  model_type=model_type,
98
+ do_ctx_only=False,
99
+ workspace_dir=workspace_dir,
98
100
  progress=progress,
99
101
  )
100
102
 
@@ -57,9 +57,10 @@ def pull_context(
57
57
  pull_split(
58
58
  tgt=tgt,
59
59
  schema=schema,
60
- workspace_dir=workspace_dir,
61
- do_ctx_only=True,
60
+ trn_val_split=None,
62
61
  model_type=model_type,
62
+ do_ctx_only=True,
63
+ workspace_dir=workspace_dir,
63
64
  progress=ProgressCallbackWrapper(update_progress=update_progress),
64
65
  )
65
66
 
@@ -651,6 +651,7 @@ def export_chunk(
651
651
  chunk: pd.DataFrame,
652
652
  hash_column: pd.Series,
653
653
  n_partitions: int,
654
+ trn_val_split: float | None,
654
655
  data_dir: Path,
655
656
  do_ctx_only: bool,
656
657
  ):
@@ -677,14 +678,18 @@ def export_chunk(
677
678
  _store_partition_chunk(partition_idx=f"000000-{split}", partition_chunk=chunk)
678
679
  return
679
680
 
680
- # split into partitions; plus split each partition into trn/val of 90/10
681
- # for that we create 10x more partitions, map modulo 0 to `val`, all others to `trn` and then trim last digit
681
+ # split into partitions; plus split each partition into trn/val based on trn_val_split
682
+ # for that we create 10x more partitions, map modulo based on trn_val_split
682
683
  # don't split into partitions when pulling context only
684
+ trn_val_split = trn_val_split or 0.9
685
+ val_count = round((1 - trn_val_split) * 10) # number of partitions for validation (out of 10)
683
686
  hashes = _hash_partitioner(hash_column, 10 * n_partitions)
684
- if np.all(hashes % 10 == 0):
685
- hashes += 1 # ensure that we have at least one training partition
687
+ if np.all(hashes % 10 < val_count):
688
+ hashes += val_count # ensure that we have at least one training partition
689
+
686
690
  chunk["__PARTITION_GROUP"] = hashes // 10
687
- chunk["__PARTITION_SPLIT"] = np.where(hashes % 10 == 0, "val", "trn") if not do_ctx_only else "ctx"
691
+ chunk["__PARTITION_SPLIT"] = np.where(hashes % 10 < val_count, "val", "trn") if not do_ctx_only else "ctx"
692
+
688
693
  for partition_group in chunk["__PARTITION_GROUP"].unique():
689
694
  partition_chunk = chunk[chunk["__PARTITION_GROUP"] == partition_group]
690
695
  for partition_split in partition_chunk["__PARTITION_SPLIT"].unique():
@@ -729,13 +734,14 @@ def split_context(
729
734
  schema: Schema,
730
735
  ctx_data_dir: Path,
731
736
  n_partitions: int,
737
+ trn_val_split: float | None,
732
738
  model_type: ModelType,
733
739
  do_ctx_only: bool,
734
740
  progress: ProgressCallbackWrapper,
735
741
  ):
736
742
  ctx = schema.get_parent(tgt)
737
743
  context_tables = schema.get_context_tables(tgt)
738
- ctx_tgt_nodes, ctx_tgt_path = get_table_chain_to_tgt(
744
+ _, ctx_tgt_path = get_table_chain_to_tgt(
739
745
  schema=schema,
740
746
  tables=context_tables,
741
747
  tgt=tgt,
@@ -819,6 +825,7 @@ def split_context(
819
825
  chunk=chunk,
820
826
  hash_column=chunk[key.ref_name()],
821
827
  n_partitions=n_partitions,
828
+ trn_val_split=trn_val_split,
822
829
  data_dir=ctx_data_dir,
823
830
  do_ctx_only=do_ctx_only,
824
831
  )
@@ -837,6 +844,7 @@ def split_target(
837
844
  schema: Schema,
838
845
  tgt_data_dir: Path,
839
846
  n_partitions: int,
847
+ trn_val_split: float | None,
840
848
  model_type: ModelType,
841
849
  do_ctx_only: bool,
842
850
  progress: ProgressCallbackWrapper,
@@ -893,6 +901,7 @@ def split_target(
893
901
  chunk=chunk,
894
902
  hash_column=_hash_column(chunk),
895
903
  n_partitions=n_partitions,
904
+ trn_val_split=trn_val_split,
896
905
  data_dir=tgt_data_dir,
897
906
  do_ctx_only=do_ctx_only,
898
907
  )
@@ -938,9 +947,10 @@ def pull_split(
938
947
  *,
939
948
  tgt: str,
940
949
  schema: Schema,
941
- workspace_dir: Path,
942
- do_ctx_only: bool,
950
+ trn_val_split: float | None,
943
951
  model_type: ModelType,
952
+ do_ctx_only: bool,
953
+ workspace_dir: Path,
944
954
  progress: ProgressCallbackWrapper,
945
955
  ) -> None:
946
956
  """Split fetched data among partitions.
@@ -987,6 +997,7 @@ def pull_split(
987
997
  schema=schema,
988
998
  ctx_data_dir=ctx_data_dir,
989
999
  n_partitions=n_partitions,
1000
+ trn_val_split=trn_val_split,
990
1001
  model_type=model_type,
991
1002
  do_ctx_only=do_ctx_only,
992
1003
  progress=progress,
@@ -998,6 +1009,7 @@ def pull_split(
998
1009
  schema=schema,
999
1010
  tgt_data_dir=tgt_data_dir,
1000
1011
  n_partitions=n_partitions,
1012
+ trn_val_split=trn_val_split,
1001
1013
  model_type=model_type,
1002
1014
  do_ctx_only=do_ctx_only,
1003
1015
  progress=progress,
@@ -0,0 +1,32 @@
1
+ # Copyright 2025 MOSTLY AI
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from pathlib import Path
16
+ from mostlyai.engine._workspace import Workspace
17
+
18
+
19
+ def migrate_workspace(workspace_dir: Path) -> None:
20
+ workspace = Workspace(workspace_dir)
21
+ # migrate min5/max5 in column stats to min/max (<= 4.5.6)
22
+ for stats_pathdesc in [workspace.ctx_stats, workspace.tgt_stats]:
23
+ stats = stats_pathdesc.read()
24
+ if stats:
25
+ for col, col_stats in stats.get("columns", {}).items():
26
+ if col_stats.get("min5") is not None:
27
+ col_stats["min"] = min(col_stats["min5"]) if len(col_stats["min5"]) > 0 else None
28
+ col_stats.pop("min5")
29
+ if col_stats.get("max5") is not None:
30
+ col_stats["max"] = max(col_stats["max5"]) if len(col_stats["max5"]) > 0 else None
31
+ col_stats.pop("max5")
32
+ stats_pathdesc.write(stats)
@@ -17,6 +17,8 @@ from collections import ChainMap, defaultdict
17
17
  from pathlib import Path
18
18
  from collections.abc import Callable
19
19
 
20
+ from mostlyai.engine.domain import DifferentialPrivacyConfig
21
+
20
22
  from mostlyai.sdk.domain import Generator, ModelType, SourceColumnValueRange, ModelEncodingType
21
23
 
22
24
 
@@ -39,10 +41,17 @@ def execute_step_analyze_training_data(
39
41
  else:
40
42
  model_config = tgt_table.tabular_model_configuration
41
43
 
44
+ # convert from SDK domain to ENGINE domain
45
+ if model_config.differential_privacy:
46
+ differential_privacy = DifferentialPrivacyConfig(**model_config.differential_privacy.model_dump())
47
+ else:
48
+ differential_privacy = None
49
+
42
50
  # call ANALYZE
43
51
  engine.analyze(
44
52
  workspace_dir=workspace_dir,
45
53
  value_protection=model_config.value_protection,
54
+ differential_privacy=differential_privacy,
46
55
  update_progress=update_progress,
47
56
  )
48
57
 
@@ -209,7 +209,6 @@ def create_report(
209
209
  report_subtitle=f" for {target_table_name[:30]}:{model_type.name}",
210
210
  report_credits=report_credits,
211
211
  max_sample_size_accuracy=100_000,
212
- max_sample_size_embeddings=10_000,
213
212
  update_progress=update_progress,
214
213
  )
215
214
  metrics = None
@@ -16,6 +16,8 @@
16
16
  from pathlib import Path
17
17
  from collections.abc import Callable
18
18
 
19
+ from mostlyai.sdk._local.execution.migration import migrate_workspace
20
+
19
21
 
20
22
  def execute_step_encode_training_data(
21
23
  *,
@@ -25,6 +27,9 @@ def execute_step_encode_training_data(
25
27
  # import ENGINE here to avoid pre-mature loading of large ENGINE dependencies
26
28
  from mostlyai import engine
27
29
 
30
+ # ensure backward compatibility
31
+ migrate_workspace(workspace_dir)
32
+
28
33
  # call ENCODE
29
34
  engine.encode(
30
35
  workspace_dir=workspace_dir,
@@ -20,6 +20,7 @@ import pandas as pd
20
20
  from mostlyai.sdk import _data as data
21
21
  from mostlyai.sdk._data.base import Schema
22
22
  from mostlyai.sdk._data.util.common import TABLE_COLUMN_INFIX, TEMPORARY_PRIMARY_KEY
23
+ from mostlyai.sdk._local.execution.migration import migrate_workspace
23
24
  from mostlyai.sdk.domain import Generator, SyntheticDataset, ModelType
24
25
 
25
26
 
@@ -37,6 +38,9 @@ def execute_step_generate_data(
37
38
  # import ENGINE here to avoid pre-mature loading of large ENGINE dependencies
38
39
  import mostlyai.engine as engine
39
40
 
41
+ # ensure backward compatibility
42
+ migrate_workspace(workspace_dir)
43
+
40
44
  tgt_g_table = next(t for t in generator.tables if t.name == target_table_name)
41
45
  tgt_sd_table = next(t for t in synthetic_dataset.tables if t.name == target_table_name)
42
46
  config = tgt_sd_table.configuration
@@ -144,16 +144,21 @@ class Routes:
144
144
 
145
145
  @self.router.get("/connectors")
146
146
  async def list_connectors(
147
- offset=0, limit=50, searchTerm: str | None = None, access_type: str | None = None
147
+ offset=0,
148
+ limit=50,
149
+ searchTerm: str | None = None,
150
+ access_type: str | None = None,
148
151
  ) -> JSONResponse:
149
152
  connector_dirs = [p for p in (self.home_dir / "connectors").glob("*") if p.is_dir()]
150
153
  connector_list_items = []
151
154
  for connector_dir in connector_dirs:
152
155
  connector = read_connector_from_json(connector_dir)
153
- if not searchTerm or searchTerm.lower() in (connector.name or "").lower():
154
- if not access_type or access_type == connector.access_type:
155
- # use model_construct to skip validation and warnings of extra fields
156
- connector_list_items.append(ConnectorListItem.model_construct(**connector.model_dump()))
156
+ connector_string = " ".join([connector.name or "", connector.description or ""]).lower()
157
+ if searchTerm and searchTerm.lower() not in connector_string:
158
+ continue
159
+ if access_type and access_type != connector.access_type:
160
+ continue
161
+ connector_list_items.append(ConnectorListItem.model_construct(**connector.model_dump()))
157
162
 
158
163
  # use jsonable_encoder to handle non-serializable objects like datetime
159
164
  return JSONResponse(
@@ -289,24 +294,26 @@ class Routes:
289
294
 
290
295
  @self.router.get("/generators")
291
296
  async def list_generators(
292
- offset: int = 0, limit: int = 50, searchTerm: str | None = None, status: str | None = None
297
+ offset: int = 0,
298
+ limit: int = 50,
299
+ searchTerm: str | None = None,
300
+ status: str | None = None,
293
301
  ) -> JSONResponse:
294
302
  generator_dirs = [p for p in (self.home_dir / "generators").glob("*") if p.is_dir()]
295
303
  generator_list_items = []
296
304
  for generator_dir in generator_dirs:
297
305
  generator = read_generator_from_json(generator_dir)
298
- if (
299
- not searchTerm
300
- or searchTerm.lower() in (generator.name or "").lower()
301
- or searchTerm.lower() in (generator.description or "").lower()
302
- ):
303
- if not status or status == generator.training_status:
304
- # use model_construct to skip validation and warnings of extra fields
305
- generator_list_items.append(GeneratorListItem.model_construct(**generator.model_dump()))
306
- # use jsonable_encoder to handle non-serializable objects like datetime
306
+ generator_string = " ".join([generator.name or "", generator.description or ""]).lower()
307
+ if searchTerm and searchTerm.lower() not in generator_string:
308
+ continue
309
+ if status and status != generator.training_status:
310
+ continue
311
+ # use model_construct to skip validation and warnings of extra fields
312
+ generator_list_items.append(GeneratorListItem.model_construct(**generator.model_dump()))
313
+
307
314
  return JSONResponse(
308
315
  status_code=200,
309
- content=jsonable_encoder(
316
+ content=jsonable_encoder( # use jsonable_encoder to handle non-serializable objects like datetime
310
317
  {
311
318
  "totalCount": len(generator_list_items),
312
319
  "results": generator_list_items[int(offset) : int(offset) + int(limit)],
@@ -455,26 +462,30 @@ class Routes:
455
462
 
456
463
  @self.router.get("/synthetic-datasets")
457
464
  async def list_synthetic_datasets(
458
- offset: int = 0, limit: int = 50, searchTerm: str | None = None, status: str | None = None
465
+ offset: int = 0,
466
+ limit: int = 50,
467
+ searchTerm: str | None = None,
468
+ status: str | None = None,
459
469
  ) -> JSONResponse:
460
470
  synthetic_dataset_dirs = [p for p in (self.home_dir / "synthetic-datasets").glob("*") if p.is_dir()]
461
471
  synthetic_dataset_list_items = []
462
472
  for synthetic_dataset_dir in synthetic_dataset_dirs:
463
473
  synthetic_dataset = read_synthetic_dataset_from_json(synthetic_dataset_dir)
464
- if (
465
- not searchTerm
466
- or searchTerm.lower() in (synthetic_dataset.name or "").lower()
467
- or searchTerm.lower() in (synthetic_dataset.description or "").lower()
468
- ):
469
- if not status or status == synthetic_dataset.generation_status:
470
- # use model_construct to skip validation and warnings of extra fields
471
- synthetic_dataset_list_items.append(
472
- SyntheticDatasetListItem.model_construct(**synthetic_dataset.model_dump())
473
- )
474
- # use jsonable_encoder to handle non-serializable objects like datetime
474
+ synthetic_dataset_string = " ".join(
475
+ [synthetic_dataset.name or "", synthetic_dataset.description or ""]
476
+ ).lower()
477
+ if searchTerm and searchTerm.lower() not in synthetic_dataset_string:
478
+ continue
479
+ if status and status != synthetic_dataset.generation_status:
480
+ continue
481
+ # use model_construct to skip validation and warnings of extra fields
482
+ synthetic_dataset_list_items.append(
483
+ SyntheticDatasetListItem.model_construct(**synthetic_dataset.model_dump())
484
+ )
485
+
475
486
  return JSONResponse(
476
487
  status_code=200,
477
- content=jsonable_encoder(
488
+ content=jsonable_encoder( # use jsonable_encoder to handle non-serializable objects like datetime
478
489
  {
479
490
  "totalCount": len(synthetic_dataset_list_items),
480
491
  "results": synthetic_dataset_list_items[int(offset) : int(offset) + int(limit)],
@@ -76,17 +76,6 @@ def validate_base_url(base_url: str) -> None:
76
76
  raise APIError("Invalid base URL.")
77
77
 
78
78
 
79
- def validate_api_key(api_key: str) -> None:
80
- """
81
- Check if the provided API key is valid. Raise an exception if it is not.
82
- """
83
- api_key = str(api_key)
84
- if not api_key:
85
- raise APIError("Missing API key.")
86
- elif len(api_key) != 71:
87
- raise APIError("Invalid API key format.")
88
-
89
-
90
79
  class _DynamicRefreshThread(Thread):
91
80
  """A thread that calls live.refresh() at dynamic intervals, increasing the delay between refreshes over time.
92
81
  The refresh interval stays at initial_interval for the first fixed_time seconds,
@@ -97,7 +86,7 @@ class _DynamicRefreshThread(Thread):
97
86
  self,
98
87
  live: "Live",
99
88
  initial_interval: float = 2.0,
100
- max_interval: float = 60.0,
89
+ max_interval: float = 30.0,
101
90
  fixed_time: float = 30.0,
102
91
  increasing_time: float = 60.0,
103
92
  ) -> None:
@@ -47,7 +47,6 @@ from mostlyai.sdk.client._utils import (
47
47
  harmonize_sd_config,
48
48
  Seed,
49
49
  check_local_mode_available,
50
- validate_api_key,
51
50
  validate_base_url,
52
51
  )
53
52
 
@@ -176,8 +175,7 @@ class MostlyAI(_MostlyBaseClient):
176
175
  base_url = os.getenv("MOSTLY_BASE_URL", DEFAULT_BASE_URL).rstrip("/")
177
176
  validate_base_url(base_url)
178
177
  if api_key is None:
179
- api_key = os.getenv("MOSTLY_API_KEY")
180
- validate_api_key(api_key)
178
+ api_key = os.getenv("MOSTLY_API_KEY", "")
181
179
  home_dir = None
182
180
  uds = None
183
181
  else:
@@ -221,7 +219,7 @@ class MostlyAI(_MostlyBaseClient):
221
219
  msg += f" as [bold]{email}[/bold]" if email else ""
222
220
  rich.print(msg)
223
221
  except Exception as e:
224
- rich.print(f"Failed to connect to {self.base_url}: {e}.")
222
+ rich.print(f"Failed to connect to {self.base_url} : {e}.")
225
223
  else:
226
224
  raise ValueError("Invalid SDK mode")
227
225
 
@@ -68,7 +68,7 @@ class _MostlyBaseClient:
68
68
  ssl_verify: bool = True,
69
69
  ):
70
70
  self.base_url = (base_url or os.getenv("MOSTLY_BASE_URL") or DEFAULT_BASE_URL).rstrip("/")
71
- self.api_key = api_key or os.getenv("MOSTLY_API_KEY")
71
+ self.api_key = api_key or os.getenv("MOSTLY_API_KEY", "")
72
72
  self.local = self.api_key == "local"
73
73
  self.transport = httpx.HTTPTransport(uds=uds) if uds else None
74
74
  self.timeout = timeout
@@ -47,9 +47,13 @@ class _MostlyConnectorsClient(_MostlyBaseClient):
47
47
  self,
48
48
  offset: int = 0,
49
49
  limit: int | None = None,
50
- access_type: str | None = None,
51
50
  search_term: str | None = None,
51
+ access_type: str | None = None,
52
52
  owner_id: str | list[str] | None = None,
53
+ visibility: str | list[str] | None = None,
54
+ created_from: str | None = None,
55
+ created_to: str | None = None,
56
+ sort_by: str | list[str] | None = None,
53
57
  ) -> Iterator[ConnectorListItem]:
54
58
  """
55
59
  List connectors.
@@ -67,9 +71,13 @@ class _MostlyConnectorsClient(_MostlyBaseClient):
67
71
  Args:
68
72
  offset: Offset for entities in the response.
69
73
  limit: Limit for the number of entities in the response.
70
- access_type: Filter by access type (e.g., "SOURCE" or "DESTINATION").
71
- search_term: Filter by string in the connector name.
74
+ search_term: Filter by search term in the name and description.
75
+ access_type: Filter by access type (e.g., READ_PROTECTED, READ_DATA or WRITE_DATA).
72
76
  owner_id: Filter by owner ID.
77
+ visibility: Filter by visibility (e.g., PUBLIC, PRIVATE or UNLISTED).
78
+ created_from: Filter by creation date, not older than this date. Format: YYYY-MM-DD.
79
+ created_to: Filter by creation date, not younger than this date. Format: YYYY-MM-DD.
80
+ sort_by: Sort by field. Either RECENCY or NO_OF_GENERATORS.
73
81
 
74
82
  Returns:
75
83
  Iterator[ConnectorListItem]: An iterator over connector list items.
@@ -79,9 +87,13 @@ class _MostlyConnectorsClient(_MostlyBaseClient):
79
87
  ConnectorListItem,
80
88
  offset=offset,
81
89
  limit=limit,
82
- access_type=access_type,
83
90
  search_term=search_term,
91
+ access_type=access_type,
84
92
  owner_id=owner_id,
93
+ visibility=visibility,
94
+ created_from=created_from,
95
+ created_to=created_to,
96
+ sort_by=sort_by,
85
97
  ) as paginator:
86
98
  yield from paginator
87
99
 
@@ -56,6 +56,10 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
56
56
  status: str | list[str] | None = None,
57
57
  search_term: str | None = None,
58
58
  owner_id: str | list[str] | None = None,
59
+ visibility: str | list[str] | None = None,
60
+ created_from: str | None = None,
61
+ created_to: str | None = None,
62
+ sort_by: str | list[str] | None = None,
59
63
  ) -> Iterator[GeneratorListItem]:
60
64
  """
61
65
  List generators.
@@ -68,6 +72,10 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
68
72
  status: Filter by training status.
69
73
  search_term: Filter by name or description.
70
74
  owner_id: Filter by owner ID.
75
+ visibility: Filter by visibility (e.g., PUBLIC, PRIVATE or UNLISTED).
76
+ created_from: Filter by creation date, not older than this date. Format: YYYY-MM-DD.
77
+ created_to: Filter by creation date, not younger than this date. Format: YYYY-MM-DD.
78
+ sort_by: Sort by field. Either RECENCY, NO_OF_LIKES or NO_OF_SYNTHETIC_DATASETS.
71
79
 
72
80
  Returns:
73
81
  Iterator[GeneratorListItem]: An iterator over generator list items.
@@ -97,6 +105,10 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
97
105
  status=status,
98
106
  search_term=search_term,
99
107
  owner_id=owner_id,
108
+ visibility=visibility,
109
+ created_from=created_from,
110
+ created_to=created_to,
111
+ sort_by=sort_by,
100
112
  ) as paginator:
101
113
  yield from paginator
102
114
 
@@ -55,6 +55,10 @@ class _MostlySyntheticDatasetsClient(_MostlyBaseClient):
55
55
  status: str | list[str] | None = None,
56
56
  search_term: str | None = None,
57
57
  owner_id: str | list[str] | None = None,
58
+ visibility: str | list[str] | None = None,
59
+ created_from: str | None = None,
60
+ created_to: str | None = None,
61
+ sort_by: str | list[str] | None = None,
58
62
  ) -> Iterator[SyntheticDatasetListItem]:
59
63
  """
60
64
  List synthetic datasets.
@@ -67,6 +71,10 @@ class _MostlySyntheticDatasetsClient(_MostlyBaseClient):
67
71
  status: Filter by generation status.
68
72
  search_term: Filter by name or description.
69
73
  owner_id: Filter by owner ID.
74
+ visibility: Filter by visibility (e.g., PUBLIC, PRIVATE or UNLISTED).
75
+ created_from: Filter by creation date, not older than this date. Format: YYYY-MM-DD.
76
+ created_to: Filter by creation date, not younger than this date. Format: YYYY-MM-DD.
77
+ sort_by: Sort by field. Either RECENCY, NO_OF_LIKES or NO_OF_DOWNLOADS.
70
78
 
71
79
  Returns:
72
80
  An iterator over synthetic datasets.
@@ -96,6 +104,10 @@ class _MostlySyntheticDatasetsClient(_MostlyBaseClient):
96
104
  status=status,
97
105
  search_term=search_term,
98
106
  owner_id=owner_id,
107
+ visibility=visibility,
108
+ created_from=created_from,
109
+ created_to=created_to,
110
+ sort_by=sort_by,
99
111
  ) as paginator:
100
112
  yield from paginator
101
113
 
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  # generated by datamodel-codegen:
16
- # timestamp: 2025-04-22T09:42:59+00:00
16
+ # timestamp: 2025-05-11T00:16:17+00:00
17
17
 
18
18
  from __future__ import annotations
19
19
 
@@ -1400,31 +1400,38 @@ class DifferentialPrivacyConfig(CustomBaseModel):
1400
1400
  """
1401
1401
 
1402
1402
  max_epsilon: float | None = Field(
1403
- None,
1403
+ 10.0,
1404
1404
  alias="maxEpsilon",
1405
1405
  description="Specifies the maximum allowable epsilon value. If the training process exceeds this threshold, it will be terminated early. Only model checkpoints with epsilon values below this limit will be retained. \nIf not provided, the training will proceed without early termination based on epsilon constraints.\n",
1406
- ge=0.0,
1406
+ gt=0.0,
1407
1407
  le=10000.0,
1408
1408
  )
1409
+ delta: float | None = Field(
1410
+ "1e-5",
1411
+ description="The delta value for differential privacy. It is the probability of the privacy guarantee not holding. \nThe smaller the delta, the more confident you can be that the privacy guarantee holds.\nThis delta will be equally distributed between the analysis and the training phase.\n",
1412
+ gt=0.0,
1413
+ le=1.0,
1414
+ )
1409
1415
  noise_multiplier: float | None = Field(
1410
1416
  1.5,
1411
1417
  alias="noiseMultiplier",
1412
- description="The ratio of the standard deviation of the Gaussian noise to the L2-sensitivity of the function to which the noise is added (How much noise to add).\n",
1418
+ description="Determines how much noise while training the model with differential privacy. This is the ratio of the standard deviation of the Gaussian noise to the L2-sensitivity of the function to which the noise is added.\n",
1413
1419
  ge=0.0,
1414
1420
  le=10000.0,
1415
1421
  )
1416
1422
  max_grad_norm: float | None = Field(
1417
1423
  1.0,
1418
1424
  alias="maxGradNorm",
1419
- description="The maximum norm of the per-sample gradients for training the model with differential privacy.\n",
1425
+ description="Determines the maximum impact of a single sample on updating the model weights during training with differential privacy. This is the maximum norm of the per-sample gradients.\n",
1420
1426
  ge=0.0,
1421
1427
  le=10000.0,
1422
1428
  )
1423
- delta: float | None = Field(
1424
- "1e-5",
1425
- description="The delta value for differential privacy. It is the probability of the privacy guarantee not holding. \nThe smaller the delta, the more confident you can be that the privacy guarantee holds.\n",
1426
- ge=0.0,
1427
- le=1.0,
1429
+ value_protection_epsilon: float | None = Field(
1430
+ 1.0,
1431
+ alias="valueProtectionEpsilon",
1432
+ description="The DP epsilon of the privacy budget for determining the value ranges, which are gathered prior to the model training during the analysis step. Only applicable if value protection is True.\nPrivacy budget will be equally distributed between the columns. For categorical we calculate noisy histograms and use a noisy threshold. For numeric and datetime we calculate bounds based on noisy histograms.\n",
1433
+ gt=0.0,
1434
+ le=10000.0,
1428
1435
  )
1429
1436
 
1430
1437
 
@@ -1436,7 +1443,8 @@ class Accuracy(CustomBaseModel):
1436
1443
  1. **Univariate Accuracy**: The accuracy of the univariate distributions for all target columns.
1437
1444
  2. **Bivariate Accuracy**: The accuracy of all pair-wise distributions for target columns, as well as for target
1438
1445
  columns with respect to the context columns.
1439
- 3. **Coherence Accuracy**: The accuracy of the auto-correlation for all target columns.
1446
+ 3. **Trivariate Accuracy**: The accuracy of all three-way distributions for target columns.
1447
+ 4. **Coherence Accuracy**: The accuracy of the auto-correlation for all target columns.
1440
1448
 
1441
1449
  Accuracy is defined as 100% - [Total Variation Distance](https://en.wikipedia.org/wiki/Total_variation_distance_of_probability_measures) (TVD),
1442
1450
  whereas TVD is half the sum of the absolute differences of the relative frequencies of the corresponding
@@ -1470,6 +1478,12 @@ class Accuracy(CustomBaseModel):
1470
1478
  ge=0.0,
1471
1479
  le=1.0,
1472
1480
  )
1481
+ trivariate: float | None = Field(
1482
+ None,
1483
+ description="Average accuracy of discretized trivariate distributions.\n",
1484
+ ge=0.0,
1485
+ le=1.0,
1486
+ )
1473
1487
  coherence: float | None = Field(
1474
1488
  None,
1475
1489
  description="Average accuracy of discretized coherence distributions. Only applicable for sequential data.\n",
@@ -1497,6 +1511,13 @@ class Accuracy(CustomBaseModel):
1497
1511
  ge=0.0,
1498
1512
  le=1.0,
1499
1513
  )
1514
+ trivariate_max: float | None = Field(
1515
+ None,
1516
+ alias="trivariateMax",
1517
+ description="Expected trivariate accuracy of a same-sized holdout. Serves as a reference for `trivariate`.\n",
1518
+ ge=0.0,
1519
+ le=1.0,
1520
+ )
1500
1521
  coherence_max: float | None = Field(
1501
1522
  None,
1502
1523
  alias="coherenceMax",
@@ -1560,19 +1581,19 @@ class Similarity(CustomBaseModel):
1560
1581
 
1561
1582
  class Distances(CustomBaseModel):
1562
1583
  """
1563
- Metrics regarding the nearest neighbor distances between training, holdout, and synthetic samples in an embedding
1564
- space. Useful for assessing the novelty / privacy of synthetic data.
1584
+ Metrics regarding the nearest neighbor distances between training, holdout, and synthetic samples in an numerically
1585
+ encoded space. Useful for assessing the novelty / privacy of synthetic data.
1565
1586
 
1566
1587
  The provided data is first down-sampled, so that the number of samples match across all datasets. Note, that for
1567
1588
  an optimal sensitivity of this privacy assessment it is recommended to use a 50/50 split between training and
1568
1589
  holdout data, and then generate synthetic data of the same size.
1569
1590
 
1570
- The embeddings of these samples are then computed, and the nearest neighbor distances are calculated for each
1591
+ The numerical encodings of these samples are then computed, and the nearest neighbor distances are calculated for each
1571
1592
  synthetic sample to the training and holdout samples. Based on these nearest neighbor distances the following
1572
1593
  metrics are calculated:
1573
- - Identical Match Share (IMS): The share of synthetic samples that are identical to a training or holdout sample.
1574
- - Distance to Closest Record (DCR): The average distance of synthetic to training or holdout samples.
1575
- - Nearest Neighbor Distance Ratio (NNDR): The 10-th smallest ratio of the distance to nearest and second nearest neighbor.
1594
+ - Identical Match Share (IMS): The share of synthetic samples that are identical to a training or holdout sample.
1595
+ - Distance to Closest Record (DCR): The average distance of synthetic to training or holdout samples.
1596
+ - Nearest Neighbor Distance Ratio (NNDR): The 10-th smallest ratio of the distance to nearest and second nearest neighbor.
1576
1597
 
1577
1598
  For privacy-safe synthetic data we expect to see about as many identical matches, and about the same distances
1578
1599
  for synthetic samples to training, as we see for synthetic samples to holdout.
@@ -2186,6 +2207,17 @@ class ModelConfiguration(CustomBaseModel):
2186
2207
  description="If false, then the Model report is not generated.\n",
2187
2208
  )
2188
2209
 
2210
+ @model_validator(mode="after")
2211
+ @classmethod
2212
+ def validate_differential_privacy_config(cls, values):
2213
+ if values.differential_privacy:
2214
+ if not values.value_protection:
2215
+ values.differential_privacy.value_protection_epsilon = None
2216
+ else:
2217
+ if values.differential_privacy.value_protection_epsilon is None:
2218
+ values.differential_privacy.value_protection_epsilon = 1.0
2219
+ return values
2220
+
2189
2221
 
2190
2222
  class ProgressStep(CustomBaseModel):
2191
2223
  """
@@ -2477,7 +2509,7 @@ class ModelMetrics(CustomBaseModel):
2477
2509
  2. **Similarity**: Metrics regarding the similarity of the full joint distributions of samples within an embedding
2478
2510
  space.
2479
2511
  3. **Distances**: Metrics regarding the nearest neighbor distances between training, holdout, and synthetic samples
2480
- in an embedding space. Useful for assessing the novelty / privacy of synthetic data.
2512
+ in an numeric encoding space. Useful for assessing the novelty / privacy of synthetic data.
2481
2513
 
2482
2514
  The quality of synthetic data is assessed by comparing these metrics to the same metrics of a holdout dataset.
2483
2515
  The holdout dataset is a subset of the original training data, that was not used for training the synthetic data
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mostlyai"
3
- version = "4.5.6"
3
+ version = "4.6.0"
4
4
  description = "Synthetic Data SDK"
5
5
  authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
6
6
  requires-python = ">=3.10,<3.14"
@@ -49,8 +49,8 @@ dependencies = [
49
49
  local = [
50
50
  # "mostlyai-engine @ git+https://github.com/mostly-ai/mostlyai-engine.git@main", # for development
51
51
  # "mostlyai-qa @ git+https://github.com/mostly-ai/mostlyai-qa.git@main", # for development
52
- "mostlyai-engine==1.3.2", # for release
53
- "mostlyai-qa==1.7.0", # for release
52
+ "mostlyai-engine==1.4.0", # for release
53
+ "mostlyai-qa==1.9.1", # for release
54
54
  "fastapi>=0.115.6,<0.116",
55
55
  "uvicorn>=0.34.0,<0.35",
56
56
  "python-multipart>=0.0.20",
@@ -75,8 +75,8 @@ local = [
75
75
  local-gpu = [
76
76
  # "mostlyai-engine[gpu] @ git+https://github.com/mostly-ai/mostlyai-engine.git@main", # for development
77
77
  # "mostlyai-qa @ git+https://github.com/mostly-ai/mostlyai-qa.git@main", # for development
78
- "mostlyai-engine[gpu]==1.3.2", # for release
79
- "mostlyai-qa==1.7.0", # for release
78
+ "mostlyai-engine[gpu]==1.4.0", # for release
79
+ "mostlyai-qa==1.9.1", # for release
80
80
  "fastapi>=0.115.6,<0.116",
81
81
  "uvicorn>=0.34.0,<0.35",
82
82
  "python-multipart>=0.0.20",
File without changes
File without changes
@@ -62,8 +62,8 @@ def execute_step_train_model(
62
62
  max_epochs=model_config.max_epochs,
63
63
  batch_size=model_config.batch_size,
64
64
  gradient_accumulation_steps=model_config.gradient_accumulation_steps,
65
- max_sequence_window=max_sequence_window,
66
65
  enable_flexible_generation=model_config.enable_flexible_generation,
66
+ max_sequence_window=max_sequence_window,
67
67
  differential_privacy=differential_privacy,
68
68
  model_state_strategy=ModelStateStrategy.resume if restarts > 0 else ModelStateStrategy.reuse,
69
69
  workspace_dir=workspace_dir,
File without changes