mostlyai 4.0.5__tar.gz → 4.1.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 (84) hide show
  1. {mostlyai-4.0.5 → mostlyai-4.1.0}/PKG-INFO +31 -32
  2. {mostlyai-4.0.5 → mostlyai-4.1.0}/README.md +6 -4
  3. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/__init__.py +1 -1
  4. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/container/azure.py +4 -1
  5. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/jobs.py +1 -1
  6. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/generators.py +38 -1
  7. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/routes.py +13 -15
  8. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/synthetic_datasets.py +28 -20
  9. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/client/base.py +5 -5
  10. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/domain.py +214 -37
  11. {mostlyai-4.0.5 → mostlyai-4.1.0}/pyproject.toml +33 -29
  12. {mostlyai-4.0.5 → mostlyai-4.1.0}/.gitignore +0 -0
  13. {mostlyai-4.0.5 → mostlyai-4.1.0}/LICENSE +0 -0
  14. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/__init__.py +0 -0
  15. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/auto_detect.py +0 -0
  16. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/base.py +0 -0
  17. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/context.py +0 -0
  18. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/conversions.py +0 -0
  19. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/__init__.py +0 -0
  20. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/base.py +0 -0
  21. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/bigquery.py +0 -0
  22. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/databricks.py +0 -0
  23. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/hive.py +0 -0
  24. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/mssql.py +0 -0
  25. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/mysql.py +0 -0
  26. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/oracle.py +0 -0
  27. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/postgresql.py +0 -0
  28. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/snowflake.py +0 -0
  29. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/sqlite.py +0 -0
  30. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
  31. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/dtype.py +0 -0
  32. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/exceptions.py +0 -0
  33. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/__init__.py +0 -0
  34. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/base.py +0 -0
  35. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
  36. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/container/aws.py +0 -0
  37. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
  38. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
  39. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/container/minio.py +0 -0
  40. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
  41. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/table/csv.py +0 -0
  42. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/table/feather.py +0 -0
  43. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/table/json.py +0 -0
  44. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
  45. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/file/utils.py +0 -0
  46. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/language_model.py +0 -0
  47. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/metadata_objects.py +0 -0
  48. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/non_context.py +0 -0
  49. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/progress_callback.py +0 -0
  50. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/pull.py +0 -0
  51. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/pull_context.py +0 -0
  52. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/pull_utils.py +0 -0
  53. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/push.py +0 -0
  54. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/util/__init__.py +0 -0
  55. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/util/common.py +0 -0
  56. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_data/util/kerberos.py +0 -0
  57. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/__init__.py +0 -0
  58. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/cli.py +0 -0
  59. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/connectors.py +0 -0
  60. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/__init__.py +0 -0
  61. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/plan.py +0 -0
  62. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
  63. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
  64. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
  65. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
  66. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
  67. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
  68. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
  69. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
  70. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
  71. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
  72. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
  73. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/progress.py +0 -0
  74. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/server.py +0 -0
  75. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/_local/storage.py +0 -0
  76. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/client/__init__.py +0 -0
  77. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/client/_base_utils.py +0 -0
  78. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/client/_naming_conventions.py +0 -0
  79. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/client/_utils.py +0 -0
  80. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/client/api.py +0 -0
  81. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/client/connectors.py +0 -0
  82. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/client/exceptions.py +0 -0
  83. {mostlyai-4.0.5 → mostlyai-4.1.0}/mostlyai/sdk/client/generators.py +0 -0
  84. {mostlyai-4.0.5 → mostlyai-4.1.0}/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.0.5
3
+ Version: 4.1.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
@@ -23,40 +23,35 @@ Classifier: Programming Language :: Python :: 3.12
23
23
  Classifier: Programming Language :: Python :: 3.13
24
24
  Classifier: Topic :: Software Development :: Libraries
25
25
  Classifier: Typing :: Typed
26
- Requires-Python: >=3.10
26
+ Requires-Python: <3.14,>=3.10
27
27
  Requires-Dist: adlfs<2024,>=2023.4.0
28
28
  Requires-Dist: azure-storage-blob<13,>=12.16.0
29
29
  Requires-Dist: cloudpathlib[azure,gs,s3]<0.18,>=0.17.0
30
- Requires-Dist: cryptography<44,>=43.0.1
31
- Requires-Dist: environs<10,>=9.5.0
32
- Requires-Dist: fastparquet<2024,>=2023.4.0
30
+ Requires-Dist: environs>=9.5.0
33
31
  Requires-Dist: filelock>=3.16.1
34
32
  Requires-Dist: gcsfs<2024,>=2023.1.0
35
- Requires-Dist: gputil<2,>=1.4.0
36
33
  Requires-Dist: greenlet<4,>=3.1.1
37
- Requires-Dist: gunicorn<24,>=23.0.0
38
- Requires-Dist: httpx<0.28.0,>=0.25.0
39
- Requires-Dist: joblib<2,>=1.2.0
40
- Requires-Dist: networkx~=3.1
34
+ Requires-Dist: gunicorn>=23.0.0
35
+ Requires-Dist: httpx>=0.25.0
36
+ Requires-Dist: joblib>=1.2.0
41
37
  Requires-Dist: openpyxl>=3.1.5
42
- Requires-Dist: pandas<3,>=1.5.3
43
- Requires-Dist: psutil<6,>=5.9.5
38
+ Requires-Dist: pandas>=2.0.0
39
+ Requires-Dist: psutil>=5.9.5
44
40
  Requires-Dist: pyarrow>=16.0.0
45
- Requires-Dist: pycryptodomex<4,>=3.20.0
41
+ Requires-Dist: pycryptodomex<4,>=3.10.0
46
42
  Requires-Dist: pydantic<3,>=2.4.2
47
- Requires-Dist: pydot<2,>=1.4.2
48
- Requires-Dist: requests<3,>=2.31.0
43
+ Requires-Dist: requests>=2.31.0
49
44
  Requires-Dist: rich>=13.7.0
50
45
  Requires-Dist: s3fs<2024,>=2023.1.0
51
- Requires-Dist: schema<0.8,>=0.7.5
52
- Requires-Dist: semantic-version<3,>=2.10.0
46
+ Requires-Dist: schema>=0.7.5
47
+ Requires-Dist: semantic-version>=2.10.0
53
48
  Requires-Dist: smart-open>=6.0.0
54
49
  Requires-Dist: smart-open[azure,gcs,s3]<7,>=6.3.0
55
- Requires-Dist: sqlalchemy<3,>=2.0.0
50
+ Requires-Dist: sqlalchemy>=2.0.0
56
51
  Requires-Dist: sshtunnel<0.5,>=0.4.0
57
- Requires-Dist: typer<0.10,>=0.9.0
52
+ Requires-Dist: typer>=0.9.0
58
53
  Requires-Dist: xlsxwriter<4,>=3.1.9
59
- Requires-Dist: xxhash<4,>=3.2.0
54
+ Requires-Dist: xxhash>=3.2.0
60
55
  Provides-Extra: databricks
61
56
  Requires-Dist: databricks-sql-connector<4,>=3.2.0; extra == 'databricks'
62
57
  Provides-Extra: googlebigquery
@@ -67,23 +62,25 @@ Requires-Dist: kerberos<2,>=1.3.1; extra == 'hive'
67
62
  Requires-Dist: pyhive[hive-pure-sasl]<0.8,>=0.7.0; extra == 'hive'
68
63
  Provides-Extra: local
69
64
  Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local'
70
- Requires-Dist: mostlyai-engine==1.0.2; extra == 'local'
71
- Requires-Dist: mostlyai-qa==1.5.1; extra == 'local'
65
+ Requires-Dist: mostlyai-engine==1.0.4; extra == 'local'
66
+ Requires-Dist: mostlyai-qa==1.5.3; extra == 'local'
72
67
  Requires-Dist: python-multipart>=0.0.20; extra == 'local'
68
+ Requires-Dist: torch<2.6.0,>=2.5.1; extra == 'local'
73
69
  Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local'
74
70
  Provides-Extra: local-cpu
75
71
  Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-cpu'
76
- Requires-Dist: mostlyai-engine[cpu]==1.0.2; extra == 'local-cpu'
77
- Requires-Dist: mostlyai-qa==1.5.1; extra == 'local-cpu'
72
+ Requires-Dist: mostlyai-engine[cpu]==1.0.4; extra == 'local-cpu'
73
+ Requires-Dist: mostlyai-qa[cpu]==1.5.3; extra == 'local-cpu'
78
74
  Requires-Dist: python-multipart>=0.0.20; extra == 'local-cpu'
79
- Requires-Dist: torch>=2.5.1; extra == 'local-cpu'
75
+ Requires-Dist: torch<2.6.0,>=2.5.1; (sys_platform != 'linux') and extra == 'local-cpu'
76
+ Requires-Dist: torch==2.5.1+cpu; (sys_platform == 'linux') and extra == 'local-cpu'
80
77
  Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local-cpu'
81
78
  Provides-Extra: local-gpu
82
79
  Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-gpu'
83
- Requires-Dist: mostlyai-engine[gpu]==1.0.2; extra == 'local-gpu'
84
- Requires-Dist: mostlyai-qa==1.5.1; extra == 'local-gpu'
80
+ Requires-Dist: mostlyai-engine[gpu]==1.0.4; extra == 'local-gpu'
81
+ Requires-Dist: mostlyai-qa[gpu]==1.5.3; extra == 'local-gpu'
85
82
  Requires-Dist: python-multipart>=0.0.20; extra == 'local-gpu'
86
- Requires-Dist: torch>=2.5.1; extra == 'local-gpu'
83
+ Requires-Dist: torch<2.6.0,>=2.5.1; extra == 'local-gpu'
87
84
  Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local-gpu'
88
85
  Provides-Extra: mssql
89
86
  Requires-Dist: pyodbc<6,>=5.1.0; extra == 'mssql'
@@ -136,12 +133,14 @@ pip install -U mostlyai
136
133
  **Client + Local mode**
137
134
 
138
135
  ```shell
139
- pip install -U 'mostlyai[local]' # for CPU
140
- #pip install -U 'mostlyai[local-gpu]' # for GPU
136
+ # for CPU on macOS
137
+ pip install -U 'mostlyai[local]'
138
+ # for CPU on Linux
139
+ #pip install -U mostlyai[local] --extra-index-url https://download.pytorch.org/whl/cpu
140
+ # for GPU on Linux
141
+ #pip install -U mostlyai[local-gpu]
141
142
  ```
142
143
 
143
- NOTE: installing `mostlyai[local]` on Linux requires `--extra-index-url https://download.pytorch.org/whl/cpu` to be specified.
144
-
145
144
  **Optional Connectors**
146
145
 
147
146
  Add any of the following extras for further data connectors support: `databricks`, `googlebigquery`, `hive`, `mssql`, `mysql`, `oracle`, `postgres`, `snowflake`.
@@ -37,12 +37,14 @@ pip install -U mostlyai
37
37
  **Client + Local mode**
38
38
 
39
39
  ```shell
40
- pip install -U 'mostlyai[local]' # for CPU
41
- #pip install -U 'mostlyai[local-gpu]' # for GPU
40
+ # for CPU on macOS
41
+ pip install -U 'mostlyai[local]'
42
+ # for CPU on Linux
43
+ #pip install -U mostlyai[local] --extra-index-url https://download.pytorch.org/whl/cpu
44
+ # for GPU on Linux
45
+ #pip install -U mostlyai[local-gpu]
42
46
  ```
43
47
 
44
- NOTE: installing `mostlyai[local]` on Linux requires `--extra-index-url https://download.pytorch.org/whl/cpu` to be specified.
45
-
46
48
  **Optional Connectors**
47
49
 
48
50
  Add any of the following extras for further data connectors support: `databricks`, `googlebigquery`, `hive`, `mssql`, `mysql`, `oracle`, `postgres`, `snowflake`.
@@ -15,4 +15,4 @@
15
15
  from mostlyai.sdk.client.api import MostlyAI
16
16
 
17
17
  __all__ = ["MostlyAI"]
18
- __version__ = "4.0.5" # Do not set this manually. Use poetry version [params].
18
+ __version__ = "4.1.0" # Do not set this manually. Use poetry version [params].
@@ -76,6 +76,7 @@ class AzureBlobFileContainer(BucketBasedContainer):
76
76
  self._blob_service_client = BlobServiceClient(
77
77
  account_url=f"https://{self.account_name}.blob.core.windows.net",
78
78
  credential=credential,
79
+ retry_total=0, # disable retry so that we won't timeout when credentials are incorrect
79
80
  )
80
81
 
81
82
  @classmethod
@@ -96,7 +97,7 @@ class AzureBlobFileContainer(BucketBasedContainer):
96
97
 
97
98
  def _check_authenticity(self) -> bool:
98
99
  try:
99
- return self.fs.ls("") is not None
100
+ return self._blob_service_client.get_account_information() is not None
100
101
  except Exception as e:
101
102
  error_message = str(e).lower()
102
103
  if any(
@@ -105,6 +106,8 @@ class AzureBlobFileContainer(BucketBasedContainer):
105
106
  "cannot connect to host",
106
107
  "account is disabled",
107
108
  "error on post request",
109
+ "nodename nor servname provided",
110
+ "failed to resolve",
108
111
  ]
109
112
  ):
110
113
  raise MostlyDataException("Account name is incorrect.")
@@ -170,7 +170,7 @@ def _set_overall_accuracy(generator: Generator) -> None:
170
170
 
171
171
  def _probe_random_samples(home_dir: Path, generator: Generator) -> None:
172
172
  config = SyntheticProbeConfig(generator_id=generator.id)
173
- synthetic_dataset = create_synthetic_dataset(home_dir=home_dir, config=config, size=20)
173
+ synthetic_dataset = create_synthetic_dataset(home_dir=home_dir, config=config, sample_size=20)
174
174
  probes = execute_probing_job(synthetic_dataset_id=synthetic_dataset.id, home_dir=home_dir)
175
175
 
176
176
  random_samples_dir = home_dir / "generators" / generator.id / "RandomSamples"
@@ -14,7 +14,12 @@
14
14
 
15
15
  from pathlib import Path
16
16
 
17
- from mostlyai.sdk._local.storage import write_generator_to_json, write_connector_to_json, write_job_progress_to_json
17
+ from mostlyai.sdk._local.storage import (
18
+ write_generator_to_json,
19
+ write_connector_to_json,
20
+ write_job_progress_to_json,
21
+ read_generator_from_json,
22
+ )
18
23
  from mostlyai.sdk._local.execution.plan import has_tabular_model, has_language_model, TRAINING_TASK_STEPS
19
24
  from mostlyai.sdk.client._base_utils import convert_to_df
20
25
  from mostlyai.sdk.domain import (
@@ -30,6 +35,8 @@ from mostlyai.sdk.domain import (
30
35
  ProgressValue,
31
36
  JobProgress,
32
37
  TaskType,
38
+ SourceTableConfig,
39
+ SourceForeignKeyConfig,
33
40
  )
34
41
 
35
42
 
@@ -108,3 +115,33 @@ def create_generator(home_dir: Path, config: GeneratorConfig) -> Generator:
108
115
  write_job_progress_to_json(generator_dir, job_progress)
109
116
 
110
117
  return generator
118
+
119
+
120
+ def get_generator_config(home_dir: Path, generator_id: str) -> GeneratorConfig:
121
+ generator_dir = home_dir / "generators" / generator_id
122
+ generator = read_generator_from_json(generator_dir)
123
+ # construct GeneratorConfig explicitly to avoid validation warnings of extra fields
124
+ config = GeneratorConfig(
125
+ name=generator.name,
126
+ description=generator.description,
127
+ tables=[
128
+ SourceTableConfig(
129
+ name=t.name,
130
+ source_connector_id=t.source_connector_id,
131
+ location=t.location,
132
+ tabular_model_configuration=t.tabular_model_configuration,
133
+ language_model_configuration=t.language_model_configuration,
134
+ primary_key=t.primary_key,
135
+ foreign_keys=[SourceForeignKeyConfig.model_construct(**k.model_dump()) for k in t.foreign_keys]
136
+ if t.foreign_keys
137
+ else None,
138
+ columns=[SourceColumnConfig.model_construct(**c.model_dump()) for c in t.columns]
139
+ if t.columns
140
+ else None,
141
+ )
142
+ for t in generator.tables
143
+ ]
144
+ if generator.tables
145
+ else None,
146
+ )
147
+ return config
@@ -54,6 +54,7 @@ from mostlyai.sdk.domain import (
54
54
  GeneratorCloneConfig,
55
55
  GeneratorCloneTrainingStatus,
56
56
  SyntheticDatasetReportType,
57
+ SyntheticDatasetListItem,
57
58
  )
58
59
  from mostlyai.sdk._local.storage import (
59
60
  read_generator_from_json,
@@ -183,7 +184,8 @@ class Routes:
183
184
  connector = read_connector_from_json(connector_dir)
184
185
  if not searchTerm or searchTerm.lower() in (connector.name or "").lower():
185
186
  if not access_type or access_type == connector.access_type:
186
- connector_list_items.append(ConnectorListItem(**connector.model_dump()))
187
+ # use model_construct to skip validation and warnings of extra fields
188
+ connector_list_items.append(ConnectorListItem.model_construct(**connector.model_dump()))
187
189
 
188
190
  # use jsonable_encoder to handle non-serializable objects like datetime
189
191
  return JSONResponse(
@@ -278,7 +280,8 @@ class Routes:
278
280
  or searchTerm.lower() in (generator.description or "").lower()
279
281
  ):
280
282
  if not status or status == generator.training_status:
281
- generator_list_items.append(GeneratorListItem(**generator.model_dump()))
283
+ # use model_construct to skip validation and warnings of extra fields
284
+ generator_list_items.append(GeneratorListItem.model_construct(**generator.model_dump()))
282
285
  # use jsonable_encoder to handle non-serializable objects like datetime
283
286
  return JSONResponse(
284
287
  status_code=200,
@@ -338,10 +341,8 @@ class Routes:
338
341
  # check if any connectors are file upload
339
342
  if any(read_connector_from_json(c).type == ConnectorType.file_upload for c in connector_dirs):
340
343
  raise HTTPException(status_code=400, detail="Cannot clone a generator with uploaded files.")
341
-
342
- new_generator = create_generator_model(
343
- home_dir=self.home_dir, config=GeneratorConfig(**generator.model_dump())
344
- )
344
+ generator_config = generators.get_generator_config(self.home_dir, id)
345
+ new_generator = create_generator_model(home_dir=self.home_dir, config=generator_config)
345
346
  new_generator_dir = self.home_dir / "generators" / new_generator.id
346
347
  if config.training_status == GeneratorCloneTrainingStatus.continue_:
347
348
  new_generator.training_status = ProgressStatus.continue_
@@ -410,10 +411,7 @@ class Routes:
410
411
 
411
412
  @self.router.get("/generators/{id}/config", response_model=GeneratorConfig)
412
413
  async def get_generator_config(id: str) -> GeneratorConfig:
413
- generator_dir = self.home_dir / "generators" / id
414
- generator = read_generator_from_json(generator_dir)
415
- config = GeneratorConfig(**generator.model_dump())
416
- return config
414
+ return generators.get_generator_config(self.home_dir, id)
417
415
 
418
416
  ### SYNTHETIC DATASETS
419
417
 
@@ -431,7 +429,10 @@ class Routes:
431
429
  or searchTerm.lower() in (synthetic_dataset.description or "").lower()
432
430
  ):
433
431
  if not status or status == synthetic_dataset.generation_status:
434
- synthetic_dataset_list_items.append(SyntheticDataset(**synthetic_dataset.model_dump()))
432
+ # use model_construct to skip validation and warnings of extra fields
433
+ synthetic_dataset_list_items.append(
434
+ SyntheticDatasetListItem.model_construct(**synthetic_dataset.model_dump())
435
+ )
435
436
  # use jsonable_encoder to handle non-serializable objects like datetime
436
437
  return JSONResponse(
437
438
  status_code=200,
@@ -505,10 +506,7 @@ class Routes:
505
506
 
506
507
  @self.router.get("/synthetic-datasets/{id}/config", response_model=SyntheticDatasetConfig)
507
508
  async def get_synthetic_dataset_config(id: str) -> SyntheticDatasetConfig:
508
- synthetic_dataset_dir = self.home_dir / "synthetic-datasets" / id
509
- synthetic_dataset = read_synthetic_dataset_from_json(synthetic_dataset_dir)
510
- config = SyntheticDatasetConfig(**synthetic_dataset.model_dump())
511
- return config
509
+ return synthetic_datasets.get_synthetic_dataset_config(self.home_dir, id)
512
510
 
513
511
  @self.router.get("/synthetic-datasets/{id}/download", response_class=FileResponse)
514
512
  async def download_synthetic_dataset(id: str, slft: str, format: str) -> FileResponse:
@@ -19,6 +19,7 @@ from mostlyai.sdk._local.storage import (
19
19
  write_job_progress_to_json,
20
20
  read_generator_from_json,
21
21
  write_connector_to_json,
22
+ read_synthetic_dataset_from_json,
22
23
  )
23
24
  from mostlyai.sdk._local.execution.plan import (
24
25
  has_tabular_model,
@@ -36,19 +37,19 @@ from mostlyai.sdk.domain import (
36
37
  ProgressValue,
37
38
  JobProgress,
38
39
  SyntheticTable,
39
- SyntheticTableConfiguration,
40
40
  TaskType,
41
41
  Connector,
42
42
  ConnectorType,
43
43
  ConnectorAccessType,
44
44
  SyntheticProbeConfig,
45
+ SyntheticTableConfig,
45
46
  )
46
47
 
47
48
 
48
49
  def create_synthetic_dataset(
49
50
  home_dir: Path,
50
51
  config: SyntheticDatasetConfig | SyntheticProbeConfig,
51
- size: int | dict[str, int] | None = None,
52
+ sample_size: int | None = None,
52
53
  ) -> SyntheticDataset:
53
54
  # create a FILE_UPLOAD connector and replace sample_seed_dict/sample_seed_data with sample_seed_connector_id
54
55
  for t in config.tables or []:
@@ -77,30 +78,21 @@ def create_synthetic_dataset(
77
78
  generator_dir = home_dir / "generators" / config.generator_id
78
79
  generator = read_generator_from_json(generator_dir)
79
80
 
80
- # fill sample sizes
81
- # if there's a seed (sample_seed_connector_id is set), sample size will be ignored by the engine
82
- size = size if size is not None else {}
81
+ # validate & fill defaults in config against generator
82
+ config.validate_against_generator(generator)
83
+
84
+ # create synthetic tables
83
85
  sd_tables = []
84
86
  for g_table in generator.tables:
85
- if g_table.name in (t.name for t in (config.tables or [])):
86
- sd_table = SyntheticTable(**next(t for t in config.tables if t.name == g_table.name).model_dump())
87
- else:
88
- sd_table = SyntheticTable(name=g_table.name)
87
+ sd_table = SyntheticTable(**next(t for t in config.tables if t.name == g_table.name).model_dump())
89
88
  sd_table.foreign_keys = g_table.foreign_keys
90
89
  sd_table.source_table_total_rows = g_table.total_rows
91
- if sd_table.configuration is None:
92
- sd_table.configuration = SyntheticTableConfiguration()
93
- is_subject = not any(fk.is_context for fk in g_table.foreign_keys or [])
94
- if is_subject and sd_table.configuration.sample_size is None:
95
- if isinstance(size, int):
96
- sd_table.configuration.sample_size = size
97
- else: # isinstance(size, dict)
98
- default_sample_size = 1 if isinstance(config, SyntheticProbeConfig) else g_table.total_rows
99
- sd_table.configuration.sample_size = size.get(g_table.name, default_sample_size)
100
- elif not is_subject:
101
- sd_table.configuration.sample_size = None # sample size is not applicable to linked tables
102
90
  sd_table.tabular_model_metrics = g_table.tabular_model_metrics
103
91
  sd_table.language_model_metrics = g_table.language_model_metrics
92
+ # overwrite sample size of subject table, if provided
93
+ is_subject = not any(fk.is_context for fk in g_table.foreign_keys or [])
94
+ if is_subject and sample_size is not None:
95
+ sd_table.configuration.sample_size = sample_size
104
96
  sd_tables.append(sd_table)
105
97
 
106
98
  # create synthetic dataset
@@ -161,3 +153,19 @@ def create_synthetic_dataset(
161
153
  )
162
154
  write_job_progress_to_json(synthetic_dataset_dir, job_progress)
163
155
  return synthetic_dataset
156
+
157
+
158
+ def get_synthetic_dataset_config(home_dir: Path, synthetic_dataset_id: str) -> SyntheticDatasetConfig:
159
+ synthetic_dataset_dir = home_dir / "synthetic-datasets" / synthetic_dataset_id
160
+ synthetic_dataset = read_synthetic_dataset_from_json(synthetic_dataset_dir)
161
+ # construct SyntheticDatasetConfig explicitly to avoid validation warnings of extra fields
162
+ config = SyntheticDatasetConfig(
163
+ generator_id=synthetic_dataset.generator_id,
164
+ name=synthetic_dataset.name,
165
+ description=synthetic_dataset.description,
166
+ tables=[SyntheticTableConfig.model_construct(**t.model_dump()) for t in synthetic_dataset.tables]
167
+ if synthetic_dataset.tables
168
+ else None,
169
+ delivery=synthetic_dataset.delivery,
170
+ )
171
+ return config
@@ -221,7 +221,7 @@ class Paginator(Generic[T]):
221
221
  item = self.page_items[self.index_in_page]
222
222
  self.index_in_page += 1
223
223
  self.index += 1
224
- return self.response_class(**item, client=self.client, by_alias=True)
224
+ return self.response_class(**item, client=self.client)
225
225
 
226
226
  def _fetch_page(self):
227
227
  if self.is_last_page:
@@ -247,10 +247,10 @@ class CustomBaseModel(BaseModel):
247
247
 
248
248
  @model_validator(mode="before")
249
249
  def __warn_extra_fields__(cls, values):
250
- extra_fields = values.keys() - cls.model_fields.keys() - {v.alias for v in cls.model_fields.values()}
251
- if extra_fields:
252
- _LOG.warning(f"ignoring unrecognized fields for {cls.__name__}: {', '.join(extra_fields)}")
253
-
250
+ if isinstance(values, dict):
251
+ extra_fields = values.keys() - cls.model_fields.keys() - {v.alias for v in cls.model_fields.values()}
252
+ if extra_fields:
253
+ _LOG.warning(f"ignoring unrecognized fields for {cls.__name__}: {', '.join(extra_fields)}")
254
254
  return values
255
255
 
256
256
  def _repr_html_(self):
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  # generated by datamodel-codegen:
16
- # timestamp: 2025-01-23T22:58:04+00:00
16
+ # timestamp: 2025-02-05T16:23:28+00:00
17
17
 
18
18
  from __future__ import annotations
19
19
 
@@ -37,7 +37,7 @@ class AboutService(CustomBaseModel):
37
37
  General information about the service.
38
38
  """
39
39
 
40
- version: str | None = Field(None, description="The version number of the service.", examples=["v209"])
40
+ version: str | None = Field(None, description="The version number of the service.", examples=["4.0.0"])
41
41
  assistant: bool | None = Field(None, description="A flag indicating if the assistant is enabled.")
42
42
 
43
43
 
@@ -406,8 +406,9 @@ class SourceForeignKey(CustomBaseModel):
406
406
  @model_validator(mode="before")
407
407
  @classmethod
408
408
  def add_required_fields(cls, values):
409
- if "id" not in values:
410
- values["id"] = str(uuid.uuid4())
409
+ if isinstance(values, dict):
410
+ if "id" not in values:
411
+ values["id"] = str(uuid.uuid4())
411
412
  return values
412
413
 
413
414
 
@@ -838,6 +839,11 @@ class OrganizationListItem(CustomBaseModel):
838
839
  """
839
840
 
840
841
  id: str = Field(..., description="The unique identifier of an organization.")
842
+ name: str | None = Field(
843
+ None,
844
+ 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",
845
+ max_length=64,
846
+ )
841
847
  display_name: str = Field(..., alias="displayName", description="The display name of an organization.")
842
848
  description: str | None = Field(None, description="The description of an organization. Supports markdown.")
843
849
  logo: AnyUrl | None = Field(None, description="The URL of the organization's logo.")
@@ -1493,8 +1499,9 @@ class Connector(CustomBaseModel):
1493
1499
  @model_validator(mode="before")
1494
1500
  @classmethod
1495
1501
  def add_required_fields(cls, values):
1496
- if "id" not in values:
1497
- values["id"] = str(uuid.uuid4())
1502
+ if isinstance(values, dict):
1503
+ if "id" not in values:
1504
+ values["id"] = str(uuid.uuid4())
1498
1505
  return values
1499
1506
 
1500
1507
  def update(
@@ -1599,6 +1606,10 @@ class GeneratorListItem(CustomBaseModel):
1599
1606
  )
1600
1607
  usage: GeneratorUsage | None = None
1601
1608
  metadata: Metadata | None = None
1609
+ accuracy: float | None = Field(
1610
+ None,
1611
+ description="The overall accuracy of the trained generator.\nThis is the average of the overall accuracy scores of all trained models.\n",
1612
+ )
1602
1613
  OPEN_URL_PARTS: ClassVar[list] = ["d", "generators"]
1603
1614
 
1604
1615
  def __getattr__(self, item):
@@ -1645,12 +1656,13 @@ class SourceColumn(CustomBaseModel):
1645
1656
  @model_validator(mode="before")
1646
1657
  @classmethod
1647
1658
  def add_required_fields(cls, values):
1648
- if "id" not in values:
1649
- values["id"] = str(uuid.uuid4())
1650
- if "model_encoding_type" not in values:
1651
- values["model_encoding_type"] = ModelEncodingType.auto
1652
- if "included" not in values:
1653
- values["included"] = True
1659
+ if isinstance(values, dict):
1660
+ if "id" not in values:
1661
+ values["id"] = str(uuid.uuid4())
1662
+ if "model_encoding_type" not in values:
1663
+ values["model_encoding_type"] = ModelEncodingType.auto
1664
+ if "included" not in values:
1665
+ values["included"] = True
1654
1666
  return values
1655
1667
 
1656
1668
 
@@ -1802,15 +1814,15 @@ class ProgressStep(CustomBaseModel):
1802
1814
  progress: ProgressValue | None = None
1803
1815
  status: ProgressStatus | None = None
1804
1816
 
1805
- @model_validator(mode="before")
1817
+ @model_validator(mode="after")
1806
1818
  @classmethod
1807
1819
  def add_required_fields(cls, values):
1808
- if "id" not in values:
1809
- values["id"] = str(uuid.uuid4())
1810
- if "status" not in values:
1811
- values["status"] = ProgressStatus.new
1812
- if "compute_name" not in values:
1813
- values["compute_name"] = "SDK"
1820
+ if values.id is None:
1821
+ values.id = str(uuid.uuid4())
1822
+ if values.status is None:
1823
+ values.status = ProgressStatus.new
1824
+ if values.compute_name is None:
1825
+ values.compute_name = "SDK"
1814
1826
  return values
1815
1827
 
1816
1828
 
@@ -1854,7 +1866,7 @@ class SyntheticTableConfiguration(CustomBaseModel):
1854
1866
  sample_size: int | None = Field(
1855
1867
  None,
1856
1868
  alias="sampleSize",
1857
- description="Number of generated samples. Only applicable for subject tables.\nIf neither size nor seed is provided, then the default behavior for Synthetic Datasets is to generate the\nsame size of samples as the original, and the default behavior for Synthetic Datasets is to generate one\nsubject only.\n",
1869
+ description="Number of generated samples. Only applicable for subject tables.\nIf neither size nor seed is provided, then the default behavior for Synthetic Datasets is to generate the\nsame size of samples as the original, and the default behavior for Synthetic Probes is to generate one\nsubject only.\n",
1858
1870
  ge=1,
1859
1871
  )
1860
1872
  sample_seed_connector_id: str | None = Field(
@@ -1904,13 +1916,13 @@ class SyntheticTableConfiguration(CustomBaseModel):
1904
1916
  def convert_data_before(cls, value):
1905
1917
  return convert_to_base64(value) if isinstance(value, pd.DataFrame) else value
1906
1918
 
1907
- @model_validator(mode="before")
1919
+ @model_validator(mode="after")
1908
1920
  @classmethod
1909
1921
  def add_required_fields(cls, values):
1910
- if "sampling_temperature" not in values or values["sampling_temperature"] is None:
1911
- values["sampling_temperature"] = 1.0
1912
- if "sampling_top_p" not in values or values["sampling_top_p"] is None:
1913
- values["sampling_top_p"] = 1.0
1922
+ if values.sampling_temperature is None:
1923
+ values.sampling_temperature = 1.0
1924
+ if values.sampling_top_p is None:
1925
+ values.sampling_top_p = 1.0
1914
1926
  return values
1915
1927
 
1916
1928
 
@@ -1933,6 +1945,29 @@ class SyntheticTableConfig(CustomBaseModel):
1933
1945
  )
1934
1946
  configuration: SyntheticTableConfiguration | None = None
1935
1947
 
1948
+ @model_validator(mode="after")
1949
+ @classmethod
1950
+ def add_configuration(cls, values):
1951
+ if values.configuration is None:
1952
+ values.configuration = SyntheticTableConfiguration()
1953
+ return values
1954
+
1955
+ def validate_against_source_table(self, source_table: SourceTable, is_probe: bool) -> None:
1956
+ self._maybe_set_sample_size(source_table, is_probe)
1957
+ _SyntheticTableConfigValidation(synthetic_table=self, source_table=source_table)
1958
+
1959
+ def _maybe_set_sample_size(self, source_table: SourceTable, is_probe: bool) -> None:
1960
+ config = self.configuration
1961
+ is_subject = not any(fk.is_context for fk in source_table.foreign_keys or [])
1962
+ if (
1963
+ not config.sample_size
1964
+ and is_subject
1965
+ and not (config.sample_seed_connector_id or config.sample_seed_dict or config.sample_seed_data)
1966
+ ):
1967
+ config.sample_size = 1 if is_probe else source_table.total_rows
1968
+ elif not is_subject:
1969
+ config.sample_size = None
1970
+
1936
1971
 
1937
1972
  class AssistantThreadListItem(CustomBaseModel):
1938
1973
  """
@@ -2049,8 +2084,9 @@ class SourceTable(CustomBaseModel):
2049
2084
  @model_validator(mode="before")
2050
2085
  @classmethod
2051
2086
  def add_required_fields(cls, values):
2052
- if "id" not in values:
2053
- values["id"] = str(uuid.uuid4())
2087
+ if isinstance(values, dict):
2088
+ if "id" not in values:
2089
+ values["id"] = str(uuid.uuid4())
2054
2090
  return values
2055
2091
 
2056
2092
 
@@ -2274,8 +2310,9 @@ class SyntheticTable(CustomBaseModel):
2274
2310
  @model_validator(mode="before")
2275
2311
  @classmethod
2276
2312
  def add_required_fields(cls, values):
2277
- if "id" not in values:
2278
- values["id"] = str(uuid.uuid4())
2313
+ if isinstance(values, dict):
2314
+ if "id" not in values:
2315
+ values["id"] = str(uuid.uuid4())
2279
2316
  return values
2280
2317
 
2281
2318
 
@@ -2290,6 +2327,19 @@ class SyntheticDatasetConfig(CustomBaseModel):
2290
2327
  tables: list[SyntheticTableConfig] | None = None
2291
2328
  delivery: SyntheticDatasetDelivery | None = None
2292
2329
 
2330
+ @field_validator("tables", mode="after")
2331
+ @classmethod
2332
+ def validate_unique_table_names(cls, tables):
2333
+ if not tables:
2334
+ return tables
2335
+ defined_tables = [t.name for t in tables]
2336
+ if len(defined_tables) != len(set(defined_tables)):
2337
+ raise ValueError("Table names must be unique.")
2338
+ return tables
2339
+
2340
+ def validate_against_generator(self, generator: Generator) -> None:
2341
+ _SyntheticDataConfigValidation(synthetic_config=self, generator=generator)
2342
+
2293
2343
 
2294
2344
  class SyntheticProbeConfig(CustomBaseModel):
2295
2345
  """
@@ -2299,6 +2349,19 @@ class SyntheticProbeConfig(CustomBaseModel):
2299
2349
  generator_id: str | None = Field(None, alias="generatorId", description="The unique identifier of a generator.")
2300
2350
  tables: list[SyntheticTableConfig] | None = None
2301
2351
 
2352
+ @field_validator("tables", mode="after")
2353
+ @classmethod
2354
+ def validate_unique_table_names(cls, tables):
2355
+ if not tables:
2356
+ return tables
2357
+ defined_tables = [t.name for t in tables]
2358
+ if len(defined_tables) != len(set(defined_tables)):
2359
+ raise ValueError("Table names must be unique.")
2360
+ return tables
2361
+
2362
+ def validate_against_generator(self, generator: Generator) -> None:
2363
+ _SyntheticDataConfigValidation(synthetic_config=self, generator=generator)
2364
+
2302
2365
 
2303
2366
  class Generator(CustomBaseModel):
2304
2367
  """
@@ -2330,10 +2393,11 @@ class Generator(CustomBaseModel):
2330
2393
  @model_validator(mode="before")
2331
2394
  @classmethod
2332
2395
  def add_required_fields(cls, values):
2333
- if "id" not in values:
2334
- values["id"] = str(uuid.uuid4())
2335
- if "training_status" not in values:
2336
- values["training_status"] = ProgressStatus.new
2396
+ if isinstance(values, dict):
2397
+ if "id" not in values:
2398
+ values["id"] = str(uuid.uuid4())
2399
+ if "training_status" not in values:
2400
+ values["training_status"] = ProgressStatus.new
2337
2401
  return values
2338
2402
 
2339
2403
  def __init__(self, *args, **kwargs):
@@ -2582,10 +2646,11 @@ class SyntheticDataset(CustomBaseModel):
2582
2646
  @model_validator(mode="before")
2583
2647
  @classmethod
2584
2648
  def add_required_fields(cls, values):
2585
- if "id" not in values:
2586
- values["id"] = str(uuid.uuid4())
2587
- if "generation_status" not in values:
2588
- values["generation_status"] = ProgressStatus.new
2649
+ if isinstance(values, dict):
2650
+ if "id" not in values:
2651
+ values["id"] = str(uuid.uuid4())
2652
+ if "generation_status" not in values:
2653
+ values["generation_status"] = ProgressStatus.new
2589
2654
  return values
2590
2655
 
2591
2656
  def __init__(self, *args, **kwargs):
@@ -2769,3 +2834,115 @@ class SyntheticDataset(CustomBaseModel):
2769
2834
  "Use it to consume the generated data. "
2770
2835
  "Publish it so others can do the same."
2771
2836
  )
2837
+
2838
+
2839
+ class _SyntheticTableConfigValidation(CustomBaseModel):
2840
+ """
2841
+ Validation logic for SyntheticTableConfig against SourceTable
2842
+ """
2843
+
2844
+ synthetic_table: SyntheticTableConfig
2845
+ source_table: SourceTable
2846
+
2847
+ @model_validator(mode="after")
2848
+ def validate_rebalancing_config(cls, validation):
2849
+ config = validation.synthetic_table.configuration
2850
+ if config and config.rebalancing:
2851
+ has_tabular_model = validation.source_table.tabular_model_configuration is not None
2852
+ if not has_tabular_model:
2853
+ raise ValueError(
2854
+ f"Table '{validation.source_table.name}' specifies rebalancing but has no tabular model"
2855
+ )
2856
+ rebalancing_column = config.rebalancing.column
2857
+ rebalancing_col = next(
2858
+ (col for col in validation.source_table.columns or [] if col.name == rebalancing_column), None
2859
+ )
2860
+ if not rebalancing_col:
2861
+ raise ValueError(
2862
+ f"Rebalancing column '{rebalancing_column}' not found in table '{validation.source_table.name}'"
2863
+ )
2864
+ if not rebalancing_col.model_encoding_type == ModelEncodingType.tabular_categorical:
2865
+ raise ValueError(
2866
+ f"Rebalancing column '{rebalancing_column}' in table '{validation.source_table.name}' must be categorical"
2867
+ )
2868
+ for value in config.rebalancing.probabilities.keys():
2869
+ if value not in rebalancing_col.value_range.values:
2870
+ raise ValueError(
2871
+ f"Rebalancing value '{value}' not found in table '{validation.source_table.name}' column '{rebalancing_column}'"
2872
+ )
2873
+ return validation
2874
+
2875
+ @model_validator(mode="after")
2876
+ def validate_imputation_config(cls, validation):
2877
+ config = validation.synthetic_table.configuration
2878
+ if config and config.imputation:
2879
+ has_tabular_model = validation.source_table.tabular_model_configuration is not None
2880
+ if not has_tabular_model:
2881
+ raise ValueError(
2882
+ f"Table '{validation.source_table.name}' specifies imputation but has no tabular model"
2883
+ )
2884
+ for col in config.imputation.columns:
2885
+ if not any(gcol.name == col for gcol in validation.source_table.columns or []):
2886
+ raise ValueError(f"Imputation column '{col}' not found in table '{validation.source_table.name}'")
2887
+ return validation
2888
+
2889
+ @model_validator(mode="after")
2890
+ def validate_fairness_config(cls, validation):
2891
+ config = validation.synthetic_table.configuration
2892
+ if config and config.fairness:
2893
+ has_tabular_model = validation.source_table.tabular_model_configuration is not None
2894
+ if not has_tabular_model:
2895
+ raise ValueError(f"Table '{validation.source_table.name}' specifies fairness but has no tabular model")
2896
+ target_col = config.fairness.target_column
2897
+ if not any(col.name == target_col for col in validation.source_table.columns or []):
2898
+ raise ValueError(
2899
+ f"Fairness target column '{target_col}' not found in table '{validation.source_table.name}'"
2900
+ )
2901
+ for col in config.fairness.sensitive_columns:
2902
+ if not any(gcol.name == col for gcol in validation.source_table.columns or []):
2903
+ raise ValueError(
2904
+ f"Fairness sensitive column '{col}' not found in table '{validation.source_table.name}'"
2905
+ )
2906
+ if target_col in config.fairness.sensitive_columns:
2907
+ raise ValueError(f"Target column '{target_col}' cannot be a sensitive column")
2908
+ return validation
2909
+
2910
+
2911
+ class _SyntheticDataConfigValidation(CustomBaseModel):
2912
+ """
2913
+ Validation logic for SyntheticDatasetConfig and SyntheticProbeConfig against Generator
2914
+ """
2915
+
2916
+ synthetic_config: SyntheticDatasetConfig | SyntheticProbeConfig
2917
+ generator: Generator
2918
+
2919
+ @model_validator(mode="after")
2920
+ def add_missing_tables(cls, validation):
2921
+ generator_table_map = {t.name: t for t in validation.generator.tables}
2922
+ if validation.synthetic_config.tables is None:
2923
+ validation.synthetic_config.tables = []
2924
+ synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables}
2925
+ missing_tables = set(generator_table_map.keys()) - set(synthetic_table_map.keys())
2926
+ for t in missing_tables:
2927
+ validation.synthetic_config.tables.append(SyntheticTableConfig(name=t))
2928
+ return validation
2929
+
2930
+ @model_validator(mode="after")
2931
+ def validate_no_extra_tables(cls, validation):
2932
+ generator_table_map = {t.name: t for t in validation.generator.tables}
2933
+ synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
2934
+ extra_tables = set(synthetic_table_map.keys()) - set(generator_table_map.keys())
2935
+ if extra_tables:
2936
+ raise ValueError(f"Extra tables in synthetic config not present in generator: {extra_tables}")
2937
+ return validation
2938
+
2939
+ @model_validator(mode="after")
2940
+ def validate_tables(cls, validation):
2941
+ generator_table_map = {t.name: t for t in validation.generator.tables}
2942
+ synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
2943
+ for table_name, synthetic_table in synthetic_table_map.items():
2944
+ generator_table = generator_table_map[table_name]
2945
+ synthetic_table.validate_against_source_table(
2946
+ generator_table, is_probe=isinstance(validation.synthetic_config, SyntheticProbeConfig)
2947
+ )
2948
+ return validation
@@ -1,9 +1,9 @@
1
1
  [project]
2
2
  name = "mostlyai"
3
- version = "4.0.5"
3
+ version = "4.1.0"
4
4
  description = "Synthetic Data SDK"
5
5
  authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
6
- requires-python = ">=3.10"
6
+ requires-python = ">=3.10,<3.14"
7
7
  readme = "README.md"
8
8
  license = "Apache-2.0"
9
9
  classifiers = [
@@ -25,28 +25,23 @@ classifiers = [
25
25
  ]
26
26
  dependencies = [
27
27
  "pydantic>=2.4.2,<3",
28
- "httpx>=0.25.0,<0.28.0",
29
- "pandas>=1.5.3,<3",
28
+ "httpx>=0.25.0",
29
+ "pandas>=2.0.0",
30
30
  "pyarrow>=16.0.0",
31
31
  "smart_open>=6.0.0",
32
32
  "rich>=13.7.0",
33
- "fastparquet>=2023.4.0,<2024",
34
- "psutil>=5.9.5,<6",
35
- "requests>=2.31.0,<3",
36
- "pydot>=1.4.2,<2",
37
- "sqlalchemy>=2.0.0,<3",
38
- "cryptography>=43.0.1,<44",
39
- "typer>=0.9.0,<0.10",
40
- "semantic-version>=2.10.0,<3",
41
- "joblib>=1.2.0,<2",
42
- "gunicorn>=23.0.0,<24",
43
- "environs>=9.5.0,<10",
44
- "gputil>=1.4.0,<2",
45
- "schema>=0.7.5,<0.8",
46
- "xxhash>=3.2.0,<4",
47
- "networkx~=3.1",
33
+ "psutil>=5.9.5",
34
+ "requests>=2.31.0",
35
+ "sqlalchemy>=2.0.0",
36
+ "typer>=0.9.0",
37
+ "semantic-version>=2.10.0",
38
+ "joblib>=1.2.0",
39
+ "gunicorn>=23.0.0",
40
+ "environs>=9.5.0",
41
+ "schema>=0.7.5",
42
+ "xxhash>=3.2.0",
48
43
  "greenlet>=3.1.1,<4",
49
- "pycryptodomex>=3.20.0,<4",
44
+ "pycryptodomex>=3.10.0,<4",
50
45
  "sshtunnel>=0.4.0,<0.5",
51
46
  "xlsxwriter>=3.1.9,<4",
52
47
  "openpyxl>=3.1.5",
@@ -63,27 +58,29 @@ dependencies = [
63
58
  [project.optional-dependencies]
64
59
  local = [
65
60
  # local
66
- "mostlyai-engine==1.0.2",
67
- "mostlyai-qa==1.5.1",
61
+ "mostlyai-engine==1.0.4",
62
+ "mostlyai-qa==1.5.3",
68
63
  "fastapi>=0.115.6,<0.116",
69
64
  "uvicorn>=0.34.0,<0.35",
70
65
  "python-multipart>=0.0.20",
66
+ "torch>=2.5.1,<2.6.0",
71
67
  ]
72
68
  local-gpu = [
73
- "mostlyai-engine[gpu]==1.0.2",
74
- "mostlyai-qa==1.5.1",
69
+ "mostlyai-engine[gpu]==1.0.4",
70
+ "mostlyai-qa[gpu]==1.5.3",
75
71
  "fastapi>=0.115.6,<0.116",
76
72
  "uvicorn>=0.34.0,<0.35",
77
73
  "python-multipart>=0.0.20",
78
- "torch>=2.5.1",
74
+ "torch>=2.5.1,<2.6.0",
79
75
  ]
80
76
  local-cpu = [
81
- "mostlyai-engine[cpu]==1.0.2",
82
- "mostlyai-qa==1.5.1",
77
+ "mostlyai-engine[cpu]==1.0.4",
78
+ "mostlyai-qa[cpu]==1.5.3",
83
79
  "fastapi>=0.115.6,<0.116",
84
80
  "uvicorn>=0.34.0,<0.35",
85
81
  "python-multipart>=0.0.20",
86
- "torch>=2.5.1",
82
+ "torch==2.5.1+cpu; sys_platform == 'linux'",
83
+ "torch>=2.5.1,<2.6.0; sys_platform != 'linux'",
87
84
  ]
88
85
  # connectors
89
86
  databricks = ["databricks-sql-connector>=3.2.0,<4"]
@@ -110,6 +107,7 @@ dev = [
110
107
  "twine>=6.0.1,<7",
111
108
  "pkginfo>=1.12.0,<2",
112
109
  "poetry-bumpversion>=0.3.2,<0.4",
110
+ "httpx<0.28",
113
111
  ]
114
112
  docs = [
115
113
  "mkdocs>=1.5.3",
@@ -140,9 +138,15 @@ name = "pytorch-cpu"
140
138
  url = "https://download.pytorch.org/whl/cpu"
141
139
  explicit = true
142
140
 
141
+ #[[tool.uv.index]]
142
+ #name = "pytorch-gpu"
143
+ #url = "https://pypi.org/simple"
144
+ #explicit = true
145
+
143
146
  [tool.uv.sources]
144
147
  torch = [
145
- { index = "pytorch-cpu", extra = "local-cpu"},
148
+ { index = "pytorch-cpu", extra = "local-cpu", marker = "sys_platform == 'linux'"},
149
+ # { index = "pytorch-gpu", extra = "local-gpu", marker = "sys_platform != 'linux' or platform_machine != 'x86_64'"},
146
150
  ]
147
151
 
148
152
  [tool.hatch.build.targets.sdist]
File without changes
File without changes