mostlyai 4.7.7__tar.gz → 4.7.9__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.7.7 → mostlyai-4.7.9}/PKG-INFO +12 -12
- {mostlyai-4.7.7 → mostlyai-4.7.9}/README.md +3 -3
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/__init__.py +1 -1
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/base.py +10 -6
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/context.py +2 -1
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/table/csv.py +1 -1
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/pull_utils.py +1 -1
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/client/api.py +31 -2
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/client/base.py +10 -2
- {mostlyai-4.7.7 → mostlyai-4.7.9}/pyproject.toml +10 -9
- {mostlyai-4.7.7 → mostlyai-4.7.9}/.gitignore +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/LICENSE +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/__init__.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/auto_detect.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/conversions.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/__init__.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/base.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/bigquery.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/databricks.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/hive.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/mssql.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/mysql.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/oracle.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/postgresql.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/snowflake.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/sqlite.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/db/types_coercion.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/dtype.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/exceptions.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/__init__.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/base.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/container/__init__.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/container/aws.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/container/azure.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/container/bucket_based.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/container/gcs.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/container/minio.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/table/__init__.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/table/feather.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/table/json.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/table/parquet.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/file/utils.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/language_model.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/metadata_objects.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/non_context.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/progress_callback.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/pull.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/pull_context.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/push.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/util/__init__.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/util/common.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_data/util/kerberos.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/__init__.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/cli.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/connectors.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/__init__.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/jobs.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/migration.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/plan.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_analyze_training_data.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_create_data_report.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_create_model_report.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_deliver_data.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_encode_training_data.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_finalize_generation.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_finalize_training.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_generate_data.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_pull_training_data.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_train_model.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/generators.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/progress.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/routes.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/server.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/storage.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/synthetic_datasets.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/client/__init__.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/client/_base_utils.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/client/_naming_conventions.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/client/_utils.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/client/connectors.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/client/exceptions.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/client/generators.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/client/synthetic_datasets.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/domain.py +0 -0
- {mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mostlyai
|
|
3
|
-
Version: 4.7.
|
|
3
|
+
Version: 4.7.9
|
|
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
|
|
@@ -59,7 +59,7 @@ Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local'
|
|
|
59
59
|
Requires-Dist: filelock>=3.16.1; extra == 'local'
|
|
60
60
|
Requires-Dist: gcsfs>=2023.1.0; extra == 'local'
|
|
61
61
|
Requires-Dist: joblib>=1.4.2; extra == 'local'
|
|
62
|
-
Requires-Dist: mostlyai-engine==1.4.
|
|
62
|
+
Requires-Dist: mostlyai-engine==1.4.6; extra == 'local'
|
|
63
63
|
Requires-Dist: mostlyai-qa==1.9.7; extra == 'local'
|
|
64
64
|
Requires-Dist: networkx<4,>=3.0; extra == 'local'
|
|
65
65
|
Requires-Dist: openpyxl>=3.1.5; extra == 'local'
|
|
@@ -68,9 +68,9 @@ Requires-Dist: s3fs>=2023.1.0; extra == 'local'
|
|
|
68
68
|
Requires-Dist: smart-open[azure,gcs,s3]>=6.3.0; extra == 'local'
|
|
69
69
|
Requires-Dist: sqlalchemy>=2.0.0; extra == 'local'
|
|
70
70
|
Requires-Dist: sshtunnel<0.5,>=0.4.0; extra == 'local'
|
|
71
|
-
Requires-Dist: torch<2.
|
|
72
|
-
Requires-Dist: torchaudio<2.
|
|
73
|
-
Requires-Dist: torchvision<0.
|
|
71
|
+
Requires-Dist: torch<2.7.1,>=2.7.0; extra == 'local'
|
|
72
|
+
Requires-Dist: torchaudio<2.7.1,>=2.7.0; extra == 'local'
|
|
73
|
+
Requires-Dist: torchvision<0.22.1,>=0.22.0; extra == 'local'
|
|
74
74
|
Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local'
|
|
75
75
|
Requires-Dist: xlsxwriter<4,>=3.1.9; extra == 'local'
|
|
76
76
|
Provides-Extra: local-gpu
|
|
@@ -81,7 +81,7 @@ Requires-Dist: fastapi<0.116,>=0.115.6; extra == 'local-gpu'
|
|
|
81
81
|
Requires-Dist: filelock>=3.16.1; extra == 'local-gpu'
|
|
82
82
|
Requires-Dist: gcsfs>=2023.1.0; extra == 'local-gpu'
|
|
83
83
|
Requires-Dist: joblib>=1.4.2; extra == 'local-gpu'
|
|
84
|
-
Requires-Dist: mostlyai-engine[gpu]==1.4.
|
|
84
|
+
Requires-Dist: mostlyai-engine[gpu]==1.4.6; extra == 'local-gpu'
|
|
85
85
|
Requires-Dist: mostlyai-qa==1.9.7; extra == 'local-gpu'
|
|
86
86
|
Requires-Dist: networkx<4,>=3.0; extra == 'local-gpu'
|
|
87
87
|
Requires-Dist: openpyxl>=3.1.5; extra == 'local-gpu'
|
|
@@ -90,9 +90,9 @@ Requires-Dist: s3fs>=2023.1.0; extra == 'local-gpu'
|
|
|
90
90
|
Requires-Dist: smart-open[azure,gcs,s3]>=6.3.0; extra == 'local-gpu'
|
|
91
91
|
Requires-Dist: sqlalchemy>=2.0.0; extra == 'local-gpu'
|
|
92
92
|
Requires-Dist: sshtunnel<0.5,>=0.4.0; extra == 'local-gpu'
|
|
93
|
-
Requires-Dist: torch<2.
|
|
94
|
-
Requires-Dist: torchaudio<2.
|
|
95
|
-
Requires-Dist: torchvision<0.
|
|
93
|
+
Requires-Dist: torch<2.7.1,>=2.7.0; extra == 'local-gpu'
|
|
94
|
+
Requires-Dist: torchaudio<2.7.1,>=2.7.0; extra == 'local-gpu'
|
|
95
|
+
Requires-Dist: torchvision<0.22.1,>=0.22.0; extra == 'local-gpu'
|
|
96
96
|
Requires-Dist: uvicorn<0.35,>=0.34.0; extra == 'local-gpu'
|
|
97
97
|
Requires-Dist: xlsxwriter<4,>=3.1.9; extra == 'local-gpu'
|
|
98
98
|
Provides-Extra: mssql
|
|
@@ -325,16 +325,16 @@ On Linux, one can explicitly install the CPU-only variant of torch together with
|
|
|
325
325
|
|
|
326
326
|
```shell
|
|
327
327
|
# uv pip install
|
|
328
|
-
uv pip install --index-strategy unsafe-first-match -U torch==2.
|
|
328
|
+
uv pip install --index-strategy unsafe-first-match -U torch==2.7.0+cpu torchvision==0.22.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
|
|
329
329
|
```
|
|
330
330
|
|
|
331
331
|
```shell
|
|
332
332
|
# standard pip install
|
|
333
|
-
pip install -U torch==2.
|
|
333
|
+
pip install -U torch==2.7.0+cpu torchvision==0.22.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
|
|
334
334
|
```
|
|
335
335
|
|
|
336
336
|
|
|
337
|
-
> **Note for Google Colab users**: Installing any of the local extras (`mostlyai[local]`, or `mostlyai[local-gpu]`)
|
|
337
|
+
> **Note for Google Colab users**: Installing any of the local extras (`mostlyai[local]`, or `mostlyai[local-gpu]`) might need restarting the runtime after installation for the changes to take effect.
|
|
338
338
|
|
|
339
339
|
### Data Connectors
|
|
340
340
|
|
|
@@ -216,16 +216,16 @@ On Linux, one can explicitly install the CPU-only variant of torch together with
|
|
|
216
216
|
|
|
217
217
|
```shell
|
|
218
218
|
# uv pip install
|
|
219
|
-
uv pip install --index-strategy unsafe-first-match -U torch==2.
|
|
219
|
+
uv pip install --index-strategy unsafe-first-match -U torch==2.7.0+cpu torchvision==0.22.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
```shell
|
|
223
223
|
# standard pip install
|
|
224
|
-
pip install -U torch==2.
|
|
224
|
+
pip install -U torch==2.7.0+cpu torchvision==0.22.0+cpu 'mostlyai[local]' --extra-index-url https://download.pytorch.org/whl/cpu
|
|
225
225
|
```
|
|
226
226
|
|
|
227
227
|
|
|
228
|
-
> **Note for Google Colab users**: Installing any of the local extras (`mostlyai[local]`, or `mostlyai[local-gpu]`)
|
|
228
|
+
> **Note for Google Colab users**: Installing any of the local extras (`mostlyai[local]`, or `mostlyai[local-gpu]`) might need restarting the runtime after installation for the changes to take effect.
|
|
229
229
|
|
|
230
230
|
### Data Connectors
|
|
231
231
|
|
|
@@ -188,13 +188,17 @@ class Schema:
|
|
|
188
188
|
return ctx_rel.child
|
|
189
189
|
|
|
190
190
|
def get_primary_key(self, table_name: str) -> DataIdentifier | None:
|
|
191
|
-
|
|
192
|
-
# first, check primary key on table
|
|
191
|
+
primary_key = None
|
|
193
192
|
if self.tables[table_name].primary_key is not None:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
# first, check primary key on table
|
|
194
|
+
primary_key = DataIdentifier(table_name, self.tables[table_name].primary_key)
|
|
195
|
+
elif context_relations := self.get_child_context_relations(table_name):
|
|
196
|
+
# fall back to checking primary key on schema
|
|
197
|
+
primary_key = context_relations[0].parent
|
|
198
|
+
# lastly, check if the primary key is in the included columns
|
|
199
|
+
if primary_key and primary_key.column not in self.tables[table_name].columns:
|
|
200
|
+
primary_key = None
|
|
201
|
+
return primary_key
|
|
198
202
|
|
|
199
203
|
def get_child_context_relations(self, parent_table: str) -> list[DataRelation]:
|
|
200
204
|
return [rel for rel in self.relations if rel.parent.table == parent_table and isinstance(rel, ContextRelation)]
|
|
@@ -257,9 +257,10 @@ def get_table_chain_to_tgt(schema: Schema, tables: list[str], tgt: str) -> tuple
|
|
|
257
257
|
"""
|
|
258
258
|
sub_schema = schema.subset(relation_type=ContextRelation, tables=tables + [tgt])
|
|
259
259
|
nodes, path = sub_schema.path_to(tgt)
|
|
260
|
+
tgt_pk = pk.column if (pk := schema.get_primary_key(tgt)) else None
|
|
260
261
|
path.append(
|
|
261
262
|
ContextRelation(
|
|
262
|
-
parent=DataIdentifier(table=tgt, column=
|
|
263
|
+
parent=DataIdentifier(table=tgt, column=tgt_pk),
|
|
263
264
|
child=DataIdentifier(),
|
|
264
265
|
)
|
|
265
266
|
)
|
|
@@ -87,7 +87,7 @@ class CsvDataTable(FileDataTable):
|
|
|
87
87
|
# with the first file consisting of integers and the others of floats; so, there still
|
|
88
88
|
# might be scenarios where errors occur due to dtype mismatch in CSV chunks; in these
|
|
89
89
|
# cases we shall advise to convert the source data to Parquet
|
|
90
|
-
read_options=pa_csv.ReadOptions(block_size=
|
|
90
|
+
read_options=pa_csv.ReadOptions(block_size=100 * 1024 * 1024),
|
|
91
91
|
# add additional formats for datetime conversion
|
|
92
92
|
convert_options=pa_csv.ConvertOptions(
|
|
93
93
|
timestamp_parsers=[
|
|
@@ -287,7 +287,7 @@ def export_meta(
|
|
|
287
287
|
tgt_metadata_path = workspace_dir / "OriginalData" / "tgt-meta"
|
|
288
288
|
tgt_metadata_path.mkdir(parents=True, exist_ok=True)
|
|
289
289
|
# tgt-meta / keys.json
|
|
290
|
-
tgt_pk =
|
|
290
|
+
tgt_pk = pk.column if (pk := schema.get_primary_key(tgt)) else None
|
|
291
291
|
for rel in schema.subset(relations_to=tgt).relations:
|
|
292
292
|
if rel.child == DataIdentifier(tgt, tgt_pk):
|
|
293
293
|
# having the same field as PK and FK is not supported
|
|
@@ -58,6 +58,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
58
58
|
Args:
|
|
59
59
|
base_url (str | None): The base URL. If not provided, env var `MOSTLY_BASE_URL` is used if available, otherwise `https://app.mostly.ai`.
|
|
60
60
|
api_key (str | None): The API key for authenticating. If not provided, env var `MOSTLY_API_KEY` is used if available.
|
|
61
|
+
bearer_token (str | None): The bearer token for authenticating. If not provided, env var `MOSTLY_BEARER_TOKEN` is used if available. Takes precedence over api_key.
|
|
61
62
|
local (bool | None): Whether to run in local mode or not. If not provided, user is prompted to choose between CLIENT and LOCAL mode.
|
|
62
63
|
local_dir (str | Path | None): The directory to use for local mode. If not provided, `~/mostlyai` is used.
|
|
63
64
|
local_port (int | None): The port to use for local mode with TCP transport. If not provided, UDS transport is used.
|
|
@@ -76,6 +77,17 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
76
77
|
# MostlyAI(base_url='https://app.mostly.ai', api_key='***')
|
|
77
78
|
```
|
|
78
79
|
|
|
80
|
+
Example for SDK in CLIENT mode with bearer token:
|
|
81
|
+
```python
|
|
82
|
+
from mostlyai.sdk import MostlyAI
|
|
83
|
+
mostly = MostlyAI(
|
|
84
|
+
bearer_token='INSERT_YOUR_BEARER_TOKEN',
|
|
85
|
+
base_url='https://app.mostly.ai',
|
|
86
|
+
)
|
|
87
|
+
mostly
|
|
88
|
+
# MostlyAI(base_url='https://app.mostly.ai', bearer_token='***')
|
|
89
|
+
```
|
|
90
|
+
|
|
79
91
|
Example for SDK in CLIENT mode with environment variables:
|
|
80
92
|
```python
|
|
81
93
|
import os
|
|
@@ -87,6 +99,17 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
87
99
|
# MostlyAI(base_url='https://app.mostly.ai', api_key='***')
|
|
88
100
|
```
|
|
89
101
|
|
|
102
|
+
Example for SDK in CLIENT mode with bearer token environment variable:
|
|
103
|
+
```python
|
|
104
|
+
import os
|
|
105
|
+
from mostlyai.sdk import MostlyAI
|
|
106
|
+
os.environ["MOSTLY_BEARER_TOKEN"] = "INSERT_YOUR_BEARER_TOKEN"
|
|
107
|
+
os.environ["MOSTLY_BASE_URL"] = "https://app.mostly.ai"
|
|
108
|
+
mostly = MostlyAI()
|
|
109
|
+
mostly
|
|
110
|
+
# MostlyAI(base_url='https://app.mostly.ai', bearer_token='***')
|
|
111
|
+
```
|
|
112
|
+
|
|
90
113
|
Example for SDK in LOCAL mode connecting via UDS:
|
|
91
114
|
```python
|
|
92
115
|
from mostlyai.sdk import MostlyAI
|
|
@@ -108,6 +131,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
108
131
|
self,
|
|
109
132
|
base_url: str | None = None,
|
|
110
133
|
api_key: str | None = None,
|
|
134
|
+
bearer_token: str | None = None,
|
|
111
135
|
local: bool | None = None,
|
|
112
136
|
local_dir: str | Path | None = None,
|
|
113
137
|
local_port: int | None = None,
|
|
@@ -122,13 +146,13 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
122
146
|
|
|
123
147
|
# determine SDK mode: either CLIENT or LOCAL mode
|
|
124
148
|
mode: Literal["CLIENT", "LOCAL", None] = None
|
|
125
|
-
if base_url is not None or api_key is not None:
|
|
149
|
+
if base_url is not None or api_key is not None or bearer_token is not None:
|
|
126
150
|
mode = "CLIENT"
|
|
127
151
|
elif local is not None:
|
|
128
152
|
mode = "LOCAL" if bool(local) else "CLIENT"
|
|
129
153
|
elif os.getenv("MOSTLY_LOCAL"):
|
|
130
154
|
mode = "LOCAL" if os.getenv("MOSTLY_LOCAL").lower()[:1] in ["1", "t", "y"] else "CLIENT"
|
|
131
|
-
elif os.getenv("MOSTLY_API_KEY"):
|
|
155
|
+
elif os.getenv("MOSTLY_API_KEY") or os.getenv("MOSTLY_BEARER_TOKEN"):
|
|
132
156
|
mode = "CLIENT"
|
|
133
157
|
else:
|
|
134
158
|
# prompt for CLIENT or LOCAL setup, if not yet determined
|
|
@@ -176,6 +200,8 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
176
200
|
validate_base_url(base_url)
|
|
177
201
|
if api_key is None:
|
|
178
202
|
api_key = os.getenv("MOSTLY_API_KEY", "")
|
|
203
|
+
if bearer_token is None:
|
|
204
|
+
bearer_token = os.getenv("MOSTLY_BEARER_TOKEN", "")
|
|
179
205
|
home_dir = None
|
|
180
206
|
uds = None
|
|
181
207
|
else:
|
|
@@ -184,6 +210,7 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
184
210
|
client_kwargs = {
|
|
185
211
|
"base_url": base_url,
|
|
186
212
|
"api_key": api_key,
|
|
213
|
+
"bearer_token": bearer_token,
|
|
187
214
|
"uds": uds,
|
|
188
215
|
"timeout": timeout,
|
|
189
216
|
"ssl_verify": ssl_verify,
|
|
@@ -231,6 +258,8 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
231
258
|
if self.local_server.uds:
|
|
232
259
|
return "MostlyAI(local=True)"
|
|
233
260
|
return f"MostlyAI(local=True, local_port={self.local_server.port})"
|
|
261
|
+
if self.bearer_token:
|
|
262
|
+
return f"MostlyAI(base_url='{self.base_url}', bearer_token=***)"
|
|
234
263
|
return f"MostlyAI(base_url='{self.base_url}', api_key=***)"
|
|
235
264
|
|
|
236
265
|
def connect(
|
|
@@ -63,23 +63,31 @@ class _MostlyBaseClient:
|
|
|
63
63
|
self,
|
|
64
64
|
base_url: str | None = None,
|
|
65
65
|
api_key: str | None = None,
|
|
66
|
+
bearer_token: str | None = None,
|
|
66
67
|
uds: str | None = None,
|
|
67
68
|
timeout: float = 60.0,
|
|
68
69
|
ssl_verify: bool = True,
|
|
69
70
|
):
|
|
70
71
|
self.base_url = (base_url or os.getenv("MOSTLY_BASE_URL") or DEFAULT_BASE_URL).rstrip("/")
|
|
71
72
|
self.api_key = api_key or os.getenv("MOSTLY_API_KEY", "")
|
|
73
|
+
self.bearer_token = bearer_token or os.getenv("MOSTLY_BEARER_TOKEN", "")
|
|
72
74
|
self.local = self.api_key == "local"
|
|
73
75
|
self.transport = httpx.HTTPTransport(uds=uds) if uds else None
|
|
74
76
|
self.timeout = timeout
|
|
75
77
|
self.ssl_verify = ssl_verify
|
|
76
78
|
|
|
77
79
|
def headers(self):
|
|
78
|
-
|
|
80
|
+
headers = {
|
|
79
81
|
"Accept": "application/json",
|
|
80
|
-
"X-MOSTLY-API-KEY": self.api_key,
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
if self.bearer_token:
|
|
85
|
+
headers["Authorization"] = f"Bearer {self.bearer_token}"
|
|
86
|
+
else:
|
|
87
|
+
headers["X-MOSTLY-API-KEY"] = self.api_key
|
|
88
|
+
|
|
89
|
+
return headers
|
|
90
|
+
|
|
83
91
|
def request(
|
|
84
92
|
self,
|
|
85
93
|
path: str | list[Any],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mostlyai"
|
|
3
|
-
version = "4.7.
|
|
3
|
+
version = "4.7.9"
|
|
4
4
|
description = "Synthetic Data SDK"
|
|
5
5
|
authors = [{ name = "MOSTLY AI", email = "dev@mostly.ai" }]
|
|
6
6
|
requires-python = ">=3.10,<3.14"
|
|
@@ -49,14 +49,14 @@ dependencies = [
|
|
|
49
49
|
local = [
|
|
50
50
|
# "mostlyai-engine @ git+https://github.com/mostly-ai/mostlyai-engine.git@main", # for development
|
|
51
51
|
# "mostlyai-qa @ git+https://github.com/mostly-ai/mostlyai-qa.git@main", # for development
|
|
52
|
-
"mostlyai-engine==1.4.
|
|
52
|
+
"mostlyai-engine==1.4.6", # for release
|
|
53
53
|
"mostlyai-qa==1.9.7", # for release
|
|
54
54
|
"fastapi>=0.115.6,<0.116",
|
|
55
55
|
"uvicorn>=0.34.0,<0.35",
|
|
56
56
|
"python-multipart>=0.0.20",
|
|
57
|
-
"torch>=2.
|
|
58
|
-
"torchaudio>=2.
|
|
59
|
-
"torchvision>=0.
|
|
57
|
+
"torch>=2.7.0,<2.7.1",
|
|
58
|
+
"torchaudio>=2.7.0,<2.7.1",
|
|
59
|
+
"torchvision>=0.22.0,<0.22.1",
|
|
60
60
|
"joblib>=1.4.2",
|
|
61
61
|
"sqlalchemy>=2.0.0",
|
|
62
62
|
"sshtunnel>=0.4.0,<0.5",
|
|
@@ -75,14 +75,14 @@ local = [
|
|
|
75
75
|
local-gpu = [
|
|
76
76
|
# "mostlyai-engine[gpu] @ git+https://github.com/mostly-ai/mostlyai-engine.git@main", # for development
|
|
77
77
|
# "mostlyai-qa @ git+https://github.com/mostly-ai/mostlyai-qa.git@main", # for development
|
|
78
|
-
"mostlyai-engine[gpu]==1.4.
|
|
78
|
+
"mostlyai-engine[gpu]==1.4.6", # for release
|
|
79
79
|
"mostlyai-qa==1.9.7", # for release
|
|
80
80
|
"fastapi>=0.115.6,<0.116",
|
|
81
81
|
"uvicorn>=0.34.0,<0.35",
|
|
82
82
|
"python-multipart>=0.0.20",
|
|
83
|
-
"torch>=2.
|
|
84
|
-
"torchaudio>=2.
|
|
85
|
-
"torchvision>=0.
|
|
83
|
+
"torch>=2.7.0,<2.7.1",
|
|
84
|
+
"torchaudio>=2.7.0,<2.7.1",
|
|
85
|
+
"torchvision>=0.22.0,<0.22.1",
|
|
86
86
|
"joblib>=1.4.2",
|
|
87
87
|
"sqlalchemy>=2.0.0",
|
|
88
88
|
"sshtunnel>=0.4.0,<0.5",
|
|
@@ -142,6 +142,7 @@ docs = [
|
|
|
142
142
|
"mkdocs>=1.6",
|
|
143
143
|
"mkdocstrings[crystal, python]>=0.29",
|
|
144
144
|
"mkdocs-material>=9.0",
|
|
145
|
+
"mkdocs-llmstxt>=0.2",
|
|
145
146
|
"griffe>=1.0",
|
|
146
147
|
"pymdown-extensions>=10.0",
|
|
147
148
|
"griffe-fieldz>=0.2",
|
|
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.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_analyze_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_encode_training_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai-4.7.7 → mostlyai-4.7.9}/mostlyai/sdk/_local/execution/step_generate_model_report_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|