mostlyai 0.1.1__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mostlyai-0.1.1 → mostlyai-0.2.0}/PKG-INFO +4 -4
- {mostlyai-0.1.1 → mostlyai-0.2.0}/README.md +1 -1
- {mostlyai-0.1.1 → mostlyai-0.2.0}/mostlyai/api.py +3 -1
- {mostlyai-0.1.1 → mostlyai-0.2.0}/mostlyai/base.py +1 -1
- mostlyai-0.2.0/mostlyai/exceptions.py +21 -0
- {mostlyai-0.1.1 → mostlyai-0.2.0}/mostlyai/model.py +47 -33
- {mostlyai-0.1.1 → mostlyai-0.2.0}/mostlyai/utils.py +36 -5
- {mostlyai-0.1.1 → mostlyai-0.2.0}/pyproject.toml +5 -2
- mostlyai-0.1.1/mostlyai/exceptions.py +0 -13
- {mostlyai-0.1.1 → mostlyai-0.2.0}/LICENSE +0 -0
- {mostlyai-0.1.1 → mostlyai-0.2.0}/mostlyai/__init__.py +0 -0
- {mostlyai-0.1.1 → mostlyai-0.2.0}/mostlyai/connectors.py +0 -0
- {mostlyai-0.1.1 → mostlyai-0.2.0}/mostlyai/generators.py +0 -0
- {mostlyai-0.1.1 → mostlyai-0.2.0}/mostlyai/shares.py +0 -0
- {mostlyai-0.1.1 → mostlyai-0.2.0}/mostlyai/synthetic_datasets.py +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mostlyai
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: The official Python
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: The official Python client for the MOSTLY AI platform.
|
|
5
|
+
Home-page: https://app.mostly.ai/
|
|
5
6
|
License: Proprietary
|
|
6
7
|
Author: MOSTLY AI
|
|
7
8
|
Author-email: office@mostly.ai
|
|
@@ -11,7 +12,6 @@ Classifier: Programming Language :: Python :: 3
|
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.9
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Requires-Dist: httpx (>=0.25.1,<0.26.0)
|
|
16
16
|
Requires-Dist: pandas (>=1.5.3,<3.0.0)
|
|
17
17
|
Requires-Dist: pyarrow (>=14.0.2,<15.0.0)
|
|
@@ -21,7 +21,7 @@ Description-Content-Type: text/markdown
|
|
|
21
21
|
|
|
22
22
|
# MOSTLY AI - GenAI for Tabular Data
|
|
23
23
|
|
|
24
|
-
A Python wrapper for the MOSTLY AI platform.
|
|
24
|
+
A Python wrapper for the MOSTLY AI platform (https://app.mostly.ai/).
|
|
25
25
|
|
|
26
26
|
| Intent | Primitive |
|
|
27
27
|
|-------------------------------------------------|----------------------------|
|
|
@@ -172,6 +172,8 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
172
172
|
:param wait: If true, then the function only returns once training has finished. Default: true.
|
|
173
173
|
:return: The created generator.
|
|
174
174
|
"""
|
|
175
|
+
if data is not None and config is not None:
|
|
176
|
+
raise ValueError("Either data or config must be provided, but not both")
|
|
175
177
|
if isinstance(data, (str, Path)):
|
|
176
178
|
name, df = _read_table_from_path(data)
|
|
177
179
|
config = {"name": name, "tables": [{"data": df, "name": name}]}
|
|
@@ -204,7 +206,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
204
206
|
|
|
205
207
|
def generate(
|
|
206
208
|
self,
|
|
207
|
-
generator: Union[Generator, str, None],
|
|
209
|
+
generator: Union[Generator, str, None] = None,
|
|
208
210
|
size: Union[int, dict[str, int], None] = None,
|
|
209
211
|
seed: Union[
|
|
210
212
|
pd.DataFrame, str, Path, dict[str, Union[pd.DataFrame, str, Path]], None
|
|
@@ -201,7 +201,7 @@ class CustomBaseModel(BaseModel):
|
|
|
201
201
|
OPEN_URL_PARTS: ClassVar[list] = None # ["d", "object-name"]
|
|
202
202
|
client: Annotated[Optional[Any], Field(exclude=True, repr=False)] = None
|
|
203
203
|
extra_key_values: Annotated[Optional[dict], Field(exclude=True, repr=False)] = None
|
|
204
|
-
model_config = ConfigDict(protected_namespaces=())
|
|
204
|
+
model_config = ConfigDict(protected_namespaces=(), populate_by_name=True)
|
|
205
205
|
|
|
206
206
|
def _repr_html_(self):
|
|
207
207
|
# Use rich.print to create a rich representation of the model
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from rich.console import Console
|
|
2
|
+
from rich.panel import Panel
|
|
3
|
+
from rich.text import Text
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class APIError(Exception):
|
|
7
|
+
def __init__(self, message: str = None, do_rich_print: bool = True):
|
|
8
|
+
super().__init__(message)
|
|
9
|
+
self.message = message
|
|
10
|
+
if do_rich_print:
|
|
11
|
+
console = Console()
|
|
12
|
+
error_message = Text(self.message, style="bold red")
|
|
13
|
+
error_panel = Panel(error_message, expand=False)
|
|
14
|
+
console.print(error_panel)
|
|
15
|
+
|
|
16
|
+
def __str__(self):
|
|
17
|
+
return self.message
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class APIStatusError(APIError):
|
|
21
|
+
pass
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# generated by datamodel-codegen:
|
|
2
|
-
# timestamp: 2024-
|
|
2
|
+
# timestamp: 2024-03-07T15:01:14+00:00
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
@@ -14,20 +14,6 @@ from pydantic import Field, RootModel
|
|
|
14
14
|
from mostlyai.base import CustomBaseModel
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
class BaseResource(CustomBaseModel):
|
|
18
|
-
id: Annotated[
|
|
19
|
-
Optional[str], Field(description="The unique identifier of the entity")
|
|
20
|
-
] = None
|
|
21
|
-
name: Annotated[Optional[str], Field(description="The name of the entity")] = None
|
|
22
|
-
uri: Annotated[
|
|
23
|
-
Optional[str],
|
|
24
|
-
Field(
|
|
25
|
-
description="The API service endpoint of the entity",
|
|
26
|
-
example="/generators/94c77249-42bf-443a-8e17-6e18a19d60b8",
|
|
27
|
-
),
|
|
28
|
-
] = None
|
|
29
|
-
|
|
30
|
-
|
|
31
17
|
class PermissionLevel(str, Enum):
|
|
32
18
|
"""
|
|
33
19
|
The permission level of the user or group with respect to this entity
|
|
@@ -357,12 +343,16 @@ class RareCategoryReplacementMethod(str, Enum):
|
|
|
357
343
|
|
|
358
344
|
|
|
359
345
|
class ModelConfiguration(CustomBaseModel):
|
|
346
|
+
"""
|
|
347
|
+
The training configuration for a AI model
|
|
348
|
+
"""
|
|
349
|
+
|
|
360
350
|
max_sample_size: Annotated[
|
|
361
351
|
Optional[int],
|
|
362
352
|
Field(
|
|
363
353
|
alias="maxSampleSize",
|
|
364
|
-
description="The maximum number of samples to consider for training.\nIf not provided, then all available samples will be taken
|
|
365
|
-
ge=
|
|
354
|
+
description="The maximum number of samples to consider for training.\nIf not provided, then all available samples will be taken.\n",
|
|
355
|
+
ge=1,
|
|
366
356
|
le=1000000000,
|
|
367
357
|
),
|
|
368
358
|
] = None
|
|
@@ -486,12 +476,6 @@ class ModelMetrics(CustomBaseModel):
|
|
|
486
476
|
distances: Optional[Distances] = None
|
|
487
477
|
|
|
488
478
|
|
|
489
|
-
class Model(CustomBaseModel):
|
|
490
|
-
id: str
|
|
491
|
-
configuration: ModelConfiguration
|
|
492
|
-
metrics: Optional[ModelMetrics] = None
|
|
493
|
-
|
|
494
|
-
|
|
495
479
|
class StepCode(str, Enum):
|
|
496
480
|
pull_training_data = "PULL_TRAINING_DATA"
|
|
497
481
|
analyze_training_data = "ANALYZE_TRAINING_DATA"
|
|
@@ -562,7 +546,6 @@ class SyntheticDatasetListItem(CustomBaseModel):
|
|
|
562
546
|
id: Annotated[
|
|
563
547
|
str, Field(description="The unique identifier of a synthetic dataset")
|
|
564
548
|
]
|
|
565
|
-
generator: Optional[BaseResource] = None
|
|
566
549
|
metadata: Metadata
|
|
567
550
|
name: Annotated[str, Field(description="The name of a synthetic dataset")]
|
|
568
551
|
description: Annotated[
|
|
@@ -585,6 +568,11 @@ class SyntheticDatasetFormat(str, Enum):
|
|
|
585
568
|
xlsx = "XLSX"
|
|
586
569
|
|
|
587
570
|
|
|
571
|
+
class SyntheticDatasetReportType(str, Enum):
|
|
572
|
+
model = "MODEL"
|
|
573
|
+
data = "DATA"
|
|
574
|
+
|
|
575
|
+
|
|
588
576
|
class SyntheticTableRebalancing(CustomBaseModel):
|
|
589
577
|
"""
|
|
590
578
|
Configure rebalancing of the table.
|
|
@@ -608,6 +596,10 @@ class SyntheticTableRebalancing(CustomBaseModel):
|
|
|
608
596
|
|
|
609
597
|
|
|
610
598
|
class SyntheticTableConfiguration(CustomBaseModel):
|
|
599
|
+
"""
|
|
600
|
+
The sample configuration for a synthetic table
|
|
601
|
+
"""
|
|
602
|
+
|
|
611
603
|
sample_size: Annotated[
|
|
612
604
|
Optional[int],
|
|
613
605
|
Field(
|
|
@@ -672,6 +664,7 @@ class SyntheticTable(CustomBaseModel):
|
|
|
672
664
|
),
|
|
673
665
|
] = None
|
|
674
666
|
configuration: Optional[SyntheticTableConfiguration] = None
|
|
667
|
+
model_metrics: Annotated[Optional[ModelMetrics], Field(alias="modelMetrics")] = None
|
|
675
668
|
|
|
676
669
|
|
|
677
670
|
class SyntheticDatasetDelivery(CustomBaseModel):
|
|
@@ -694,6 +687,23 @@ class SyntheticDatasetDelivery(CustomBaseModel):
|
|
|
694
687
|
]
|
|
695
688
|
|
|
696
689
|
|
|
690
|
+
class BaseResource(CustomBaseModel):
|
|
691
|
+
id: Annotated[
|
|
692
|
+
Optional[str], Field(description="The unique identifier of the entity")
|
|
693
|
+
] = None
|
|
694
|
+
name: Annotated[Optional[str], Field(description="The name of the entity")] = None
|
|
695
|
+
uri: Annotated[
|
|
696
|
+
Optional[str],
|
|
697
|
+
Field(
|
|
698
|
+
description="The API service endpoint of the entity",
|
|
699
|
+
example="/generators/94c77249-42bf-443a-8e17-6e18a19d60b8",
|
|
700
|
+
),
|
|
701
|
+
] = None
|
|
702
|
+
current_user_permission_level: Annotated[
|
|
703
|
+
Optional[PermissionLevel], Field(alias="currentUserPermissionLevel")
|
|
704
|
+
] = None
|
|
705
|
+
|
|
706
|
+
|
|
697
707
|
class User(CustomBaseModel):
|
|
698
708
|
id: Annotated[
|
|
699
709
|
Optional[str], Field(description="The unique identifier of a user")
|
|
@@ -763,8 +773,13 @@ class SourceTable(CustomBaseModel):
|
|
|
763
773
|
Optional[List[SourceForeignKey]],
|
|
764
774
|
Field(alias="foreignKeys", description="The foreign keys of a table."),
|
|
765
775
|
] = None
|
|
766
|
-
|
|
767
|
-
|
|
776
|
+
model_metrics: Annotated[Optional[ModelMetrics], Field(alias="modelMetrics")] = None
|
|
777
|
+
model_configuration: Annotated[
|
|
778
|
+
Optional[ModelConfiguration], Field(alias="modelConfiguration")
|
|
779
|
+
] = None
|
|
780
|
+
text_model_configuration: Annotated[
|
|
781
|
+
Optional[ModelConfiguration], Field(alias="textModelConfiguration")
|
|
782
|
+
] = None
|
|
768
783
|
total_rows: Annotated[
|
|
769
784
|
Optional[int],
|
|
770
785
|
Field(
|
|
@@ -875,6 +890,12 @@ class SyntheticDataset(CustomBaseModel):
|
|
|
875
890
|
Field(description="The tables of this synthetic dataset."),
|
|
876
891
|
] = None
|
|
877
892
|
delivery: Optional[SyntheticDatasetDelivery] = None
|
|
893
|
+
accuracy: Annotated[
|
|
894
|
+
Optional[float],
|
|
895
|
+
Field(
|
|
896
|
+
description="The overall accuracy of the trained generator.\nThis is the average of the overall accuracy scores of all trained models.\n"
|
|
897
|
+
),
|
|
898
|
+
] = None
|
|
878
899
|
usage: Optional[SyntheticDatasetUsage] = None
|
|
879
900
|
OPEN_URL_PARTS: ClassVar[list] = ["d", "synthetic-datasets"]
|
|
880
901
|
generation: Annotated[Optional[Any], Field(exclude=True)] = None
|
|
@@ -1013,13 +1034,6 @@ class Generator(CustomBaseModel):
|
|
|
1013
1034
|
tables: Annotated[
|
|
1014
1035
|
Optional[List[SourceTable]], Field(description="The tables of this generator")
|
|
1015
1036
|
] = None
|
|
1016
|
-
synthetic_datasets: Annotated[
|
|
1017
|
-
Optional[List[BaseResource]],
|
|
1018
|
-
Field(
|
|
1019
|
-
alias="syntheticDatasets",
|
|
1020
|
-
description="The synthetic datasets that were created with this generator.",
|
|
1021
|
-
),
|
|
1022
|
-
] = None
|
|
1023
1037
|
OPEN_URL_PARTS: ClassVar[list] = ["d", "generators"]
|
|
1024
1038
|
training: Annotated[Optional[Any], Field(exclude=True)] = None
|
|
1025
1039
|
|
|
@@ -6,7 +6,14 @@ from typing import Callable, Union
|
|
|
6
6
|
|
|
7
7
|
import pandas as pd
|
|
8
8
|
import rich
|
|
9
|
-
from rich.progress import
|
|
9
|
+
from rich.progress import (
|
|
10
|
+
BarColumn,
|
|
11
|
+
Progress,
|
|
12
|
+
TaskProgressColumn,
|
|
13
|
+
TextColumn,
|
|
14
|
+
TimeElapsedColumn,
|
|
15
|
+
)
|
|
16
|
+
from rich.style import Style
|
|
10
17
|
|
|
11
18
|
from mostlyai.model import (
|
|
12
19
|
Connector,
|
|
@@ -26,10 +33,21 @@ def _job_wait(
|
|
|
26
33
|
# retrieve current JobProgress
|
|
27
34
|
job = get_progress()
|
|
28
35
|
# initialize progress bars
|
|
29
|
-
progress = Progress(
|
|
36
|
+
progress = Progress(
|
|
37
|
+
TextColumn("[progress.description]{task.description}"),
|
|
38
|
+
BarColumn(
|
|
39
|
+
style=Style(color="rgb(245,245,245)"),
|
|
40
|
+
complete_style=Style(color="rgb(66,77,179)"),
|
|
41
|
+
finished_style=Style(color="rgb(36,219,149)"),
|
|
42
|
+
pulse_style=Style(color="rgb(245,245,245)"),
|
|
43
|
+
),
|
|
44
|
+
TaskProgressColumn(),
|
|
45
|
+
TimeElapsedColumn(),
|
|
46
|
+
)
|
|
30
47
|
progress_bars = {
|
|
31
48
|
"overall": progress.add_task(
|
|
32
49
|
description="[bold]Overall job progress[/b]",
|
|
50
|
+
start=job.start_date is not None,
|
|
33
51
|
completed=0,
|
|
34
52
|
total=job.progress.max,
|
|
35
53
|
)
|
|
@@ -41,8 +59,9 @@ def _job_wait(
|
|
|
41
59
|
progress_bars |= {
|
|
42
60
|
step.id: progress.add_task(
|
|
43
61
|
description=f"Step {step.model_label or 'common'} [#808080]{step_code}[/]",
|
|
62
|
+
start=step.start_date is not None,
|
|
44
63
|
completed=0,
|
|
45
|
-
total=
|
|
64
|
+
total=step.progress.max,
|
|
46
65
|
)
|
|
47
66
|
}
|
|
48
67
|
try:
|
|
@@ -53,19 +72,31 @@ def _job_wait(
|
|
|
53
72
|
time.sleep(interval)
|
|
54
73
|
# retrieve current JobProgress
|
|
55
74
|
job = get_progress()
|
|
75
|
+
current_task_id = progress_bars["overall"]
|
|
76
|
+
current_task = progress.tasks[current_task_id]
|
|
77
|
+
if not current_task.started and job.start_date is not None:
|
|
78
|
+
progress.start_task(current_task_id)
|
|
56
79
|
# update progress bars
|
|
57
80
|
progress.update(
|
|
58
|
-
|
|
81
|
+
current_task_id,
|
|
59
82
|
total=job.progress.max,
|
|
60
83
|
completed=job.progress.value,
|
|
61
84
|
)
|
|
85
|
+
if current_task.started and job.end_date is not None:
|
|
86
|
+
progress.stop_task(current_task_id)
|
|
62
87
|
for i, step in enumerate(job.steps):
|
|
88
|
+
current_task_id = progress_bars[step.id]
|
|
89
|
+
current_task = progress.tasks[current_task_id]
|
|
90
|
+
if not current_task.started and step.start_date is not None:
|
|
91
|
+
progress.start_task(current_task_id)
|
|
63
92
|
if step.progress.max > 0:
|
|
64
93
|
progress.update(
|
|
65
|
-
|
|
94
|
+
current_task_id,
|
|
66
95
|
total=step.progress.max,
|
|
67
96
|
completed=step.progress.value,
|
|
68
97
|
)
|
|
98
|
+
if current_task.started and step.end_date is not None:
|
|
99
|
+
progress.stop_task(current_task_id)
|
|
69
100
|
# break if step has failed or been canceled
|
|
70
101
|
if step.status in (ProgressStatus.failed, ProgressStatus.canceled):
|
|
71
102
|
rich.print(
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "mostlyai"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "The official Python
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "The official Python client for the MOSTLY AI platform."
|
|
5
|
+
homepage = "https://app.mostly.ai/"
|
|
5
6
|
authors = ["MOSTLY AI <office@mostly.ai>"]
|
|
6
7
|
license = "Proprietary"
|
|
7
8
|
readme = "README.md"
|
|
@@ -30,6 +31,8 @@ datamodel-code-generator = { version = "^0.22.0", extras = ["http"] }
|
|
|
30
31
|
vcrpy = "^5.1.0"
|
|
31
32
|
ruff = "^0.2.2"
|
|
32
33
|
respx = "^0.20.2"
|
|
34
|
+
twine = "^5.0.0"
|
|
35
|
+
commitizen = "^3.18.0"
|
|
33
36
|
|
|
34
37
|
[tool.mypy]
|
|
35
38
|
python_version = "3.9"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|