mostlyai 4.1.1__tar.gz → 4.1.2__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.1.1 → mostlyai-4.1.2}/PKG-INFO +5 -4
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/__init__.py +1 -1
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/routes.py +29 -3
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/storage.py +10 -6
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/client/api.py +7 -4
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/client/generators.py +17 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/client/synthetic_datasets.py +17 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/domain.py +141 -38
- {mostlyai-4.1.1 → mostlyai-4.1.2}/pyproject.toml +7 -6
- {mostlyai-4.1.1 → mostlyai-4.1.2}/.gitignore +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/LICENSE +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/README.md +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/__init__.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/auto_detect.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/base.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/context.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/conversions.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/__init__.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/base.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/bigquery.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/databricks.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/hive.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/mssql.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/mysql.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/oracle.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/postgresql.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/snowflake.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/sqlite.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/dtype.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/exceptions.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/__init__.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/base.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/container/aws.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/container/azure.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/container/minio.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/table/csv.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/table/feather.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/table/json.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/file/utils.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/language_model.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/metadata_objects.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/non_context.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/progress_callback.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/pull.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/pull_context.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/pull_utils.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/push.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/util/__init__.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/util/common.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_data/util/kerberos.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/__init__.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/cli.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/connectors.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/__init__.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/jobs.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/plan.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/generators.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/progress.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/server.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/client/__init__.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/client/_base_utils.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/client/_naming_conventions.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/client/_utils.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/client/base.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/client/connectors.py +0 -0
- {mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/client/exceptions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mostlyai
|
|
3
|
-
Version: 4.1.
|
|
3
|
+
Version: 4.1.2
|
|
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
|
|
@@ -33,6 +33,7 @@ Requires-Dist: gcsfs<2024,>=2023.1.0
|
|
|
33
33
|
Requires-Dist: greenlet<4,>=3.1.1
|
|
34
34
|
Requires-Dist: gunicorn>=23.0.0
|
|
35
35
|
Requires-Dist: httpx>=0.25.0
|
|
36
|
+
Requires-Dist: ipywidgets>=8.1.0
|
|
36
37
|
Requires-Dist: joblib>=1.2.0
|
|
37
38
|
Requires-Dist: networkx<4,>=3.0
|
|
38
39
|
Requires-Dist: openpyxl>=3.1.5
|
|
@@ -64,14 +65,14 @@ Requires-Dist: pyhive[hive-pure-sasl]<0.8,>=0.7.0; extra == 'hive'
|
|
|
64
65
|
Provides-Extra: local
|
|
65
66
|
Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local'
|
|
66
67
|
Requires-Dist: mostlyai-engine==1.0.4; extra == 'local'
|
|
67
|
-
Requires-Dist: mostlyai-qa==1.5.
|
|
68
|
+
Requires-Dist: mostlyai-qa==1.5.5; extra == 'local'
|
|
68
69
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local'
|
|
69
70
|
Requires-Dist: torch<2.6.0,>=2.5.1; extra == 'local'
|
|
70
71
|
Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local'
|
|
71
72
|
Provides-Extra: local-cpu
|
|
72
73
|
Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-cpu'
|
|
73
74
|
Requires-Dist: mostlyai-engine[cpu]==1.0.4; extra == 'local-cpu'
|
|
74
|
-
Requires-Dist: mostlyai-qa[cpu]==1.5.
|
|
75
|
+
Requires-Dist: mostlyai-qa[cpu]==1.5.5; extra == 'local-cpu'
|
|
75
76
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local-cpu'
|
|
76
77
|
Requires-Dist: torch<2.6.0,>=2.5.1; (sys_platform != 'linux') and extra == 'local-cpu'
|
|
77
78
|
Requires-Dist: torch==2.5.1+cpu; (sys_platform == 'linux') and extra == 'local-cpu'
|
|
@@ -79,7 +80,7 @@ Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local-cpu'
|
|
|
79
80
|
Provides-Extra: local-gpu
|
|
80
81
|
Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-gpu'
|
|
81
82
|
Requires-Dist: mostlyai-engine[gpu]==1.0.4; extra == 'local-gpu'
|
|
82
|
-
Requires-Dist: mostlyai-qa[gpu]==1.5.
|
|
83
|
+
Requires-Dist: mostlyai-qa[gpu]==1.5.5; extra == 'local-gpu'
|
|
83
84
|
Requires-Dist: python-multipart>=0.0.20; extra == 'local-gpu'
|
|
84
85
|
Requires-Dist: torch<2.6.0,>=2.5.1; extra == 'local-gpu'
|
|
85
86
|
Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local-gpu'
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import os
|
|
15
15
|
import shutil
|
|
16
16
|
import subprocess
|
|
17
|
+
import sys
|
|
17
18
|
import uuid
|
|
18
19
|
import zipfile
|
|
19
20
|
from io import BytesIO
|
|
@@ -290,7 +291,7 @@ class Routes:
|
|
|
290
291
|
if len(connector_dirs) < len(generator.tables):
|
|
291
292
|
raise HTTPException(
|
|
292
293
|
status_code=400,
|
|
293
|
-
detail="
|
|
294
|
+
detail="Cannot clone a generator whose connectors have been deleted.",
|
|
294
295
|
)
|
|
295
296
|
|
|
296
297
|
# check if any connectors are file upload
|
|
@@ -330,12 +331,26 @@ class Routes:
|
|
|
330
331
|
|
|
331
332
|
# call shell script to start training job
|
|
332
333
|
cli_py = str((Path(os.path.dirname(os.path.realpath(__file__))) / "cli.py").absolute())
|
|
333
|
-
cmd = [
|
|
334
|
+
cmd = [sys.executable, cli_py, "run-training", generator.id, str(self.home_dir.absolute())]
|
|
334
335
|
subprocess.Popen(cmd)
|
|
335
336
|
|
|
337
|
+
@self.router.get("/generators/{id}/training/logs", response_class=StreamingResponse)
|
|
338
|
+
async def download_training_logs(id: str, slft: str) -> StreamingResponse:
|
|
339
|
+
_ = slft # ignore parameter
|
|
340
|
+
generator_dir = self.home_dir / "generators" / id
|
|
341
|
+
zip_buffer = create_zip_in_memory(generator_dir, "*.log")
|
|
342
|
+
return StreamingResponse(
|
|
343
|
+
zip_buffer,
|
|
344
|
+
media_type="application/zip",
|
|
345
|
+
headers={"Content-Disposition": f"attachment; filename=generator-{id[:8]}-logs.zip"},
|
|
346
|
+
)
|
|
347
|
+
|
|
336
348
|
@self.router.get("/generators/{id}/export-to-file", response_class=StreamingResponse)
|
|
337
349
|
async def export_generator_to_file(id: str) -> StreamingResponse:
|
|
338
350
|
generator_dir = self.home_dir / "generators" / id
|
|
351
|
+
generator = read_generator_from_json(generator_dir)
|
|
352
|
+
if generator.training_status != ProgressStatus.done:
|
|
353
|
+
raise HTTPException(status_code=400, detail="Cannot export generator that is not trained")
|
|
339
354
|
zip_buffer = create_zip_in_memory(generator_dir)
|
|
340
355
|
return StreamingResponse(
|
|
341
356
|
zip_buffer,
|
|
@@ -456,9 +471,20 @@ class Routes:
|
|
|
456
471
|
|
|
457
472
|
# call shell script to start generation job
|
|
458
473
|
cli_py = str((Path(os.path.dirname(os.path.realpath(__file__))) / "cli.py").absolute())
|
|
459
|
-
cmd = [
|
|
474
|
+
cmd = [sys.executable, cli_py, "run-generation", synthetic_dataset.id, str(self.home_dir.absolute())]
|
|
460
475
|
subprocess.Popen(cmd)
|
|
461
476
|
|
|
477
|
+
@self.router.get("/synthetic-datasets/{id}/generation/logs", response_class=StreamingResponse)
|
|
478
|
+
async def download_generation_logs(id: str, slft: str) -> StreamingResponse:
|
|
479
|
+
_ = slft # ignore parameter
|
|
480
|
+
synthetic_dataset_dir = self.home_dir / "synthetic-datasets" / id
|
|
481
|
+
zip_buffer = create_zip_in_memory(synthetic_dataset_dir, "*.log")
|
|
482
|
+
return StreamingResponse(
|
|
483
|
+
zip_buffer,
|
|
484
|
+
media_type="application/zip",
|
|
485
|
+
headers={"Content-Disposition": f"attachment; filename=synthetic-dataset-{id[:8]}-logs.zip"},
|
|
486
|
+
)
|
|
487
|
+
|
|
462
488
|
@self.router.get("/synthetic-datasets/{id}/config", response_model=SyntheticDatasetConfig)
|
|
463
489
|
async def get_synthetic_dataset_config(id: str) -> SyntheticDatasetConfig:
|
|
464
490
|
return synthetic_datasets.get_synthetic_dataset_config(self.home_dir, id)
|
|
@@ -69,15 +69,19 @@ def write_synthetic_dataset_to_json(synthetic_dataset_dir: Path, synthetic_datas
|
|
|
69
69
|
write_to_json(json_file, synthetic_dataset)
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
def create_zip_in_memory(
|
|
72
|
+
def create_zip_in_memory(path: Path, pattern: str = "*") -> BytesIO:
|
|
73
73
|
# Create an in-memory zip file
|
|
74
74
|
zip_buffer = BytesIO()
|
|
75
75
|
with zipfile.ZipFile(zip_buffer, "w") as zip_file:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
#
|
|
80
|
-
|
|
76
|
+
if path.is_dir():
|
|
77
|
+
# Iterate over all files in the directory and subdirectories
|
|
78
|
+
for file_path in path.rglob(pattern):
|
|
79
|
+
if file_path.is_file(): # Ensure it's a file (not a directory)
|
|
80
|
+
# Add file to the zip archive, keeping the directory structure
|
|
81
|
+
zip_file.write(file_path, file_path.relative_to(path))
|
|
82
|
+
else:
|
|
83
|
+
# Add the single file to the zip archive
|
|
84
|
+
zip_file.write(path, path.name)
|
|
81
85
|
# Ensure the buffer is ready for streaming
|
|
82
86
|
zip_buffer.seek(0)
|
|
83
87
|
return zip_buffer
|
|
@@ -53,9 +53,9 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
53
53
|
Example for instantiating the SDK in local mode:
|
|
54
54
|
```python
|
|
55
55
|
from mostlyai.sdk import MostlyAI
|
|
56
|
-
mostly = MostlyAI(local=True
|
|
56
|
+
mostly = MostlyAI(local=True)
|
|
57
57
|
mostly
|
|
58
|
-
# MostlyAI(
|
|
58
|
+
# MostlyAI(local=True)
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
Example for instantiating the SDK in client mode with explicit arguments:
|
|
@@ -150,8 +150,11 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
150
150
|
rich.print(f"Failed to connect to {self.base_url}: {e}.")
|
|
151
151
|
|
|
152
152
|
def __repr__(self) -> str:
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
if self.local:
|
|
154
|
+
return "MostlyAI(local=True)"
|
|
155
|
+
else:
|
|
156
|
+
api_key = "'***'" if self.api_key else "None"
|
|
157
|
+
return f"MostlyAI(base_url='{self.base_url}', api_key={api_key})"
|
|
155
158
|
|
|
156
159
|
def connect(
|
|
157
160
|
self,
|
|
@@ -299,3 +299,20 @@ class _MostlyGeneratorsClient(_MostlyBaseClient):
|
|
|
299
299
|
job_wait(lambda: self._training_progress(generator_id), interval, progress_bar)
|
|
300
300
|
generator = self.get(generator_id)
|
|
301
301
|
return generator
|
|
302
|
+
|
|
303
|
+
def _training_logs(self, generator_id: str, short_lived_file_token: str | None = None) -> (bytes, str):
|
|
304
|
+
response = self.request(
|
|
305
|
+
verb=GET,
|
|
306
|
+
path=[generator_id, "training", "logs"],
|
|
307
|
+
params={
|
|
308
|
+
"slft": short_lived_file_token,
|
|
309
|
+
},
|
|
310
|
+
headers={
|
|
311
|
+
"Content-Type": "application/zip",
|
|
312
|
+
"Accept": "application/json, text/plain, */*",
|
|
313
|
+
},
|
|
314
|
+
raw_response=True,
|
|
315
|
+
)
|
|
316
|
+
content_bytes = response.content
|
|
317
|
+
filename = f"generator-{generator_id[:8]}-logs.zip"
|
|
318
|
+
return content_bytes, filename
|
|
@@ -286,6 +286,23 @@ class _MostlySyntheticDatasetsClient(_MostlyBaseClient):
|
|
|
286
286
|
synthetic_dataset = self.get(synthetic_dataset_id)
|
|
287
287
|
return synthetic_dataset
|
|
288
288
|
|
|
289
|
+
def _generation_logs(self, synthetic_dataset_id: str, short_lived_file_token: str | None = None) -> (bytes, str):
|
|
290
|
+
response = self.request(
|
|
291
|
+
verb=GET,
|
|
292
|
+
path=[synthetic_dataset_id, "generation", "logs"],
|
|
293
|
+
params={
|
|
294
|
+
"slft": short_lived_file_token,
|
|
295
|
+
},
|
|
296
|
+
headers={
|
|
297
|
+
"Content-Type": "application/zip",
|
|
298
|
+
"Accept": "application/json, text/plain, */*",
|
|
299
|
+
},
|
|
300
|
+
raw_response=True,
|
|
301
|
+
)
|
|
302
|
+
content_bytes = response.content
|
|
303
|
+
filename = f"synthetic-dataset-{synthetic_dataset_id[:8]}-logs.zip"
|
|
304
|
+
return content_bytes, filename
|
|
305
|
+
|
|
289
306
|
|
|
290
307
|
class _MostlySyntheticProbesClient(_MostlyBaseClient):
|
|
291
308
|
SECTION = ["synthetic-probes"]
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
# generated by datamodel-codegen:
|
|
16
|
-
# timestamp: 2025-02-
|
|
16
|
+
# timestamp: 2025-02-13T12:18:42+00:00
|
|
17
17
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
@@ -688,7 +688,7 @@ class AssistantMessage(CustomBaseModel):
|
|
|
688
688
|
id: str | None = Field(None, description="The unique identifier of a assistant message.")
|
|
689
689
|
role: AssistantMessageRole | None = None
|
|
690
690
|
content_type: AssistantMessageContentType | None = Field(None, alias="contentType")
|
|
691
|
-
content: str | None = Field(None, description="The content of a message",
|
|
691
|
+
content: str | None = Field(None, description="The content of a message", min_length=0)
|
|
692
692
|
finish_reason: AssistantMessageFinishReason | None = Field(None, alias="finishReason")
|
|
693
693
|
tokens_consumed: int | None = Field(
|
|
694
694
|
None,
|
|
@@ -705,12 +705,7 @@ class AssistantMessageDelta(CustomBaseModel):
|
|
|
705
705
|
id: str | None = Field(None, description="The unique identifier of a assistant message.")
|
|
706
706
|
role: AssistantMessageRole | None = None
|
|
707
707
|
content_type: AssistantMessageContentType | None = Field(None, alias="contentType")
|
|
708
|
-
delta: str | None = Field(
|
|
709
|
-
None,
|
|
710
|
-
description="The partial content of a message",
|
|
711
|
-
max_length=65000,
|
|
712
|
-
min_length=1,
|
|
713
|
-
)
|
|
708
|
+
delta: str | None = Field(None, description="The partial content of a message", min_length=0)
|
|
714
709
|
finish_reason: AssistantMessageFinishReason | None = Field(None, alias="finishReason")
|
|
715
710
|
tokens_consumed: int | None = Field(
|
|
716
711
|
None,
|
|
@@ -744,7 +739,7 @@ class AssistantMessageConfig(CustomBaseModel):
|
|
|
744
739
|
True,
|
|
745
740
|
description="Whether to stream back partial progress. If set, message deltas will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a data: [DONE] message.",
|
|
746
741
|
)
|
|
747
|
-
content: str | None = Field(None, description="The content of a message",
|
|
742
|
+
content: str | None = Field(None, description="The content of a message", min_length=0)
|
|
748
743
|
content_type: AssistantMessageContentType | None = Field(None, alias="contentType")
|
|
749
744
|
|
|
750
745
|
|
|
@@ -1644,6 +1639,7 @@ class SourceColumn(CustomBaseModel):
|
|
|
1644
1639
|
name: str = Field(
|
|
1645
1640
|
...,
|
|
1646
1641
|
description="The name of a source column. It must be unique within a source table.",
|
|
1642
|
+
max_length=256,
|
|
1647
1643
|
min_length=1,
|
|
1648
1644
|
)
|
|
1649
1645
|
included: bool | None = Field(
|
|
@@ -1684,6 +1680,7 @@ class SourceColumnConfig(CustomBaseModel):
|
|
|
1684
1680
|
name: str = Field(
|
|
1685
1681
|
...,
|
|
1686
1682
|
description="The name of a source column. It must be unique within a source table.",
|
|
1683
|
+
max_length=256,
|
|
1687
1684
|
min_length=1,
|
|
1688
1685
|
)
|
|
1689
1686
|
model_encoding_type: ModelEncodingType | None = Field(ModelEncodingType.auto, alias="modelEncodingType")
|
|
@@ -2064,6 +2061,7 @@ class SourceTable(CustomBaseModel):
|
|
|
2064
2061
|
name: str = Field(
|
|
2065
2062
|
...,
|
|
2066
2063
|
description="The name of a source table. It must be unique within a generator.",
|
|
2064
|
+
max_length=256,
|
|
2067
2065
|
min_length=1,
|
|
2068
2066
|
)
|
|
2069
2067
|
primary_key: str | None = Field(None, alias="primaryKey", description="The column name of the primary key.")
|
|
@@ -2098,6 +2096,7 @@ class SourceTableConfig(CustomBaseModel):
|
|
|
2098
2096
|
name: str = Field(
|
|
2099
2097
|
...,
|
|
2100
2098
|
description="The name of a source table. It must be unique within a generator.",
|
|
2099
|
+
max_length=256,
|
|
2101
2100
|
min_length=1,
|
|
2102
2101
|
)
|
|
2103
2102
|
source_connector_id: str | None = Field(
|
|
@@ -2128,6 +2127,23 @@ class SourceTableConfig(CustomBaseModel):
|
|
|
2128
2127
|
def convert_data_before(cls, value):
|
|
2129
2128
|
return convert_to_base64(value) if isinstance(value, pd.DataFrame) else value
|
|
2130
2129
|
|
|
2130
|
+
@field_validator("columns", mode="before")
|
|
2131
|
+
@classmethod
|
|
2132
|
+
def filter_excluded_columns(cls, columns):
|
|
2133
|
+
if columns is None or not isinstance(columns, list):
|
|
2134
|
+
return columns
|
|
2135
|
+
included_columns = []
|
|
2136
|
+
for column in columns:
|
|
2137
|
+
is_included = any(
|
|
2138
|
+
(
|
|
2139
|
+
isinstance(column, dict) and bool(column.get("included", True)),
|
|
2140
|
+
isinstance(column, SourceColumn) and column.included,
|
|
2141
|
+
)
|
|
2142
|
+
)
|
|
2143
|
+
if is_included:
|
|
2144
|
+
included_columns.append(column)
|
|
2145
|
+
return included_columns
|
|
2146
|
+
|
|
2131
2147
|
@model_validator(mode="after")
|
|
2132
2148
|
@classmethod
|
|
2133
2149
|
def add_model_configuration(cls, values):
|
|
@@ -2148,11 +2164,11 @@ class SourceTableConfig(CustomBaseModel):
|
|
|
2148
2164
|
for fk in values.foreign_keys:
|
|
2149
2165
|
if fk.is_context:
|
|
2150
2166
|
has_tabular_model = True
|
|
2151
|
-
#
|
|
2167
|
+
# Remove model configurations that are not applicable for the model type
|
|
2152
2168
|
if values.tabular_model_configuration and not has_tabular_model:
|
|
2153
|
-
|
|
2169
|
+
values.tabular_model_configuration = None
|
|
2154
2170
|
if values.language_model_configuration and not has_language_model:
|
|
2155
|
-
|
|
2171
|
+
values.language_model_configuration = None
|
|
2156
2172
|
# Add default model configurations if none were provided
|
|
2157
2173
|
if has_tabular_model and not values.tabular_model_configuration:
|
|
2158
2174
|
default_model = "MOSTLY_AI/Medium"
|
|
@@ -2216,6 +2232,7 @@ class SourceTablePatchConfig(CustomBaseModel):
|
|
|
2216
2232
|
name: str | None = Field(
|
|
2217
2233
|
None,
|
|
2218
2234
|
description="The name of a source table. It must be unique within a generator.",
|
|
2235
|
+
max_length=256,
|
|
2219
2236
|
min_length=1,
|
|
2220
2237
|
)
|
|
2221
2238
|
primary_key: str | None = Field(None, alias="primaryKey", description="The column name of the primary key.")
|
|
@@ -2240,6 +2257,7 @@ class SourceTableAddConfig(CustomBaseModel):
|
|
|
2240
2257
|
name: str | None = Field(
|
|
2241
2258
|
None,
|
|
2242
2259
|
description="The name of a source table. It must be unique within a generator.",
|
|
2260
|
+
max_length=256,
|
|
2243
2261
|
min_length=1,
|
|
2244
2262
|
)
|
|
2245
2263
|
include_children: bool | None = Field(
|
|
@@ -2283,6 +2301,7 @@ class SyntheticTable(CustomBaseModel):
|
|
|
2283
2301
|
name: str = Field(
|
|
2284
2302
|
...,
|
|
2285
2303
|
description="The name of a source table. It must be unique within a generator.",
|
|
2304
|
+
max_length=256,
|
|
2286
2305
|
min_length=1,
|
|
2287
2306
|
)
|
|
2288
2307
|
configuration: SyntheticTableConfiguration | None = None
|
|
@@ -2473,15 +2492,19 @@ class Generator(CustomBaseModel):
|
|
|
2473
2492
|
"""
|
|
2474
2493
|
return self.client._clone(generator_id=self.id, training_status=training_status)
|
|
2475
2494
|
|
|
2476
|
-
def reports(self, file_path: str | Path | None = None) -> Path:
|
|
2495
|
+
def reports(self, file_path: str | Path | None = None, display: bool = False) -> Path | None:
|
|
2477
2496
|
"""
|
|
2478
|
-
Download the quality assurance reports
|
|
2497
|
+
Download or display the quality assurance reports.
|
|
2498
|
+
|
|
2499
|
+
If display is True, the report is rendered inline via IPython display and no file is downloaded.
|
|
2500
|
+
Otherwise, the report is downloaded and saved to file_path (or a default location if None).
|
|
2479
2501
|
|
|
2480
2502
|
Args:
|
|
2481
|
-
file_path: The file path to save the zipped reports.
|
|
2503
|
+
file_path: The file path to save the zipped reports (ignored if display=True).
|
|
2504
|
+
display: If True, render the report inline instead of downloading it.
|
|
2482
2505
|
|
|
2483
2506
|
Returns:
|
|
2484
|
-
The path to the saved file.
|
|
2507
|
+
The path to the saved file if downloading, or None if display=True.
|
|
2485
2508
|
"""
|
|
2486
2509
|
reports = {}
|
|
2487
2510
|
for table in self.tables:
|
|
@@ -2500,15 +2523,31 @@ class Generator(CustomBaseModel):
|
|
|
2500
2523
|
short_lived_file_token=(self.metadata.short_lived_file_token if self.metadata else None),
|
|
2501
2524
|
)
|
|
2502
2525
|
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2526
|
+
if display:
|
|
2527
|
+
if not rich.console._is_jupyter():
|
|
2528
|
+
raise ValueError("Displaying reports is only supported in Jupyter notebooks.")
|
|
2529
|
+
|
|
2530
|
+
import html # noqa
|
|
2531
|
+
|
|
2532
|
+
from IPython.display import HTML, display # noqa
|
|
2533
|
+
|
|
2534
|
+
iframes = ""
|
|
2535
|
+
for content in reports.values():
|
|
2536
|
+
content = html.escape(content, quote=True)
|
|
2537
|
+
iframes += f'<p><iframe srcdoc="{content}" width="100%" height="600"></iframe></p> '
|
|
2538
|
+
|
|
2539
|
+
display(HTML(iframes))
|
|
2540
|
+
return None
|
|
2541
|
+
else:
|
|
2542
|
+
file_path = Path(file_path or ".")
|
|
2543
|
+
if file_path.is_dir():
|
|
2544
|
+
file_path = file_path / f"generator-{self.id[:8]}-reports.zip"
|
|
2545
|
+
if file_path.exists():
|
|
2546
|
+
file_path.unlink()
|
|
2547
|
+
with zipfile.ZipFile(file_path, "w", zipfile.ZIP_DEFLATED) as zip_file:
|
|
2548
|
+
for filename, content in reports.items():
|
|
2549
|
+
zip_file.writestr(filename, content)
|
|
2550
|
+
return file_path
|
|
2512
2551
|
|
|
2513
2552
|
class Training:
|
|
2514
2553
|
def __init__(self, _generator: Generator):
|
|
@@ -2554,6 +2593,28 @@ class Generator(CustomBaseModel):
|
|
|
2554
2593
|
"Publish it so others can do the same."
|
|
2555
2594
|
)
|
|
2556
2595
|
|
|
2596
|
+
def logs(self, file_path: str | Path | None = None) -> Path:
|
|
2597
|
+
"""
|
|
2598
|
+
Download the training logs and save to file.
|
|
2599
|
+
|
|
2600
|
+
Args:
|
|
2601
|
+
file_path: The file path to save the logs.
|
|
2602
|
+
|
|
2603
|
+
Returns:
|
|
2604
|
+
The path to the saved file.
|
|
2605
|
+
"""
|
|
2606
|
+
bytes, filename = self.generator.client._training_logs(
|
|
2607
|
+
generator_id=self.generator.id,
|
|
2608
|
+
short_lived_file_token=(
|
|
2609
|
+
self.generator.metadata.short_lived_file_token if self.generator.metadata else None
|
|
2610
|
+
),
|
|
2611
|
+
)
|
|
2612
|
+
file_path = Path(file_path or ".")
|
|
2613
|
+
if file_path.is_dir():
|
|
2614
|
+
file_path = file_path / filename
|
|
2615
|
+
file_path.write_bytes(bytes)
|
|
2616
|
+
return file_path
|
|
2617
|
+
|
|
2557
2618
|
|
|
2558
2619
|
class GeneratorConfig(CustomBaseModel):
|
|
2559
2620
|
"""
|
|
@@ -2745,15 +2806,19 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2745
2806
|
else:
|
|
2746
2807
|
return dfs
|
|
2747
2808
|
|
|
2748
|
-
def reports(self, file_path: str | Path | None = None) -> Path:
|
|
2809
|
+
def reports(self, file_path: str | Path | None = None, display: bool = False) -> Path | None:
|
|
2749
2810
|
"""
|
|
2750
|
-
Download the quality assurance reports
|
|
2811
|
+
Download or display the quality assurance reports.
|
|
2812
|
+
|
|
2813
|
+
If display is True, the report is rendered inline via IPython display and no file is downloaded.
|
|
2814
|
+
Otherwise, the report is downloaded and saved to file_path (or a default location if None).
|
|
2751
2815
|
|
|
2752
2816
|
Args:
|
|
2753
|
-
file_path: The file path to save the zipped reports.
|
|
2817
|
+
file_path: The file path to save the zipped reports (ignored if display=True).
|
|
2818
|
+
display: If True, render the report inline instead of downloading it.
|
|
2754
2819
|
|
|
2755
2820
|
Returns:
|
|
2756
|
-
The path to the saved file.
|
|
2821
|
+
The path to the saved file if downloading, or None if display=True.
|
|
2757
2822
|
"""
|
|
2758
2823
|
reports = {}
|
|
2759
2824
|
for report_type in [
|
|
@@ -2779,15 +2844,31 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2779
2844
|
short_lived_file_token=(self.metadata.short_lived_file_token if self.metadata else None),
|
|
2780
2845
|
)
|
|
2781
2846
|
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2847
|
+
if display:
|
|
2848
|
+
if not rich.console._is_jupyter():
|
|
2849
|
+
raise ValueError("Displaying reports is only supported in Jupyter notebooks.")
|
|
2850
|
+
|
|
2851
|
+
import html # noqa
|
|
2852
|
+
|
|
2853
|
+
from IPython.display import HTML, display # noqa
|
|
2854
|
+
|
|
2855
|
+
iframes = ""
|
|
2856
|
+
for content in reports.values():
|
|
2857
|
+
content = html.escape(content, quote=True)
|
|
2858
|
+
iframes += f'<p><iframe srcdoc="{content}" width="100%" height="600"></iframe></p> '
|
|
2859
|
+
|
|
2860
|
+
display(HTML(iframes))
|
|
2861
|
+
return None
|
|
2862
|
+
else:
|
|
2863
|
+
file_path = Path(file_path or ".")
|
|
2864
|
+
if file_path.is_dir():
|
|
2865
|
+
file_path = file_path / f"synthetic-dataset-{self.id[:8]}-reports.zip"
|
|
2866
|
+
if file_path.exists():
|
|
2867
|
+
file_path.unlink()
|
|
2868
|
+
with zipfile.ZipFile(file_path, "w", zipfile.ZIP_DEFLATED) as zip_file:
|
|
2869
|
+
for filename, content in reports.items():
|
|
2870
|
+
zip_file.writestr(filename, content)
|
|
2871
|
+
return file_path
|
|
2791
2872
|
|
|
2792
2873
|
class Generation:
|
|
2793
2874
|
def __init__(self, _synthetic_dataset: SyntheticDataset):
|
|
@@ -2835,6 +2916,28 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
2835
2916
|
"Publish it so others can do the same."
|
|
2836
2917
|
)
|
|
2837
2918
|
|
|
2919
|
+
def logs(self, file_path: str | Path | None = None) -> Path:
|
|
2920
|
+
"""
|
|
2921
|
+
Download the generation logs and save to file.
|
|
2922
|
+
|
|
2923
|
+
Args:
|
|
2924
|
+
file_path: The file path to save the logs.
|
|
2925
|
+
|
|
2926
|
+
Returns:
|
|
2927
|
+
The path to the saved file.
|
|
2928
|
+
"""
|
|
2929
|
+
bytes, filename = self.synthetic_dataset.client._generation_logs(
|
|
2930
|
+
synthetic_dataset_id=self.synthetic_dataset.id,
|
|
2931
|
+
short_lived_file_token=(
|
|
2932
|
+
self.synthetic_dataset.metadata.short_lived_file_token if self.synthetic_dataset.metadata else None
|
|
2933
|
+
),
|
|
2934
|
+
)
|
|
2935
|
+
file_path = Path(file_path or ".")
|
|
2936
|
+
if file_path.is_dir():
|
|
2937
|
+
file_path = file_path / filename
|
|
2938
|
+
file_path.write_bytes(bytes)
|
|
2939
|
+
return file_path
|
|
2940
|
+
|
|
2838
2941
|
|
|
2839
2942
|
class _SyntheticTableConfigValidation(CustomBaseModel):
|
|
2840
2943
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mostlyai"
|
|
3
|
-
version = "4.1.
|
|
3
|
+
version = "4.1.2"
|
|
4
4
|
description = "Synthetic Data SDK"
|
|
5
5
|
authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
|
|
6
6
|
requires-python = ">=3.10,<3.14"
|
|
@@ -46,6 +46,7 @@ dependencies = [
|
|
|
46
46
|
"xlsxwriter>=3.1.9,<4",
|
|
47
47
|
"openpyxl>=3.1.5",
|
|
48
48
|
"networkx>=3.0,<4",
|
|
49
|
+
"ipywidgets>=8.1.0",
|
|
49
50
|
# cloud-based connectors
|
|
50
51
|
"s3fs>=2023.1.0,<2024",
|
|
51
52
|
"gcsfs>=2023.1.0,<2024",
|
|
@@ -60,7 +61,7 @@ dependencies = [
|
|
|
60
61
|
local = [
|
|
61
62
|
# local
|
|
62
63
|
"mostlyai-engine==1.0.4",
|
|
63
|
-
"mostlyai-qa==1.5.
|
|
64
|
+
"mostlyai-qa==1.5.5",
|
|
64
65
|
"fastapi>=0.115.6,<0.116",
|
|
65
66
|
"uvicorn>=0.34.0,<0.35",
|
|
66
67
|
"python-multipart>=0.0.20",
|
|
@@ -68,7 +69,7 @@ local = [
|
|
|
68
69
|
]
|
|
69
70
|
local-gpu = [
|
|
70
71
|
"mostlyai-engine[gpu]==1.0.4",
|
|
71
|
-
"mostlyai-qa[gpu]==1.5.
|
|
72
|
+
"mostlyai-qa[gpu]==1.5.5",
|
|
72
73
|
"fastapi>=0.115.6,<0.116",
|
|
73
74
|
"uvicorn>=0.34.0,<0.35",
|
|
74
75
|
"python-multipart>=0.0.20",
|
|
@@ -76,7 +77,7 @@ local-gpu = [
|
|
|
76
77
|
]
|
|
77
78
|
local-cpu = [
|
|
78
79
|
"mostlyai-engine[cpu]==1.0.4",
|
|
79
|
-
"mostlyai-qa[cpu]==1.5.
|
|
80
|
+
"mostlyai-qa[cpu]==1.5.5",
|
|
80
81
|
"fastapi>=0.115.6,<0.116",
|
|
81
82
|
"uvicorn>=0.34.0,<0.35",
|
|
82
83
|
"python-multipart>=0.0.20",
|
|
@@ -105,10 +106,10 @@ dev = [
|
|
|
105
106
|
"vcrpy>=5.1.0,<6",
|
|
106
107
|
"ruff==0.9.2",
|
|
107
108
|
"respx>=0.20.2,<0.21",
|
|
108
|
-
"twine>=6.0
|
|
109
|
-
"pkginfo>=1.12.0,<2",
|
|
109
|
+
"twine>=6.1.0,<7",
|
|
110
110
|
"poetry-bumpversion>=0.3.2,<0.4",
|
|
111
111
|
"httpx<0.28",
|
|
112
|
+
"ipykernel>=6.25.2",
|
|
112
113
|
]
|
|
113
114
|
docs = [
|
|
114
115
|
"mkdocs>=1.5.3",
|
|
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-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_analyze_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.1.1 → mostlyai-4.1.2}/mostlyai/sdk/_local/execution/step_encode_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.1.1 → mostlyai-4.1.2}/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
|