mostlyai 5.2.7__tar.gz → 5.3.1__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.
- {mostlyai-5.2.7 → mostlyai-5.3.1}/PKG-INFO +1 -1
- mostlyai-5.3.1/mostlyai/sdk/__init__.py +52 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/api.py +9 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/domain.py +134 -121
- {mostlyai-5.2.7 → mostlyai-5.3.1}/pyproject.toml +1 -1
- mostlyai-5.2.7/mostlyai/sdk/__init__.py +0 -18
- {mostlyai-5.2.7 → mostlyai-5.3.1}/.gitignore +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/LICENSE +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/README.md +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/__init__.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/auto_detect.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/base.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/context.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/conversions.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/__init__.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/base.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/bigquery.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/databricks.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/hive.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/mssql.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/mysql.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/oracle.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/postgresql.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/redshift.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/snowflake.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/sqlite.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/dtype.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/exceptions.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/__init__.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/base.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/container/aws.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/container/azure.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/container/minio.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/table/csv.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/table/feather.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/table/json.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/file/utils.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/language_model.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/metadata_objects.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/non_context.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/progress_callback.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/pull.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/pull_context.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/pull_utils.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/push.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/util/__init__.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/util/common.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_data/util/kerberos.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/__init__.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/cli.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/connectors.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/__init__.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/jobs.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/migration.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/plan.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/generators.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/progress.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/routes.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/server.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/storage.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/__init__.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/_base_utils.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/_naming_conventions.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/_utils.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/artifacts.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/base.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/connectors.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/datasets.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/exceptions.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/generators.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/client/synthetic_datasets.py +0 -0
- {mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/py.typed +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Copyright 2024-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
|
+
"""Synthetic Data SDK - Python toolkit for high-fidelity, privacy-safe synthetic data.
|
|
16
|
+
|
|
17
|
+
The SDK supports two operating modes:
|
|
18
|
+
- LOCAL mode: Train and generate synthetic data locally on your own compute resources
|
|
19
|
+
- CLIENT mode: Connect to a remote MOSTLY AI platform for training & generation
|
|
20
|
+
|
|
21
|
+
Key Resources
|
|
22
|
+
-------------
|
|
23
|
+
The SDK manages four core resources:
|
|
24
|
+
|
|
25
|
+
1. **Generators** - Train synthetic data generators on tabular or language data
|
|
26
|
+
2. **Synthetic Datasets** - Create synthetic samples from trained generators
|
|
27
|
+
3. **Connectors** - Connect to data sources (databases, cloud storage)
|
|
28
|
+
4. **Datasets** - Create datasets with instructions (CLIENT mode only)
|
|
29
|
+
|
|
30
|
+
Core Operations
|
|
31
|
+
---------------
|
|
32
|
+
- `mostly.train(config)` - Train a generator on tabular or language data
|
|
33
|
+
- `mostly.generate(g, config)` - Generate synthetic data records
|
|
34
|
+
- `mostly.probe(g, config)` - Live probe the generator on demand
|
|
35
|
+
- `mostly.connect(config)` - Connect to external data sources
|
|
36
|
+
|
|
37
|
+
Key Features
|
|
38
|
+
------------
|
|
39
|
+
- Broad data support (mixed-type, single/multi-table, time-series)
|
|
40
|
+
- Multiple model types (TabularARGN, Hugging Face LLMs, LSTM)
|
|
41
|
+
- Advanced training options (GPU/CPU, Differential Privacy)
|
|
42
|
+
- Automated quality assurance with metrics and HTML reports
|
|
43
|
+
- Flexible sampling (up-sampling, conditional simulation, rebalancing)
|
|
44
|
+
- Seamless integration with external data sources
|
|
45
|
+
|
|
46
|
+
For more information, visit: https://mostly-ai.github.io/mostlyai/
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
from mostlyai.sdk.client.api import MostlyAI
|
|
50
|
+
|
|
51
|
+
__all__ = ["MostlyAI"]
|
|
52
|
+
__version__ = "5.3.1" # Do not set this manually. Use poetry version [params].
|
|
@@ -420,6 +420,15 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
420
420
|
database: string
|
|
421
421
|
secrets:
|
|
422
422
|
password: string
|
|
423
|
+
|
|
424
|
+
- type: REDSHIFT
|
|
425
|
+
config:
|
|
426
|
+
host: string
|
|
427
|
+
port: integer, default: 5439
|
|
428
|
+
username: string
|
|
429
|
+
database: string
|
|
430
|
+
secrets:
|
|
431
|
+
password: string
|
|
423
432
|
```
|
|
424
433
|
"""
|
|
425
434
|
c = self.connectors.create(config=config, test_connection=test_connection)
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
# generated by datamodel-codegen:
|
|
16
|
-
# timestamp: 2025-10-
|
|
16
|
+
# timestamp: 2025-10-08T14:06:22+00:00
|
|
17
17
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
@@ -893,6 +893,11 @@ class SyntheticDatasetSortField(str, Enum):
|
|
|
893
893
|
no_of_threads = "NO_OF_THREADS"
|
|
894
894
|
|
|
895
895
|
|
|
896
|
+
class ArtifactSortField(str, Enum):
|
|
897
|
+
recency = "RECENCY"
|
|
898
|
+
no_of_threads = "NO_OF_THREADS"
|
|
899
|
+
|
|
900
|
+
|
|
896
901
|
class AssistantLiteLlmExtraItem(CustomBaseModel):
|
|
897
902
|
"""
|
|
898
903
|
Configuration parameter for the selected LiteLLM model.
|
|
@@ -2618,15 +2623,14 @@ class ModelConfiguration(CustomBaseModel):
|
|
|
2618
2623
|
)
|
|
2619
2624
|
|
|
2620
2625
|
@model_validator(mode="after")
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
values.differential_privacy.value_protection_epsilon = None
|
|
2626
|
+
def validate_differential_privacy_config(self):
|
|
2627
|
+
if self.differential_privacy:
|
|
2628
|
+
if not self.value_protection:
|
|
2629
|
+
self.differential_privacy.value_protection_epsilon = None
|
|
2626
2630
|
else:
|
|
2627
|
-
if
|
|
2628
|
-
|
|
2629
|
-
return
|
|
2631
|
+
if self.differential_privacy.value_protection_epsilon is None:
|
|
2632
|
+
self.differential_privacy.value_protection_epsilon = 1.0
|
|
2633
|
+
return self
|
|
2630
2634
|
|
|
2631
2635
|
|
|
2632
2636
|
class ProgressStep(CustomBaseModel):
|
|
@@ -2669,15 +2673,14 @@ class ProgressStep(CustomBaseModel):
|
|
|
2669
2673
|
status: ProgressStatus | None = None
|
|
2670
2674
|
|
|
2671
2675
|
@model_validator(mode="after")
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
return values
|
|
2676
|
+
def add_required_fields(self):
|
|
2677
|
+
if self.id is None:
|
|
2678
|
+
self.id = str(uuid.uuid4())
|
|
2679
|
+
if self.status is None:
|
|
2680
|
+
self.status = ProgressStatus.new
|
|
2681
|
+
if self.compute_name is None:
|
|
2682
|
+
self.compute_name = "SDK"
|
|
2683
|
+
return self
|
|
2681
2684
|
|
|
2682
2685
|
|
|
2683
2686
|
class SyntheticDatasetListItem(CustomBaseModel):
|
|
@@ -2771,13 +2774,12 @@ class SyntheticTableConfiguration(CustomBaseModel):
|
|
|
2771
2774
|
)
|
|
2772
2775
|
|
|
2773
2776
|
@model_validator(mode="after")
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
return values
|
|
2777
|
+
def add_required_fields(self):
|
|
2778
|
+
if self.sampling_temperature is None:
|
|
2779
|
+
self.sampling_temperature = 1.0
|
|
2780
|
+
if self.sampling_top_p is None:
|
|
2781
|
+
self.sampling_top_p = 1.0
|
|
2782
|
+
return self
|
|
2781
2783
|
|
|
2782
2784
|
|
|
2783
2785
|
class SyntheticDatasetPatchConfig(CustomBaseModel):
|
|
@@ -2819,11 +2821,10 @@ class SyntheticTableConfig(CustomBaseModel):
|
|
|
2819
2821
|
configuration: SyntheticTableConfiguration | None = None
|
|
2820
2822
|
|
|
2821
2823
|
@model_validator(mode="after")
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
return values
|
|
2824
|
+
def add_configuration(self):
|
|
2825
|
+
if self.configuration is None:
|
|
2826
|
+
self.configuration = SyntheticTableConfiguration()
|
|
2827
|
+
return self
|
|
2827
2828
|
|
|
2828
2829
|
def validate_against_source_table(self, source_table: SourceTable, is_probe: bool) -> None:
|
|
2829
2830
|
self._maybe_set_sample_size(source_table, is_probe)
|
|
@@ -2850,6 +2851,7 @@ class AssistantThreadListItem(CustomBaseModel):
|
|
|
2850
2851
|
id: str = Field(..., description="The unique identifier of a assistant thread.")
|
|
2851
2852
|
metadata: Metadata | None = None
|
|
2852
2853
|
name: str = Field(..., description="The name of a assistant thread.")
|
|
2854
|
+
session_status: AssistantThreadSessionStatus = Field(..., alias="sessionStatus")
|
|
2853
2855
|
usage: AssistantThreadUsage | None = None
|
|
2854
2856
|
|
|
2855
2857
|
|
|
@@ -2885,14 +2887,14 @@ class Artifact(CustomBaseModel):
|
|
|
2885
2887
|
|
|
2886
2888
|
id: str = Field(..., description="The unique identifier of an artifact.")
|
|
2887
2889
|
name: str = Field(..., description="The name/title of an artifact.", max_length=256, min_length=1)
|
|
2888
|
-
file_name: str
|
|
2890
|
+
file_name: str = Field(..., alias="fileName", description="The filename of an artifact.")
|
|
2889
2891
|
description: str = Field(
|
|
2890
2892
|
...,
|
|
2891
2893
|
description="The description/prompt of an artifact that explains how to recreate it.",
|
|
2892
2894
|
)
|
|
2893
2895
|
type: ArtifactType | None = None
|
|
2894
2896
|
preview: ArtifactPreview | None = None
|
|
2895
|
-
download_url: str
|
|
2897
|
+
download_url: str = Field(..., alias="downloadUrl", description="URL to download the artifact.")
|
|
2896
2898
|
shareable_url: str = Field(
|
|
2897
2899
|
...,
|
|
2898
2900
|
alias="shareableUrl",
|
|
@@ -2930,6 +2932,30 @@ class Artifact(CustomBaseModel):
|
|
|
2930
2932
|
self.reload()
|
|
2931
2933
|
|
|
2932
2934
|
|
|
2935
|
+
class ArtifactListItem(CustomBaseModel):
|
|
2936
|
+
"""
|
|
2937
|
+
Essential artifact details for listings.
|
|
2938
|
+
"""
|
|
2939
|
+
|
|
2940
|
+
id: str = Field(..., description="The unique identifier of an artifact.")
|
|
2941
|
+
name: str = Field(..., description="The name/title of an artifact.", max_length=256, min_length=1)
|
|
2942
|
+
file_name: str = Field(..., alias="fileName", description="The filename of an artifact.")
|
|
2943
|
+
description: str = Field(
|
|
2944
|
+
...,
|
|
2945
|
+
description="The description/prompt of an artifact that explains how to recreate it.",
|
|
2946
|
+
)
|
|
2947
|
+
type: ArtifactType | None = None
|
|
2948
|
+
preview: ArtifactPreview | None = None
|
|
2949
|
+
download_url: str = Field(..., alias="downloadUrl", description="URL to download the artifact.")
|
|
2950
|
+
shareable_url: str = Field(
|
|
2951
|
+
...,
|
|
2952
|
+
alias="shareableUrl",
|
|
2953
|
+
description="Public URL where the artifact can be viewed and shared.",
|
|
2954
|
+
)
|
|
2955
|
+
usage: ArtifactUsage | None = None
|
|
2956
|
+
metadata: Metadata | None = None
|
|
2957
|
+
|
|
2958
|
+
|
|
2933
2959
|
class OrganizationMetadata(CustomBaseModel):
|
|
2934
2960
|
"""
|
|
2935
2961
|
The metadata of an organization.
|
|
@@ -3119,13 +3145,12 @@ class SourceTableConfig(CustomBaseModel):
|
|
|
3119
3145
|
return included_columns
|
|
3120
3146
|
|
|
3121
3147
|
@model_validator(mode="after")
|
|
3122
|
-
|
|
3123
|
-
def add_model_configuration(cls, values):
|
|
3148
|
+
def add_model_configuration(self):
|
|
3124
3149
|
# Check if the table has a tabular and/or a language model
|
|
3125
|
-
columns =
|
|
3126
|
-
keys = [fk.column for fk in
|
|
3127
|
-
if
|
|
3128
|
-
keys.append(
|
|
3150
|
+
columns = self.columns or []
|
|
3151
|
+
keys = [fk.column for fk in self.foreign_keys or []]
|
|
3152
|
+
if self.primary_key:
|
|
3153
|
+
keys.append(self.primary_key)
|
|
3129
3154
|
model_columns = [c for c in columns if c.name not in keys]
|
|
3130
3155
|
if model_columns:
|
|
3131
3156
|
enc_types = [c.model_encoding_type or ModelEncodingType.auto for c in model_columns]
|
|
@@ -3135,24 +3160,24 @@ class SourceTableConfig(CustomBaseModel):
|
|
|
3135
3160
|
has_tabular_model = True
|
|
3136
3161
|
has_language_model = False
|
|
3137
3162
|
# Always train tabular model for tables with a primary key or linked tables to model sequences
|
|
3138
|
-
if
|
|
3163
|
+
if self.primary_key or (self.foreign_keys and any(fk.is_context for fk in self.foreign_keys)):
|
|
3139
3164
|
has_tabular_model = True
|
|
3140
3165
|
# Remove model configurations that are not applicable for the model type
|
|
3141
|
-
if
|
|
3142
|
-
|
|
3143
|
-
if
|
|
3144
|
-
|
|
3166
|
+
if self.tabular_model_configuration and not has_tabular_model:
|
|
3167
|
+
self.tabular_model_configuration = None
|
|
3168
|
+
if self.language_model_configuration and not has_language_model:
|
|
3169
|
+
self.language_model_configuration = None
|
|
3145
3170
|
# Add default model configurations if none were provided
|
|
3146
|
-
if has_tabular_model and not
|
|
3171
|
+
if has_tabular_model and not self.tabular_model_configuration:
|
|
3147
3172
|
default_model = "MOSTLY_AI/Medium"
|
|
3148
|
-
|
|
3149
|
-
if has_language_model and not
|
|
3173
|
+
self.tabular_model_configuration = ModelConfiguration(model=default_model)
|
|
3174
|
+
if has_language_model and not self.language_model_configuration:
|
|
3150
3175
|
default_model = "MOSTLY_AI/LSTMFromScratch-3m"
|
|
3151
|
-
|
|
3152
|
-
if has_language_model and
|
|
3176
|
+
self.language_model_configuration = ModelConfiguration(model=default_model, max_sequence_window=None)
|
|
3177
|
+
if has_language_model and self.language_model_configuration:
|
|
3153
3178
|
# language models atm do not support max_sequence_window; thus set configuration to None
|
|
3154
|
-
|
|
3155
|
-
return
|
|
3179
|
+
self.language_model_configuration.max_sequence_window = None
|
|
3180
|
+
return self
|
|
3156
3181
|
|
|
3157
3182
|
@field_validator("columns", mode="after")
|
|
3158
3183
|
@classmethod
|
|
@@ -3164,15 +3189,14 @@ class SourceTableConfig(CustomBaseModel):
|
|
|
3164
3189
|
return columns
|
|
3165
3190
|
|
|
3166
3191
|
@model_validator(mode="after")
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
fks = [fk.column for fk in values.foreign_keys or []]
|
|
3192
|
+
def validate_unique_keys(self):
|
|
3193
|
+
pk = self.primary_key or []
|
|
3194
|
+
fks = [fk.column for fk in self.foreign_keys or []]
|
|
3171
3195
|
if len(fks) != len(set(fks)):
|
|
3172
3196
|
raise ValueError("Foreign key column names must be unique.")
|
|
3173
3197
|
if pk in fks:
|
|
3174
3198
|
raise ValueError("Primary key column name must not be defined as foreign key.")
|
|
3175
|
-
return
|
|
3199
|
+
return self
|
|
3176
3200
|
|
|
3177
3201
|
@field_validator("foreign_keys", mode="after")
|
|
3178
3202
|
@classmethod
|
|
@@ -3184,26 +3208,24 @@ class SourceTableConfig(CustomBaseModel):
|
|
|
3184
3208
|
return foreign_keys
|
|
3185
3209
|
|
|
3186
3210
|
@model_validator(mode="after")
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
pk = values.primary_key
|
|
3211
|
+
def validate_keys_exists_in_columns(self):
|
|
3212
|
+
if self.columns:
|
|
3213
|
+
column_names = {col.name for col in self.columns}
|
|
3214
|
+
pk = self.primary_key
|
|
3192
3215
|
if pk and pk not in column_names:
|
|
3193
3216
|
raise ValueError(f"Primary key column '{pk}' does not exist in the table's columns.")
|
|
3194
|
-
for fk in
|
|
3217
|
+
for fk in self.foreign_keys or []:
|
|
3195
3218
|
if fk.column not in column_names:
|
|
3196
3219
|
raise ValueError(f"Foreign key column '{fk.column}' does not exist in the table's columns.")
|
|
3197
|
-
return
|
|
3220
|
+
return self
|
|
3198
3221
|
|
|
3199
3222
|
@model_validator(mode="after")
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
foreign_keys = [fk.column for fk in values.foreign_keys or []]
|
|
3223
|
+
def validate_pk_and_fks_are_not_overlapping(self):
|
|
3224
|
+
primary_key = self.primary_key
|
|
3225
|
+
foreign_keys = [fk.column for fk in self.foreign_keys or []]
|
|
3204
3226
|
if primary_key and primary_key in foreign_keys:
|
|
3205
3227
|
raise ValueError(f"Column '{primary_key}' is both a primary key and a foreign key.")
|
|
3206
|
-
return
|
|
3228
|
+
return self
|
|
3207
3229
|
|
|
3208
3230
|
|
|
3209
3231
|
class SourceTablePatchConfig(CustomBaseModel):
|
|
@@ -4035,81 +4057,72 @@ class _SyntheticTableConfigValidation(CustomBaseModel):
|
|
|
4035
4057
|
source_table: SourceTable
|
|
4036
4058
|
|
|
4037
4059
|
@model_validator(mode="after")
|
|
4038
|
-
def validate_rebalancing_config(
|
|
4039
|
-
config =
|
|
4060
|
+
def validate_rebalancing_config(self):
|
|
4061
|
+
config = self.synthetic_table.configuration
|
|
4040
4062
|
if config and config.rebalancing:
|
|
4041
4063
|
rebalancing_column = config.rebalancing.column
|
|
4042
4064
|
rebalancing_col = next(
|
|
4043
|
-
(col for col in
|
|
4065
|
+
(col for col in self.source_table.columns or [] if col.name == rebalancing_column), None
|
|
4044
4066
|
)
|
|
4045
4067
|
if not rebalancing_col:
|
|
4046
4068
|
raise ValueError(
|
|
4047
|
-
f"Rebalancing column '{rebalancing_column}' not found in table '{
|
|
4069
|
+
f"Rebalancing column '{rebalancing_column}' not found in table '{self.source_table.name}'"
|
|
4048
4070
|
)
|
|
4049
4071
|
if not rebalancing_col.model_encoding_type == ModelEncodingType.tabular_categorical:
|
|
4050
4072
|
raise ValueError(
|
|
4051
|
-
f"Rebalancing column '{rebalancing_column}' in table '{
|
|
4073
|
+
f"Rebalancing column '{rebalancing_column}' in table '{self.source_table.name}' must be categorical"
|
|
4052
4074
|
)
|
|
4053
4075
|
if not rebalancing_col.included:
|
|
4054
4076
|
raise ValueError(
|
|
4055
|
-
f"Rebalancing column '{rebalancing_column}' in table '{
|
|
4077
|
+
f"Rebalancing column '{rebalancing_column}' in table '{self.source_table.name}' must have `included=True`"
|
|
4056
4078
|
)
|
|
4057
4079
|
for value in config.rebalancing.probabilities.keys():
|
|
4058
4080
|
if value not in rebalancing_col.value_range.values:
|
|
4059
4081
|
raise ValueError(
|
|
4060
|
-
f"Rebalancing value '{value}' not found in table '{
|
|
4082
|
+
f"Rebalancing value '{value}' not found in table '{self.source_table.name}' column '{rebalancing_column}'"
|
|
4061
4083
|
)
|
|
4062
|
-
return
|
|
4084
|
+
return self
|
|
4063
4085
|
|
|
4064
4086
|
@model_validator(mode="after")
|
|
4065
|
-
def validate_imputation_config(
|
|
4066
|
-
config =
|
|
4087
|
+
def validate_imputation_config(self):
|
|
4088
|
+
config = self.synthetic_table.configuration
|
|
4067
4089
|
if config and config.imputation:
|
|
4068
|
-
has_tabular_model =
|
|
4090
|
+
has_tabular_model = self.source_table.tabular_model_configuration is not None
|
|
4069
4091
|
if not has_tabular_model:
|
|
4070
|
-
raise ValueError(
|
|
4071
|
-
f"Table '{validation.source_table.name}' specifies imputation but has no tabular model"
|
|
4072
|
-
)
|
|
4092
|
+
raise ValueError(f"Table '{self.source_table.name}' specifies imputation but has no tabular model")
|
|
4073
4093
|
for col in config.imputation.columns:
|
|
4074
|
-
if not any(gcol.name == col for gcol in
|
|
4075
|
-
raise ValueError(f"Imputation column '{col}' not found in table '{
|
|
4076
|
-
return
|
|
4094
|
+
if not any(gcol.name == col for gcol in self.source_table.columns or []):
|
|
4095
|
+
raise ValueError(f"Imputation column '{col}' not found in table '{self.source_table.name}'")
|
|
4096
|
+
return self
|
|
4077
4097
|
|
|
4078
4098
|
@model_validator(mode="after")
|
|
4079
|
-
def validate_fairness_config(
|
|
4080
|
-
config =
|
|
4099
|
+
def validate_fairness_config(self):
|
|
4100
|
+
config = self.synthetic_table.configuration
|
|
4081
4101
|
if config and config.fairness:
|
|
4082
|
-
has_tabular_model =
|
|
4102
|
+
has_tabular_model = self.source_table.tabular_model_configuration is not None
|
|
4083
4103
|
if not has_tabular_model:
|
|
4084
|
-
raise ValueError(f"Table '{
|
|
4104
|
+
raise ValueError(f"Table '{self.source_table.name}' specifies fairness but has no tabular model")
|
|
4085
4105
|
target_col = config.fairness.target_column
|
|
4086
|
-
if not any(col.name == target_col for col in
|
|
4087
|
-
raise ValueError(
|
|
4088
|
-
f"Fairness target column '{target_col}' not found in table '{validation.source_table.name}'"
|
|
4089
|
-
)
|
|
4106
|
+
if not any(col.name == target_col for col in self.source_table.columns or []):
|
|
4107
|
+
raise ValueError(f"Fairness target column '{target_col}' not found in table '{self.source_table.name}'")
|
|
4090
4108
|
for col in config.fairness.sensitive_columns:
|
|
4091
|
-
if not any(gcol.name == col for gcol in
|
|
4092
|
-
raise ValueError(
|
|
4093
|
-
f"Fairness sensitive column '{col}' not found in table '{validation.source_table.name}'"
|
|
4094
|
-
)
|
|
4109
|
+
if not any(gcol.name == col for gcol in self.source_table.columns or []):
|
|
4110
|
+
raise ValueError(f"Fairness sensitive column '{col}' not found in table '{self.source_table.name}'")
|
|
4095
4111
|
if target_col in config.fairness.sensitive_columns:
|
|
4096
4112
|
raise ValueError(f"Target column '{target_col}' cannot be a sensitive column")
|
|
4097
|
-
return
|
|
4113
|
+
return self
|
|
4098
4114
|
|
|
4099
4115
|
@model_validator(mode="after")
|
|
4100
|
-
def validate_data_report_disabled_if_both_model_reports_disabled(
|
|
4116
|
+
def validate_data_report_disabled_if_both_model_reports_disabled(self):
|
|
4101
4117
|
configs = [
|
|
4102
4118
|
cfg
|
|
4103
|
-
for cfg in [
|
|
4104
|
-
validation.source_table.tabular_model_configuration,
|
|
4105
|
-
validation.source_table.language_model_configuration,
|
|
4106
|
-
]
|
|
4119
|
+
for cfg in [self.source_table.tabular_model_configuration, self.source_table.language_model_configuration]
|
|
4107
4120
|
if cfg
|
|
4108
4121
|
]
|
|
4109
4122
|
if all(cfg.enable_model_report is False for cfg in configs):
|
|
4110
|
-
if
|
|
4111
|
-
|
|
4112
|
-
return
|
|
4123
|
+
if self.synthetic_table.configuration is not None:
|
|
4124
|
+
self.synthetic_table.configuration.enable_data_report = False
|
|
4125
|
+
return self
|
|
4113
4126
|
|
|
4114
4127
|
|
|
4115
4128
|
class _SyntheticDataConfigValidation(CustomBaseModel):
|
|
@@ -4121,38 +4134,38 @@ class _SyntheticDataConfigValidation(CustomBaseModel):
|
|
|
4121
4134
|
generator: Generator
|
|
4122
4135
|
|
|
4123
4136
|
@model_validator(mode="after")
|
|
4124
|
-
def add_missing_tables(
|
|
4125
|
-
generator_table_map = {t.name: t for t in
|
|
4126
|
-
if
|
|
4127
|
-
|
|
4128
|
-
synthetic_table_map = {t.name: t for t in
|
|
4137
|
+
def add_missing_tables(self):
|
|
4138
|
+
generator_table_map = {t.name: t for t in self.generator.tables}
|
|
4139
|
+
if self.synthetic_config.tables is None:
|
|
4140
|
+
self.synthetic_config.tables = []
|
|
4141
|
+
synthetic_table_map = {t.name: t for t in self.synthetic_config.tables}
|
|
4129
4142
|
missing_tables = set(generator_table_map.keys()) - set(synthetic_table_map.keys())
|
|
4130
4143
|
for t in missing_tables:
|
|
4131
|
-
|
|
4132
|
-
return
|
|
4144
|
+
self.synthetic_config.tables.append(SyntheticTableConfig(name=t))
|
|
4145
|
+
return self
|
|
4133
4146
|
|
|
4134
4147
|
@model_validator(mode="after")
|
|
4135
|
-
def validate_no_extra_tables(
|
|
4136
|
-
generator_table_map = {t.name: t for t in
|
|
4137
|
-
synthetic_table_map = {t.name: t for t in
|
|
4148
|
+
def validate_no_extra_tables(self):
|
|
4149
|
+
generator_table_map = {t.name: t for t in self.generator.tables}
|
|
4150
|
+
synthetic_table_map = {t.name: t for t in self.synthetic_config.tables or []}
|
|
4138
4151
|
generator_tables = set(generator_table_map.keys())
|
|
4139
4152
|
extra_tables = set(synthetic_table_map.keys()) - generator_tables
|
|
4140
4153
|
if extra_tables:
|
|
4141
4154
|
raise ValueError(
|
|
4142
4155
|
f"Tables {extra_tables} are not present in the generator. Only {generator_tables} are available."
|
|
4143
4156
|
)
|
|
4144
|
-
return
|
|
4157
|
+
return self
|
|
4145
4158
|
|
|
4146
4159
|
@model_validator(mode="after")
|
|
4147
|
-
def validate_tables(
|
|
4148
|
-
generator_table_map = {t.name: t for t in
|
|
4149
|
-
synthetic_table_map = {t.name: t for t in
|
|
4160
|
+
def validate_tables(self):
|
|
4161
|
+
generator_table_map = {t.name: t for t in self.generator.tables}
|
|
4162
|
+
synthetic_table_map = {t.name: t for t in self.synthetic_config.tables or []}
|
|
4150
4163
|
for table_name, synthetic_table in synthetic_table_map.items():
|
|
4151
4164
|
generator_table = generator_table_map[table_name]
|
|
4152
4165
|
synthetic_table.validate_against_source_table(
|
|
4153
|
-
generator_table, is_probe=isinstance(
|
|
4166
|
+
generator_table, is_probe=isinstance(self.synthetic_config, SyntheticProbeConfig)
|
|
4154
4167
|
)
|
|
4155
|
-
return
|
|
4168
|
+
return self
|
|
4156
4169
|
|
|
4157
4170
|
|
|
4158
4171
|
def _add_fields_to_docstring(cls):
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# Copyright 2024-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 mostlyai.sdk.client.api import MostlyAI
|
|
16
|
-
|
|
17
|
-
__all__ = ["MostlyAI"]
|
|
18
|
-
__version__ = "5.2.7" # Do not set this manually. Use poetry version [params].
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_analyze_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_encode_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-5.2.7 → mostlyai-5.3.1}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|