mostlyai 4.5.6__tar.gz → 4.5.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. {mostlyai-4.5.6 → mostlyai-4.5.7}/PKG-INFO +48 -7
  2. {mostlyai-4.5.6 → mostlyai-4.5.7}/README.md +45 -4
  3. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/__init__.py +1 -1
  4. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/pull.py +4 -2
  5. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/pull_context.py +3 -2
  6. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/pull_utils.py +20 -8
  7. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/routes.py +40 -29
  8. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/client/_utils.py +1 -12
  9. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/client/api.py +2 -4
  10. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/client/base.py +1 -1
  11. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/client/connectors.py +16 -4
  12. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/client/generators.py +12 -0
  13. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/client/synthetic_datasets.py +12 -0
  14. {mostlyai-4.5.6 → mostlyai-4.5.7}/pyproject.toml +3 -3
  15. {mostlyai-4.5.6 → mostlyai-4.5.7}/.gitignore +0 -0
  16. {mostlyai-4.5.6 → mostlyai-4.5.7}/LICENSE +0 -0
  17. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/__init__.py +0 -0
  18. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/auto_detect.py +0 -0
  19. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/base.py +0 -0
  20. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/context.py +0 -0
  21. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/conversions.py +0 -0
  22. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/__init__.py +0 -0
  23. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/base.py +0 -0
  24. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/bigquery.py +0 -0
  25. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/databricks.py +0 -0
  26. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/hive.py +0 -0
  27. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/mssql.py +0 -0
  28. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/mysql.py +0 -0
  29. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/oracle.py +0 -0
  30. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/postgresql.py +0 -0
  31. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/snowflake.py +0 -0
  32. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/sqlite.py +0 -0
  33. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
  34. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/dtype.py +0 -0
  35. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/exceptions.py +0 -0
  36. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/__init__.py +0 -0
  37. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/base.py +0 -0
  38. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
  39. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/container/aws.py +0 -0
  40. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/container/azure.py +0 -0
  41. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
  42. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
  43. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/container/minio.py +0 -0
  44. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
  45. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/table/csv.py +0 -0
  46. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/table/feather.py +0 -0
  47. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/table/json.py +0 -0
  48. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
  49. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/file/utils.py +0 -0
  50. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/language_model.py +0 -0
  51. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/metadata_objects.py +0 -0
  52. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/non_context.py +0 -0
  53. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/progress_callback.py +0 -0
  54. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/push.py +0 -0
  55. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/util/__init__.py +0 -0
  56. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/util/common.py +0 -0
  57. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_data/util/kerberos.py +0 -0
  58. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/__init__.py +0 -0
  59. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/cli.py +0 -0
  60. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/connectors.py +0 -0
  61. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/__init__.py +0 -0
  62. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/jobs.py +0 -0
  63. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/plan.py +0 -0
  64. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
  65. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
  66. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
  67. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
  68. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
  69. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
  70. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
  71. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
  72. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
  73. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
  74. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
  75. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/generators.py +0 -0
  76. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/progress.py +0 -0
  77. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/server.py +0 -0
  78. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/storage.py +0 -0
  79. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
  80. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/client/__init__.py +0 -0
  81. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/client/_base_utils.py +0 -0
  82. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/client/_naming_conventions.py +0 -0
  83. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/client/exceptions.py +0 -0
  84. {mostlyai-4.5.6 → mostlyai-4.5.7}/mostlyai/sdk/domain.py +0 -0
  85. {mostlyai-4.5.6 → mostlyai-4.5.7}/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.5.7
4
4
  Summary: Synthetic Data SDK
5
5
  Project-URL: homepage, https://app.mostly.ai/
6
6
  Project-URL: repository, https://github.com/mostly-ai/mostlyai
@@ -59,7 +59,7 @@ 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'
62
+ Requires-Dist: mostlyai-engine==1.3.3; extra == 'local'
63
63
  Requires-Dist: mostlyai-qa==1.7.0; extra == 'local'
64
64
  Requires-Dist: networkx<4,>=3.0; extra == 'local'
65
65
  Requires-Dist: openpyxl>=3.1.5; extra == 'local'
@@ -81,7 +81,7 @@ 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'
84
+ Requires-Dist: mostlyai-engine[gpu]==1.3.3; extra == 'local-gpu'
85
85
  Requires-Dist: mostlyai-qa==1.7.0; 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'
@@ -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.5.7" # 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,
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mostlyai"
3
- version = "4.5.6"
3
+ version = "4.5.7"
4
4
  description = "Synthetic Data SDK"
5
5
  authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
6
6
  requires-python = ">=3.10,<3.14"
@@ -49,7 +49,7 @@ 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
52
+ "mostlyai-engine==1.3.3", # for release
53
53
  "mostlyai-qa==1.7.0", # for release
54
54
  "fastapi>=0.115.6,<0.116",
55
55
  "uvicorn>=0.34.0,<0.35",
@@ -75,7 +75,7 @@ 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
78
+ "mostlyai-engine[gpu]==1.3.3", # for release
79
79
  "mostlyai-qa==1.7.0", # for release
80
80
  "fastapi>=0.115.6,<0.116",
81
81
  "uvicorn>=0.34.0,<0.35",
File without changes
File without changes
File without changes