mostlyai 4.0.6__tar.gz → 4.1.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-4.0.6 → mostlyai-4.1.1}/PKG-INFO +8 -7
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/__init__.py +1 -1
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/container/azure.py +4 -1
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/routes.py +1 -46
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/server.py +22 -28
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/client/_utils.py +2 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/client/api.py +16 -12
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/client/base.py +4 -1
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/client/connectors.py +4 -1
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/client/generators.py +8 -2
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/client/synthetic_datasets.py +6 -3
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/domain.py +106 -86
- {mostlyai-4.0.6 → mostlyai-4.1.1}/pyproject.toml +8 -7
- {mostlyai-4.0.6 → mostlyai-4.1.1}/.gitignore +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/LICENSE +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/README.md +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/__init__.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/auto_detect.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/base.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/context.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/conversions.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/__init__.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/base.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/bigquery.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/databricks.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/hive.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/mssql.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/mysql.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/oracle.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/postgresql.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/snowflake.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/sqlite.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/dtype.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/exceptions.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/__init__.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/base.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/container/aws.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/container/minio.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/table/csv.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/table/feather.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/table/json.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/file/utils.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/language_model.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/metadata_objects.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/non_context.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/progress_callback.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/pull.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/pull_context.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/pull_utils.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/push.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/util/__init__.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/util/common.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_data/util/kerberos.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/__init__.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/cli.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/connectors.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/__init__.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/jobs.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/plan.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/generators.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/progress.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/storage.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/client/__init__.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/client/_base_utils.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/client/_naming_conventions.py +0 -0
- {mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/client/exceptions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mostlyai
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.1.1
|
|
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
|
|
@@ -34,6 +34,7 @@ Requires-Dist: greenlet<4,>=3.1.1
|
|
|
34
34
|
Requires-Dist: gunicorn>=23.0.0
|
|
35
35
|
Requires-Dist: httpx>=0.25.0
|
|
36
36
|
Requires-Dist: joblib>=1.2.0
|
|
37
|
+
Requires-Dist: networkx<4,>=3.0
|
|
37
38
|
Requires-Dist: openpyxl>=3.1.5
|
|
38
39
|
Requires-Dist: pandas>=2.0.0
|
|
39
40
|
Requires-Dist: psutil>=5.9.5
|
|
@@ -62,23 +63,23 @@ Requires-Dist: kerberos<2,>=1.3.1; extra == 'hive'
|
|
|
62
63
|
Requires-Dist: pyhive[hive-pure-sasl]<0.8,>=0.7.0; extra == 'hive'
|
|
63
64
|
Provides-Extra: local
|
|
64
65
|
Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local'
|
|
65
|
-
Requires-Dist: mostlyai-engine==1.0.
|
|
66
|
-
Requires-Dist: mostlyai-qa==1.5.
|
|
66
|
+
Requires-Dist: mostlyai-engine==1.0.4; extra == 'local'
|
|
67
|
+
Requires-Dist: mostlyai-qa==1.5.3; extra == 'local'
|
|
67
68
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local'
|
|
68
69
|
Requires-Dist: torch<2.6.0,>=2.5.1; extra == 'local'
|
|
69
70
|
Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local'
|
|
70
71
|
Provides-Extra: local-cpu
|
|
71
72
|
Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-cpu'
|
|
72
|
-
Requires-Dist: mostlyai-engine[cpu]==1.0.
|
|
73
|
-
Requires-Dist: mostlyai-qa[cpu]==1.5.
|
|
73
|
+
Requires-Dist: mostlyai-engine[cpu]==1.0.4; extra == 'local-cpu'
|
|
74
|
+
Requires-Dist: mostlyai-qa[cpu]==1.5.3; extra == 'local-cpu'
|
|
74
75
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local-cpu'
|
|
75
76
|
Requires-Dist: torch<2.6.0,>=2.5.1; (sys_platform != 'linux') and extra == 'local-cpu'
|
|
76
77
|
Requires-Dist: torch==2.5.1+cpu; (sys_platform == 'linux') and extra == 'local-cpu'
|
|
77
78
|
Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local-cpu'
|
|
78
79
|
Provides-Extra: local-gpu
|
|
79
80
|
Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-gpu'
|
|
80
|
-
Requires-Dist: mostlyai-engine[gpu]==1.0.
|
|
81
|
-
Requires-Dist: mostlyai-qa[gpu]==1.5.
|
|
81
|
+
Requires-Dist: mostlyai-engine[gpu]==1.0.4; extra == 'local-gpu'
|
|
82
|
+
Requires-Dist: mostlyai-qa[gpu]==1.5.3; extra == 'local-gpu'
|
|
82
83
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local-gpu'
|
|
83
84
|
Requires-Dist: torch<2.6.0,>=2.5.1; extra == 'local-gpu'
|
|
84
85
|
Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local-gpu'
|
|
@@ -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.
|
|
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.")
|
|
@@ -21,7 +21,7 @@ from pathlib import Path
|
|
|
21
21
|
|
|
22
22
|
from fastapi import APIRouter, Body, HTTPException, UploadFile, File
|
|
23
23
|
from fastapi.encoders import jsonable_encoder
|
|
24
|
-
from fastapi.responses import FileResponse, JSONResponse, StreamingResponse, HTMLResponse
|
|
24
|
+
from fastapi.responses import FileResponse, JSONResponse, StreamingResponse, HTMLResponse
|
|
25
25
|
|
|
26
26
|
from mostlyai import sdk
|
|
27
27
|
from mostlyai.sdk._data.conversions import create_container_from_connector
|
|
@@ -105,51 +105,6 @@ class Routes:
|
|
|
105
105
|
def _initialize_routes(self):
|
|
106
106
|
## GENERAL
|
|
107
107
|
|
|
108
|
-
@self.router.get("/", include_in_schema=False)
|
|
109
|
-
async def root() -> RedirectResponse:
|
|
110
|
-
return RedirectResponse(url="/docs")
|
|
111
|
-
|
|
112
|
-
@self.router.get("/d/connectors/{id}", response_class=HTMLResponse, include_in_schema=False)
|
|
113
|
-
async def show_connector(id: str) -> HTMLResponse:
|
|
114
|
-
connector_dir = self.home_dir / "connectors" / id
|
|
115
|
-
connector_json = connector_dir / "connector.json"
|
|
116
|
-
body = f"<h3>file://{connector_json}</h3><pre>{connector_json.read_text()}</pre>"
|
|
117
|
-
return HTMLResponse(content=self._html("Connector", body))
|
|
118
|
-
|
|
119
|
-
@self.router.get("/d/generators/{id}", response_class=HTMLResponse, include_in_schema=False)
|
|
120
|
-
async def show_generator(id: str) -> HTMLResponse:
|
|
121
|
-
generator_dir = self.home_dir / "generators" / id
|
|
122
|
-
generator_json = generator_dir / "generator.json"
|
|
123
|
-
progress_json = generator_dir / "job_progress.json"
|
|
124
|
-
job_log_file = generator_dir / "job.log"
|
|
125
|
-
job_log_logs = job_log_file.read_text() if job_log_file.exists() else ""
|
|
126
|
-
body = (
|
|
127
|
-
f"<h3>file://{generator_json}</h3>"
|
|
128
|
-
f"<pre>{generator_json.read_text()}</pre>"
|
|
129
|
-
f"<h3>file://{progress_json}</h3>"
|
|
130
|
-
f"<pre>{progress_json.read_text()}</pre>"
|
|
131
|
-
f"<h3>file://{job_log_file}</h3>"
|
|
132
|
-
f"<pre>{job_log_logs}</pre>"
|
|
133
|
-
)
|
|
134
|
-
return HTMLResponse(content=self._html("Generator", body))
|
|
135
|
-
|
|
136
|
-
@self.router.get("/d/synthetic-datasets/{id}", response_class=HTMLResponse, include_in_schema=False)
|
|
137
|
-
async def show_synthetic_dataset(id: str) -> HTMLResponse:
|
|
138
|
-
synthetic_dataset_dir = self.home_dir / "synthetic-datasets" / id
|
|
139
|
-
synthetic_dataset_json = synthetic_dataset_dir / "synthetic-dataset.json"
|
|
140
|
-
progress_json = synthetic_dataset_dir / "job_progress.json"
|
|
141
|
-
job_log_file = synthetic_dataset_dir / "job.log"
|
|
142
|
-
job_log_logs = job_log_file.read_text() if job_log_file.exists() else ""
|
|
143
|
-
body = (
|
|
144
|
-
f"<h3>file://{synthetic_dataset_json}</h3>"
|
|
145
|
-
f"<pre>{synthetic_dataset_json.read_text()}</pre>"
|
|
146
|
-
f"<h3>file://{progress_json}</h3>"
|
|
147
|
-
f"<pre>{progress_json.read_text()}</pre>"
|
|
148
|
-
f"<h3>file://{job_log_file}</h3>"
|
|
149
|
-
f"<pre>{job_log_logs}</pre>"
|
|
150
|
-
)
|
|
151
|
-
return HTMLResponse(content=self._html("Synthetic Dataset", body))
|
|
152
|
-
|
|
153
108
|
@self.router.get("/about", response_model=AboutService)
|
|
154
109
|
async def get_about_service() -> AboutService:
|
|
155
110
|
return AboutService(version=sdk.__version__, assistant=False)
|
|
@@ -11,30 +11,32 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
-
|
|
14
|
+
import atexit
|
|
15
|
+
import tempfile
|
|
15
16
|
import time
|
|
16
17
|
from pathlib import Path
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
from threading import Thread
|
|
19
20
|
|
|
20
21
|
import rich
|
|
21
22
|
from fastapi import FastAPI
|
|
22
23
|
import uvicorn
|
|
23
24
|
from mostlyai.sdk._local.routes import Routes
|
|
24
|
-
|
|
25
|
+
|
|
26
|
+
import os
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
class LocalServer:
|
|
28
30
|
def __init__(
|
|
29
31
|
self,
|
|
30
32
|
home_dir: str | Path | None = None,
|
|
31
|
-
host: str | None = None,
|
|
32
|
-
port: int | None = None,
|
|
33
33
|
):
|
|
34
|
-
self.home_dir = Path(home_dir
|
|
35
|
-
self.
|
|
36
|
-
self.
|
|
37
|
-
|
|
34
|
+
self.home_dir = Path(home_dir or "~/mostlyai").expanduser()
|
|
35
|
+
self.home_dir.mkdir(parents=True, exist_ok=True)
|
|
36
|
+
self.uds = tempfile.NamedTemporaryFile(
|
|
37
|
+
dir=self.home_dir, prefix=".mostlyai-", suffix=".sock", delete=False
|
|
38
|
+
).name
|
|
39
|
+
self.base_url = "http://127.0.0.1"
|
|
38
40
|
self._app = FastAPI(
|
|
39
41
|
root_path="/api/v2",
|
|
40
42
|
title="Synthetic Data SDK ✨",
|
|
@@ -50,24 +52,13 @@ class LocalServer:
|
|
|
50
52
|
self._thread = None
|
|
51
53
|
self.start() # Automatically start the server during initialization
|
|
52
54
|
|
|
53
|
-
def
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return s.connect_ex((host, port)) == 0
|
|
57
|
-
|
|
58
|
-
failed_ports = []
|
|
59
|
-
min_port, max_port = 49152, 65535
|
|
60
|
-
for _ in range(10):
|
|
61
|
-
port = random.randint(min_port, max_port)
|
|
62
|
-
if not is_port_in_use(port, self.host):
|
|
63
|
-
return port
|
|
64
|
-
failed_ports.append(port)
|
|
65
|
-
raise ValueError(
|
|
66
|
-
f"Could not find an available port in range {min_port}-{max_port} after 10 attempts. Tried ports: {failed_ports}"
|
|
67
|
-
)
|
|
55
|
+
def _clear_socket_file(self):
|
|
56
|
+
if os.path.exists(self.uds):
|
|
57
|
+
os.remove(self.uds)
|
|
68
58
|
|
|
69
59
|
def _create_server(self):
|
|
70
|
-
|
|
60
|
+
self._clear_socket_file()
|
|
61
|
+
config = uvicorn.Config(self._app, uds=self.uds, log_level="error", reload=False)
|
|
71
62
|
self._server = uvicorn.Server(config)
|
|
72
63
|
|
|
73
64
|
def _run_server(self):
|
|
@@ -77,18 +68,21 @@ class LocalServer:
|
|
|
77
68
|
def start(self):
|
|
78
69
|
if not self._server:
|
|
79
70
|
rich.print(
|
|
80
|
-
f"Starting
|
|
71
|
+
f"Starting Synthetic Data SDK in local mode using [link=file://{self.home_dir} dodger_blue2 underline]file://{self.home_dir}[/]"
|
|
81
72
|
)
|
|
82
73
|
self._create_server()
|
|
83
74
|
self._thread = Thread(target=self._run_server, daemon=True)
|
|
84
75
|
self._thread.start()
|
|
76
|
+
# make sure the socket file is cleaned up on exit
|
|
77
|
+
atexit.register(self._clear_socket_file)
|
|
85
78
|
time.sleep(0.5) # give the server a moment to start
|
|
86
79
|
|
|
87
80
|
def stop(self):
|
|
88
81
|
if self._server and self._server.started:
|
|
89
|
-
rich.print(
|
|
82
|
+
rich.print("Stopping Synthetic Data SDK in local mode")
|
|
90
83
|
self._server.should_exit = True # Signal the server to shut down
|
|
91
84
|
self._thread.join() # Wait for the server thread to finish
|
|
85
|
+
self._clear_socket_file()
|
|
92
86
|
|
|
93
87
|
def __enter__(self):
|
|
94
88
|
# Ensure the server is running
|
|
@@ -102,5 +96,5 @@ class LocalServer:
|
|
|
102
96
|
def __del__(self):
|
|
103
97
|
# Backup cleanup in case `stop` was not called explicitly or via context
|
|
104
98
|
if self._server and self._server.started:
|
|
105
|
-
print(
|
|
99
|
+
print("Automatically shutting down server")
|
|
106
100
|
self.stop()
|
|
@@ -65,6 +65,7 @@ def job_wait(
|
|
|
65
65
|
),
|
|
66
66
|
TaskProgressColumn(),
|
|
67
67
|
TimeElapsedColumn(),
|
|
68
|
+
refresh_per_second=1 / interval,
|
|
68
69
|
)
|
|
69
70
|
progress_bars = {
|
|
70
71
|
"overall": progress.add_task(
|
|
@@ -127,6 +128,7 @@ def job_wait(
|
|
|
127
128
|
return
|
|
128
129
|
# check whether we are done
|
|
129
130
|
if job.progress.value >= job.progress.max:
|
|
131
|
+
progress.refresh()
|
|
130
132
|
time.sleep(1) # give the system a moment to update the status
|
|
131
133
|
return
|
|
132
134
|
else:
|
|
@@ -85,8 +85,6 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
85
85
|
api_key: The API key for authenticating. If not provided, it would rely on environment variables.
|
|
86
86
|
local: Whether to run in local mode or not.
|
|
87
87
|
local_dir: The directory to use for local mode. If not provided, `~/mostlyai` will be used.
|
|
88
|
-
local_port: The port to use for local mode. If not provided, a random port will be used.
|
|
89
|
-
local_host: The host to use for local mode. If not provided, then 127.0.0.1 will be used.
|
|
90
88
|
timeout: Timeout for HTTPS requests in seconds.
|
|
91
89
|
ssl_verify: Whether to verify SSL certificates.
|
|
92
90
|
quiet: Whether to suppress rich output.
|
|
@@ -98,8 +96,6 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
98
96
|
api_key: str | None = None,
|
|
99
97
|
local: bool = False,
|
|
100
98
|
local_dir: str | Path | None = None,
|
|
101
|
-
local_port: int | None = None,
|
|
102
|
-
local_host: str | None = None,
|
|
103
99
|
timeout: float = 60.0,
|
|
104
100
|
ssl_verify: bool = True,
|
|
105
101
|
quiet: bool = False,
|
|
@@ -117,27 +113,35 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
117
113
|
from mostlyai import qa # noqa
|
|
118
114
|
except ImportError:
|
|
119
115
|
raise APIError(
|
|
120
|
-
"
|
|
116
|
+
"LOCAL mode requires additional packages to be installed. Run `pip install 'mostlyai[local]'`."
|
|
121
117
|
)
|
|
122
118
|
|
|
123
|
-
self.local = LocalServer(home_dir=local_dir
|
|
119
|
+
self.local = LocalServer(home_dir=local_dir)
|
|
124
120
|
base_url = self.local.base_url
|
|
125
121
|
api_key = "local"
|
|
122
|
+
uds = self.local.uds
|
|
123
|
+
else:
|
|
124
|
+
uds = None
|
|
126
125
|
|
|
127
|
-
super().__init__(base_url=base_url, api_key=api_key, timeout=timeout, ssl_verify=ssl_verify)
|
|
128
126
|
client_kwargs = {
|
|
129
|
-
"base_url":
|
|
130
|
-
"api_key":
|
|
131
|
-
"
|
|
132
|
-
"
|
|
127
|
+
"base_url": base_url,
|
|
128
|
+
"api_key": api_key,
|
|
129
|
+
"uds": uds,
|
|
130
|
+
"timeout": timeout,
|
|
131
|
+
"ssl_verify": ssl_verify,
|
|
133
132
|
}
|
|
133
|
+
super().__init__(**client_kwargs)
|
|
134
134
|
self.connectors = _MostlyConnectorsClient(**client_kwargs)
|
|
135
135
|
self.generators = _MostlyGeneratorsClient(**client_kwargs)
|
|
136
136
|
self.synthetic_datasets = _MostlySyntheticDatasetsClient(**client_kwargs)
|
|
137
137
|
self.synthetic_probes = _MostlySyntheticProbesClient(**client_kwargs)
|
|
138
138
|
try:
|
|
139
|
+
if local:
|
|
140
|
+
msg = "Connected to Synthetic Data SDK in local mode"
|
|
141
|
+
else:
|
|
142
|
+
msg = f"Connected to [link={self.base_url} dodger_blue2 underline]{self.base_url}[/]"
|
|
139
143
|
version = self.about().version
|
|
140
|
-
msg
|
|
144
|
+
msg += f" ({version})"
|
|
141
145
|
email = self.me().email
|
|
142
146
|
if email:
|
|
143
147
|
msg += f" as [bold]{email}[/bold]"
|
|
@@ -63,11 +63,14 @@ class _MostlyBaseClient:
|
|
|
63
63
|
self,
|
|
64
64
|
base_url: str | None = None,
|
|
65
65
|
api_key: str | None = None,
|
|
66
|
+
uds: str | None = None,
|
|
66
67
|
timeout: float = 60.0,
|
|
67
68
|
ssl_verify: bool = True,
|
|
68
69
|
):
|
|
69
70
|
self.base_url = (base_url or os.getenv("MOSTLY_BASE_URL") or DEFAULT_BASE_URL).rstrip("/")
|
|
70
71
|
self.api_key = api_key or os.getenv("MOSTLY_API_KEY")
|
|
72
|
+
self.local = uds is not None
|
|
73
|
+
self.transport = httpx.HTTPTransport(uds=uds) if uds else None
|
|
71
74
|
self.timeout = timeout
|
|
72
75
|
self.ssl_verify = ssl_verify
|
|
73
76
|
if not self.api_key:
|
|
@@ -137,7 +140,7 @@ class _MostlyBaseClient:
|
|
|
137
140
|
kwargs["params"] = map_snake_to_camel_case(kwargs["params"])
|
|
138
141
|
|
|
139
142
|
try:
|
|
140
|
-
with httpx.Client(timeout=self.timeout, verify=self.ssl_verify) as client:
|
|
143
|
+
with httpx.Client(timeout=self.timeout, verify=self.ssl_verify, transport=self.transport) as client:
|
|
141
144
|
response = client.request(method=verb, url=full_url, **kwargs)
|
|
142
145
|
response.raise_for_status()
|
|
143
146
|
except httpx.HTTPStatusError as exc:
|
|
@@ -126,7 +126,10 @@ class _MostlyConnectorsClient(_MostlyBaseClient):
|
|
|
126
126
|
response_type=Connector,
|
|
127
127
|
)
|
|
128
128
|
cid = connector.id
|
|
129
|
-
|
|
129
|
+
if self.local:
|
|
130
|
+
rich.print(f"Created connector [dodger_blue2]{cid}[/]")
|
|
131
|
+
else:
|
|
132
|
+
rich.print(f"Created connector [link={self.base_url}/d/connectors/{cid} dodger_blue2 underline]{cid}[/]")
|
|
130
133
|
return connector
|
|
131
134
|
|
|
132
135
|
# PRIVATE METHODS #
|
|
@@ -172,7 +172,10 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
|
|
|
172
172
|
table["columns"] = [{"name": col} if isinstance(col, str) else col for col in table["columns"]]
|
|
173
173
|
generator = self.request(verb=POST, path=[], json=config, response_type=Generator)
|
|
174
174
|
gid = generator.id
|
|
175
|
-
|
|
175
|
+
if self.local:
|
|
176
|
+
rich.print(f"Created generator [dodger_blue2]{gid}[/]")
|
|
177
|
+
else:
|
|
178
|
+
rich.print(f"Created generator [link={self.base_url}/d/generators/{gid} dodger_blue2 underline]{gid}[/]")
|
|
176
179
|
return generator
|
|
177
180
|
|
|
178
181
|
def import_from_file(
|
|
@@ -206,7 +209,10 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
|
|
|
206
209
|
response_type=Generator,
|
|
207
210
|
)
|
|
208
211
|
gid = generator.id
|
|
209
|
-
|
|
212
|
+
if self.local:
|
|
213
|
+
rich.print(f"Imported generator [dodger_blue2]{gid}[/]")
|
|
214
|
+
else:
|
|
215
|
+
rich.print(f"Imported generator [link={self.base_url}/d/generators/{gid} dodger_blue2 underline]{gid}[/]")
|
|
210
216
|
return generator
|
|
211
217
|
|
|
212
218
|
# PRIVATE METHODS #
|
|
@@ -158,9 +158,12 @@ class _MostlySyntheticDatasetsClient(_MostlyBaseClient):
|
|
|
158
158
|
)
|
|
159
159
|
sid = synthetic_dataset.id
|
|
160
160
|
gid = synthetic_dataset.generator_id
|
|
161
|
-
|
|
162
|
-
f"Created synthetic dataset [
|
|
163
|
-
|
|
161
|
+
if self.local:
|
|
162
|
+
rich.print(f"Created synthetic dataset [dodger_blue2]{sid}[/] with generator [dodger_blue2]{gid}[/]")
|
|
163
|
+
else:
|
|
164
|
+
rich.print(
|
|
165
|
+
f"Created synthetic dataset [link={self.base_url}/d/synthetic-datasets/{sid} dodger_blue2 underline]{sid}[/] with generator [link={self.base_url}/d/generators/{gid} dodger_blue2 underline]{gid}[/]"
|
|
166
|
+
)
|
|
164
167
|
return synthetic_dataset
|
|
165
168
|
|
|
166
169
|
# PRIVATE METHODS #
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
# generated by datamodel-codegen:
|
|
16
|
-
# timestamp: 2025-
|
|
16
|
+
# timestamp: 2025-02-05T16:23:28+00:00
|
|
17
17
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
@@ -839,6 +839,11 @@ class OrganizationListItem(CustomBaseModel):
|
|
|
839
839
|
"""
|
|
840
840
|
|
|
841
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
|
+
)
|
|
842
847
|
display_name: str = Field(..., alias="displayName", description="The display name of an organization.")
|
|
843
848
|
description: str | None = Field(None, description="The description of an organization. Supports markdown.")
|
|
844
849
|
logo: AnyUrl | None = Field(None, description="The URL of the organization's logo.")
|
|
@@ -1601,6 +1606,10 @@ class GeneratorListItem(CustomBaseModel):
|
|
|
1601
1606
|
)
|
|
1602
1607
|
usage: GeneratorUsage | None = None
|
|
1603
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
|
+
)
|
|
1604
1613
|
OPEN_URL_PARTS: ClassVar[list] = ["d", "generators"]
|
|
1605
1614
|
|
|
1606
1615
|
def __getattr__(self, item):
|
|
@@ -1943,6 +1952,22 @@ class SyntheticTableConfig(CustomBaseModel):
|
|
|
1943
1952
|
values.configuration = SyntheticTableConfiguration()
|
|
1944
1953
|
return values
|
|
1945
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
|
+
|
|
1946
1971
|
|
|
1947
1972
|
class AssistantThreadListItem(CustomBaseModel):
|
|
1948
1973
|
"""
|
|
@@ -2313,7 +2338,7 @@ class SyntheticDatasetConfig(CustomBaseModel):
|
|
|
2313
2338
|
return tables
|
|
2314
2339
|
|
|
2315
2340
|
def validate_against_generator(self, generator: Generator) -> None:
|
|
2316
|
-
|
|
2341
|
+
_SyntheticDataConfigValidation(synthetic_config=self, generator=generator)
|
|
2317
2342
|
|
|
2318
2343
|
|
|
2319
2344
|
class SyntheticProbeConfig(CustomBaseModel):
|
|
@@ -2335,7 +2360,7 @@ class SyntheticProbeConfig(CustomBaseModel):
|
|
|
2335
2360
|
return tables
|
|
2336
2361
|
|
|
2337
2362
|
def validate_against_generator(self, generator: Generator) -> None:
|
|
2338
|
-
|
|
2363
|
+
_SyntheticDataConfigValidation(synthetic_config=self, generator=generator)
|
|
2339
2364
|
|
|
2340
2365
|
|
|
2341
2366
|
class Generator(CustomBaseModel):
|
|
@@ -2811,9 +2836,81 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2811
2836
|
)
|
|
2812
2837
|
|
|
2813
2838
|
|
|
2814
|
-
class
|
|
2839
|
+
class _SyntheticTableConfigValidation(CustomBaseModel):
|
|
2815
2840
|
"""
|
|
2816
|
-
|
|
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
|
|
2817
2914
|
"""
|
|
2818
2915
|
|
|
2819
2916
|
synthetic_config: SyntheticDatasetConfig | SyntheticProbeConfig
|
|
@@ -2840,89 +2937,12 @@ class _SyntheticConfigValidation(CustomBaseModel):
|
|
|
2840
2937
|
return validation
|
|
2841
2938
|
|
|
2842
2939
|
@model_validator(mode="after")
|
|
2843
|
-
def
|
|
2844
|
-
generator_table_map = {t.name: t for t in validation.generator.tables}
|
|
2845
|
-
synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
|
|
2846
|
-
for table_name, synthetic_table in synthetic_table_map.items():
|
|
2847
|
-
generator_table = generator_table_map[table_name]
|
|
2848
|
-
config = synthetic_table.configuration
|
|
2849
|
-
if config and config.rebalancing:
|
|
2850
|
-
has_tabular_model = generator_table.tabular_model_configuration is not None
|
|
2851
|
-
if not has_tabular_model:
|
|
2852
|
-
raise ValueError(f"Table '{table_name}' specifies rebalancing but has no tabular model")
|
|
2853
|
-
rebalancing_column = config.rebalancing.column
|
|
2854
|
-
rebalancing_col = next(
|
|
2855
|
-
(col for col in generator_table.columns or [] if col.name == rebalancing_column), None
|
|
2856
|
-
)
|
|
2857
|
-
if not rebalancing_col:
|
|
2858
|
-
raise ValueError(f"Rebalancing column '{rebalancing_column}' not found in table '{table_name}'")
|
|
2859
|
-
if not rebalancing_col.model_encoding_type == ModelEncodingType.tabular_categorical:
|
|
2860
|
-
raise ValueError(
|
|
2861
|
-
f"Rebalancing column '{rebalancing_column}' in table '{table_name}' must be categorical"
|
|
2862
|
-
)
|
|
2863
|
-
for value in config.rebalancing.probabilities.keys():
|
|
2864
|
-
if value not in rebalancing_col.value_range.values:
|
|
2865
|
-
raise ValueError(
|
|
2866
|
-
f"Rebalancing value '{value}' not found in table '{table_name}' column '{rebalancing_column}'"
|
|
2867
|
-
)
|
|
2868
|
-
return validation
|
|
2869
|
-
|
|
2870
|
-
@model_validator(mode="after")
|
|
2871
|
-
def validate_imputation_configs(cls, validation):
|
|
2872
|
-
generator_table_map = {t.name: t for t in validation.generator.tables}
|
|
2873
|
-
synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
|
|
2874
|
-
for table_name, synthetic_table in synthetic_table_map.items():
|
|
2875
|
-
generator_table = generator_table_map[table_name]
|
|
2876
|
-
config = synthetic_table.configuration
|
|
2877
|
-
if config and config.imputation:
|
|
2878
|
-
has_tabular_model = generator_table.tabular_model_configuration is not None
|
|
2879
|
-
if not has_tabular_model:
|
|
2880
|
-
raise ValueError(f"Table '{table_name}' specifies imputation but has no tabular model")
|
|
2881
|
-
for col in config.imputation.columns:
|
|
2882
|
-
if not any(gcol.name == col for gcol in generator_table.columns or []):
|
|
2883
|
-
raise ValueError(f"Imputation column '{col}' not found in table '{table_name}'")
|
|
2884
|
-
return validation
|
|
2885
|
-
|
|
2886
|
-
@model_validator(mode="after")
|
|
2887
|
-
def validate_fairness_configs(cls, validation):
|
|
2940
|
+
def validate_tables(cls, validation):
|
|
2888
2941
|
generator_table_map = {t.name: t for t in validation.generator.tables}
|
|
2889
2942
|
synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
|
|
2890
2943
|
for table_name, synthetic_table in synthetic_table_map.items():
|
|
2891
2944
|
generator_table = generator_table_map[table_name]
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
if not has_tabular_model:
|
|
2896
|
-
raise ValueError(f"Table '{table_name}' specifies fairness but has no tabular model")
|
|
2897
|
-
target_col = config.fairness.target_column
|
|
2898
|
-
if not any(col.name == target_col for col in generator_table.columns or []):
|
|
2899
|
-
raise ValueError(f"Fairness target column '{target_col}' not found in table '{table_name}'")
|
|
2900
|
-
for col in config.fairness.sensitive_columns:
|
|
2901
|
-
if not any(gcol.name == col for gcol in generator_table.columns or []):
|
|
2902
|
-
raise ValueError(f"Fairness sensitive column '{col}' not found in table '{table_name}'")
|
|
2903
|
-
if target_col in config.fairness.sensitive_columns:
|
|
2904
|
-
raise ValueError(f"Target column '{target_col}' cannot be a sensitive column")
|
|
2905
|
-
return validation
|
|
2906
|
-
|
|
2907
|
-
@model_validator(mode="after")
|
|
2908
|
-
def set_default_sample_sizes(cls, validation):
|
|
2909
|
-
generator_table_map = {t.name: t for t in validation.generator.tables}
|
|
2910
|
-
synthetic_table_map = {t.name: t for t in validation.synthetic_config.tables or []}
|
|
2911
|
-
for table_name, synthetic_table in synthetic_table_map.items():
|
|
2912
|
-
generator_table = generator_table_map[table_name]
|
|
2913
|
-
config = synthetic_table.configuration
|
|
2914
|
-
if config:
|
|
2915
|
-
is_subject = not any(fk.is_context for fk in generator_table.foreign_keys or [])
|
|
2916
|
-
if (
|
|
2917
|
-
not config.sample_size
|
|
2918
|
-
and is_subject
|
|
2919
|
-
and (not (config.sample_seed_connector_id or config.sample_seed_dict or config.sample_seed_data))
|
|
2920
|
-
):
|
|
2921
|
-
config.sample_size = (
|
|
2922
|
-
1
|
|
2923
|
-
if isinstance(validation.synthetic_config, SyntheticProbeConfig)
|
|
2924
|
-
else generator_table.total_rows
|
|
2925
|
-
)
|
|
2926
|
-
elif not is_subject:
|
|
2927
|
-
config.sample_size = None
|
|
2945
|
+
synthetic_table.validate_against_source_table(
|
|
2946
|
+
generator_table, is_probe=isinstance(validation.synthetic_config, SyntheticProbeConfig)
|
|
2947
|
+
)
|
|
2928
2948
|
return validation
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mostlyai"
|
|
3
|
-
version = "4.
|
|
3
|
+
version = "4.1.1"
|
|
4
4
|
description = "Synthetic Data SDK"
|
|
5
5
|
authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
|
|
6
6
|
requires-python = ">=3.10,<3.14"
|
|
@@ -45,6 +45,7 @@ dependencies = [
|
|
|
45
45
|
"sshtunnel>=0.4.0,<0.5",
|
|
46
46
|
"xlsxwriter>=3.1.9,<4",
|
|
47
47
|
"openpyxl>=3.1.5",
|
|
48
|
+
"networkx>=3.0,<4",
|
|
48
49
|
# cloud-based connectors
|
|
49
50
|
"s3fs>=2023.1.0,<2024",
|
|
50
51
|
"gcsfs>=2023.1.0,<2024",
|
|
@@ -58,24 +59,24 @@ dependencies = [
|
|
|
58
59
|
[project.optional-dependencies]
|
|
59
60
|
local = [
|
|
60
61
|
# local
|
|
61
|
-
"mostlyai-engine==1.0.
|
|
62
|
-
"mostlyai-qa==1.5.
|
|
62
|
+
"mostlyai-engine==1.0.4",
|
|
63
|
+
"mostlyai-qa==1.5.3",
|
|
63
64
|
"fastapi>=0.115.6,<0.116",
|
|
64
65
|
"uvicorn>=0.34.0,<0.35",
|
|
65
66
|
"python-multipart>=0.0.20",
|
|
66
67
|
"torch>=2.5.1,<2.6.0",
|
|
67
68
|
]
|
|
68
69
|
local-gpu = [
|
|
69
|
-
"mostlyai-engine[gpu]==1.0.
|
|
70
|
-
"mostlyai-qa[gpu]==1.5.
|
|
70
|
+
"mostlyai-engine[gpu]==1.0.4",
|
|
71
|
+
"mostlyai-qa[gpu]==1.5.3",
|
|
71
72
|
"fastapi>=0.115.6,<0.116",
|
|
72
73
|
"uvicorn>=0.34.0,<0.35",
|
|
73
74
|
"python-multipart>=0.0.20",
|
|
74
75
|
"torch>=2.5.1,<2.6.0",
|
|
75
76
|
]
|
|
76
77
|
local-cpu = [
|
|
77
|
-
"mostlyai-engine[cpu]==1.0.
|
|
78
|
-
"mostlyai-qa[cpu]==1.5.
|
|
78
|
+
"mostlyai-engine[cpu]==1.0.4",
|
|
79
|
+
"mostlyai-qa[cpu]==1.5.3",
|
|
79
80
|
"fastapi>=0.115.6,<0.116",
|
|
80
81
|
"uvicorn>=0.34.0,<0.35",
|
|
81
82
|
"python-multipart>=0.0.20",
|
|
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-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_analyze_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.0.6 → mostlyai-4.1.1}/mostlyai/sdk/_local/execution/step_encode_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.0.6 → mostlyai-4.1.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
|