mostlyai 0.3.3__tar.gz → 0.3.5__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.3.3 → mostlyai-0.3.5}/PKG-INFO +1 -1
- {mostlyai-0.3.3 → mostlyai-0.3.5}/mostlyai/api.py +134 -102
- {mostlyai-0.3.3 → mostlyai-0.3.5}/mostlyai/connectors.py +7 -1
- {mostlyai-0.3.3 → mostlyai-0.3.5}/mostlyai/model.py +101 -1
- {mostlyai-0.3.3 → mostlyai-0.3.5}/pyproject.toml +6 -2
- {mostlyai-0.3.3 → mostlyai-0.3.5}/LICENSE +0 -0
- {mostlyai-0.3.3 → mostlyai-0.3.5}/README.md +0 -0
- {mostlyai-0.3.3 → mostlyai-0.3.5}/mostlyai/__init__.py +0 -0
- {mostlyai-0.3.3 → mostlyai-0.3.5}/mostlyai/base.py +0 -0
- {mostlyai-0.3.3 → mostlyai-0.3.5}/mostlyai/exceptions.py +0 -0
- {mostlyai-0.3.3 → mostlyai-0.3.5}/mostlyai/generators.py +0 -0
- {mostlyai-0.3.3 → mostlyai-0.3.5}/mostlyai/shares.py +0 -0
- {mostlyai-0.3.3 → mostlyai-0.3.5}/mostlyai/synthetic_datasets.py +0 -0
- {mostlyai-0.3.3 → mostlyai-0.3.5}/mostlyai/utils.py +0 -0
|
@@ -60,108 +60,140 @@ class MostlyAI(_MostlyBaseClient):
|
|
|
60
60
|
|
|
61
61
|
If validation fails, a 400 status with an error message will be returned.
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
63
|
+
`config` is a dictionary with the keys `type`, `config`, `secrets`, and `ssl`.
|
|
64
|
+
The structures of the `config`, `secrets` and `ssl` parameters depend on the connector `type`:
|
|
65
|
+
|
|
66
|
+
- Cloud storage:
|
|
67
|
+
- \t
|
|
68
|
+
```yaml
|
|
69
|
+
type: AZURE_STORAGE
|
|
70
|
+
config:
|
|
71
|
+
accountName: string
|
|
72
|
+
clientId: string (required for auth via service principal)
|
|
73
|
+
tenantId: string (required for auth via service principal)
|
|
74
|
+
secrets:
|
|
75
|
+
accountKey: string (required for regular auth)
|
|
76
|
+
clientSecret: string (required for auth via service principal)
|
|
77
|
+
```
|
|
78
|
+
- \t
|
|
79
|
+
```yaml
|
|
80
|
+
type: GOOGLE_CLOUD_STORAGE
|
|
81
|
+
config:
|
|
82
|
+
secrets:
|
|
83
|
+
keyFile: string
|
|
84
|
+
```
|
|
85
|
+
- \t
|
|
86
|
+
```yaml
|
|
87
|
+
type: S3_STORAGE
|
|
88
|
+
config:
|
|
89
|
+
accessKey: string
|
|
90
|
+
secrets:
|
|
91
|
+
secretKey: string
|
|
92
|
+
```
|
|
93
|
+
- Database:
|
|
94
|
+
- \t
|
|
95
|
+
```yaml
|
|
96
|
+
type: BIGQUERY
|
|
97
|
+
config:
|
|
98
|
+
secrets:
|
|
99
|
+
keyFile: string
|
|
100
|
+
```
|
|
101
|
+
- \t
|
|
102
|
+
```yaml
|
|
103
|
+
type: DATABRICKS
|
|
104
|
+
config:
|
|
105
|
+
host: string
|
|
106
|
+
httpPath: string
|
|
107
|
+
catalog: string
|
|
108
|
+
clientId: string (required for auth via service principal)
|
|
109
|
+
tenantId: string (required for auth via service principal)
|
|
110
|
+
secrets:
|
|
111
|
+
accessToken: string (required for regular auth)
|
|
112
|
+
clientSecret: string (required for auth via service principal)
|
|
113
|
+
```
|
|
114
|
+
- \t
|
|
115
|
+
```yaml
|
|
116
|
+
type: HIVE
|
|
117
|
+
config:
|
|
118
|
+
host: string
|
|
119
|
+
port: integer, default: 10000
|
|
120
|
+
username: string (required for regular auth)
|
|
121
|
+
kerberos_enabled: boolean, default: false
|
|
122
|
+
kerberos_principal: string (required if kerberos_enabled)
|
|
123
|
+
kerberos_krb5_conf: string (required if kerberos_enabled)
|
|
124
|
+
secrets:
|
|
125
|
+
password: string (required for regular auth)
|
|
126
|
+
kerberos_keytab: base64-encoded string (required if kerberos_enabled)
|
|
127
|
+
```
|
|
128
|
+
- \t
|
|
129
|
+
```yaml
|
|
130
|
+
type: MARIADB
|
|
131
|
+
config:
|
|
132
|
+
host: string
|
|
133
|
+
port: integer, default: 3306
|
|
134
|
+
username: string
|
|
135
|
+
secrets:
|
|
136
|
+
password: string
|
|
137
|
+
```
|
|
138
|
+
- \t
|
|
139
|
+
```yaml
|
|
140
|
+
type: MSSQL
|
|
141
|
+
config:
|
|
142
|
+
host: string
|
|
143
|
+
port: integer, default: 1433
|
|
144
|
+
username: string
|
|
145
|
+
database: string
|
|
146
|
+
secrets:
|
|
147
|
+
password: string
|
|
148
|
+
```
|
|
149
|
+
- \t
|
|
150
|
+
```yaml
|
|
151
|
+
type: MYSQL
|
|
152
|
+
config:
|
|
153
|
+
host: string
|
|
154
|
+
port: integer, default: 3306
|
|
155
|
+
username: string
|
|
156
|
+
secrets:
|
|
157
|
+
password: string
|
|
158
|
+
```
|
|
159
|
+
- \t
|
|
160
|
+
```yaml
|
|
161
|
+
type: ORACLE
|
|
162
|
+
config:
|
|
163
|
+
host: string
|
|
164
|
+
port: integer, default: 1521
|
|
165
|
+
username: string
|
|
166
|
+
connectionType: enum {SID, SERVICE_NAME}, default: SID
|
|
167
|
+
database: string, default: ORCL
|
|
168
|
+
secrets:
|
|
169
|
+
password: string
|
|
170
|
+
```
|
|
171
|
+
- \t
|
|
172
|
+
```yaml
|
|
173
|
+
type: POSTGRES
|
|
174
|
+
config:
|
|
175
|
+
host: string
|
|
176
|
+
port: integer, default: 5432
|
|
177
|
+
username: string
|
|
178
|
+
database: string
|
|
179
|
+
secrets:
|
|
180
|
+
password: string
|
|
181
|
+
ssl:
|
|
182
|
+
rootCertificate: string
|
|
183
|
+
sslCertificate: string
|
|
184
|
+
sslCertificateKey: string
|
|
185
|
+
```
|
|
186
|
+
- \t
|
|
187
|
+
```yaml
|
|
188
|
+
type: SNOWFLAKE
|
|
189
|
+
config:
|
|
190
|
+
account: string
|
|
191
|
+
username: string
|
|
192
|
+
warehouse: string, default: COMPUTE_WH
|
|
193
|
+
database: string
|
|
194
|
+
secrets:
|
|
195
|
+
password: string
|
|
196
|
+
```
|
|
165
197
|
|
|
166
198
|
:return: The created connector.
|
|
167
199
|
"""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, Iterator, Optional
|
|
1
|
+
from typing import Any, Iterator, Optional, List, Dict
|
|
2
2
|
|
|
3
3
|
from mostlyai.base import DELETE, GET, PATCH, POST, Paginator, _MostlyBaseClient
|
|
4
4
|
from mostlyai.model import Connector
|
|
@@ -91,3 +91,9 @@ class _MostlyConnectorsClient(_MostlyBaseClient, _MostlySharesMixin):
|
|
|
91
91
|
verb=GET, path=[connector_id, "locations"], params={"prefix": prefix}
|
|
92
92
|
)
|
|
93
93
|
return response
|
|
94
|
+
|
|
95
|
+
def _schema(self, connector_id: str, location: str) -> List[Dict[str, Any]]:
|
|
96
|
+
response = self.request(
|
|
97
|
+
verb=GET, path=[connector_id, "schema"], params={"location": location}
|
|
98
|
+
)
|
|
99
|
+
return response
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# generated by datamodel-codegen:
|
|
2
|
-
# timestamp: 2024-
|
|
2
|
+
# timestamp: 2024-05-13T11:50:56+00:00
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
@@ -127,6 +127,7 @@ class ModelEncodingType(str, Enum):
|
|
|
127
127
|
"""
|
|
128
128
|
The encoding type used for model training and data generation.
|
|
129
129
|
This property is only relevant if generation method is AI_MODEL.
|
|
130
|
+
- AUTO: Model chooses among available encoding types based on the column's data type.
|
|
130
131
|
- CATEGORICAL: Model samples from existing (non-rare) categories.
|
|
131
132
|
- NUMERIC_AUTO: Model chooses among 3 numeric encoding types based on the values.
|
|
132
133
|
- NUMERIC_DISCRETE: Model samples from existing discrete numerical values.
|
|
@@ -140,6 +141,7 @@ class ModelEncodingType(str, Enum):
|
|
|
140
141
|
|
|
141
142
|
"""
|
|
142
143
|
|
|
144
|
+
auto = "AUTO"
|
|
143
145
|
categorical = "CATEGORICAL"
|
|
144
146
|
numeric_auto = "NUMERIC_AUTO"
|
|
145
147
|
numeric_discrete = "NUMERIC_DISCRETE"
|
|
@@ -182,12 +184,27 @@ class ConnectorTestConnection(RootModel[bool]):
|
|
|
182
184
|
]
|
|
183
185
|
|
|
184
186
|
|
|
187
|
+
class ConnectorUsage(CustomBaseModel):
|
|
188
|
+
no_of_shares: Annotated[
|
|
189
|
+
Optional[int],
|
|
190
|
+
Field(alias="noOfShares", description="Number of shares of this connector."),
|
|
191
|
+
] = None
|
|
192
|
+
no_of_generators: Annotated[
|
|
193
|
+
Optional[int],
|
|
194
|
+
Field(
|
|
195
|
+
alias="noOfGenerators",
|
|
196
|
+
description="Number of generators using this connector.",
|
|
197
|
+
),
|
|
198
|
+
] = None
|
|
199
|
+
|
|
200
|
+
|
|
185
201
|
class ConnectorListItem(CustomBaseModel):
|
|
186
202
|
id: Annotated[str, Field(description="The unique identifier of a connector")]
|
|
187
203
|
name: Annotated[str, Field(description="The name of a connector")]
|
|
188
204
|
type: ConnectorType
|
|
189
205
|
access_type: Annotated[ConnectorAccessType, Field(alias="accessType")]
|
|
190
206
|
metadata: Metadata
|
|
207
|
+
usage: Optional[ConnectorUsage] = None
|
|
191
208
|
|
|
192
209
|
|
|
193
210
|
class Connector(CustomBaseModel):
|
|
@@ -199,6 +216,7 @@ class Connector(CustomBaseModel):
|
|
|
199
216
|
secrets: Optional[Dict[str, str]] = None
|
|
200
217
|
ssl: Optional[Dict[str, str]] = None
|
|
201
218
|
metadata: Optional[Metadata] = None
|
|
219
|
+
usage: Optional[ConnectorUsage] = None
|
|
202
220
|
table_id: Annotated[
|
|
203
221
|
Optional[str],
|
|
204
222
|
Field(
|
|
@@ -234,11 +252,38 @@ class Connector(CustomBaseModel):
|
|
|
234
252
|
For storage connectors, this returns list of folders and files at root, respectively at `prefix` level.
|
|
235
253
|
For DB connectors, this returns list of schemas (or databases for DBs without schema), respectively list of tables if `prefix` is provided.
|
|
236
254
|
|
|
255
|
+
The formats of the locations are:
|
|
256
|
+
|
|
257
|
+
- Cloud storage:
|
|
258
|
+
- `AZURE_STORAGE`: `container/path`
|
|
259
|
+
- `GOOGLE_CLOUD_STORAGE`: `bucket/path`
|
|
260
|
+
- `S3_STORAGE`: `bucket/path`
|
|
261
|
+
- Database:
|
|
262
|
+
- `BIGQUERY`: `dataset.table`
|
|
263
|
+
- `DATABRICKS`: `schema.table`
|
|
264
|
+
- `HIVE`: `database.table`
|
|
265
|
+
- `MARIADB`: `database.table`
|
|
266
|
+
- `MSSQL`: `schema.table`
|
|
267
|
+
- `MYSQL`: `database.table`
|
|
268
|
+
- `ORACLE`: `schema.table`
|
|
269
|
+
- `POSTGRES`: `schema.table`
|
|
270
|
+
- `SNOWFLAKE`: `schema.table`
|
|
237
271
|
:param prefix: The prefix to filter the results by.
|
|
238
272
|
:return: A list of locations (schemas, databases, directories, etc.) on the given level.
|
|
239
273
|
"""
|
|
240
274
|
return self.client._locations(connector_id=self.id, prefix=prefix)
|
|
241
275
|
|
|
276
|
+
def schema(self, location: str) -> list[dict[str, Any]]:
|
|
277
|
+
"""
|
|
278
|
+
Retrieve the schema (column names, original data types and default model encoding types) of the table at a connector location.
|
|
279
|
+
|
|
280
|
+
Please refer to `locations()` for the format of the location.
|
|
281
|
+
|
|
282
|
+
:param location: The location of the table
|
|
283
|
+
:return: The retrieved schema
|
|
284
|
+
"""
|
|
285
|
+
return self.client._schema(connector_id=self.id, location=location)
|
|
286
|
+
|
|
242
287
|
def config(self) -> dict[str, Any]:
|
|
243
288
|
"""
|
|
244
289
|
Retrieve writeable generator properties
|
|
@@ -266,6 +311,17 @@ class GeneratorUsage(CustomBaseModel):
|
|
|
266
311
|
description="The total compute time in seconds used for training this generator. \nThis is the sum of the compute time of all trained tasks.\n",
|
|
267
312
|
),
|
|
268
313
|
] = None
|
|
314
|
+
no_of_synthetic_datasets: Annotated[
|
|
315
|
+
Optional[int],
|
|
316
|
+
Field(
|
|
317
|
+
alias="noOfSyntheticDatasets",
|
|
318
|
+
description="Number of synthetic datasets generated by this generator.",
|
|
319
|
+
),
|
|
320
|
+
] = None
|
|
321
|
+
no_of_shares: Annotated[
|
|
322
|
+
Optional[int],
|
|
323
|
+
Field(alias="noOfShares", description="Number of shares of this generator."),
|
|
324
|
+
] = None
|
|
269
325
|
|
|
270
326
|
|
|
271
327
|
class SourceTableData(RootModel[str]):
|
|
@@ -286,6 +342,40 @@ class SourceTableIncludeChildren(RootModel[bool]):
|
|
|
286
342
|
]
|
|
287
343
|
|
|
288
344
|
|
|
345
|
+
class SourceColumnValueRange(CustomBaseModel):
|
|
346
|
+
"""
|
|
347
|
+
The (privacy-safe) range of values detected within a source column. These values can then be used as seed values
|
|
348
|
+
for conditional generation. For CATEGORICAL and NUMERIC_DISCRETE encoding types, this will be given as a list
|
|
349
|
+
of unique values, sorted by popularity. For other NUMERIC and for DATETIME encoding types, this will be given
|
|
350
|
+
as a min and max value. Note, that this property will only be populated, once the analysis step for the training
|
|
351
|
+
of the generator has been completed.
|
|
352
|
+
|
|
353
|
+
"""
|
|
354
|
+
|
|
355
|
+
min: Annotated[
|
|
356
|
+
Optional[str],
|
|
357
|
+
Field(
|
|
358
|
+
description="The minimum value of the column. For dates, this is represented in ISO format."
|
|
359
|
+
),
|
|
360
|
+
] = None
|
|
361
|
+
max: Annotated[
|
|
362
|
+
Optional[str],
|
|
363
|
+
Field(
|
|
364
|
+
description="The maximum value of the column. For dates, this is represented in ISO format."
|
|
365
|
+
),
|
|
366
|
+
] = None
|
|
367
|
+
values: Annotated[
|
|
368
|
+
Optional[List[str]],
|
|
369
|
+
Field(
|
|
370
|
+
description="The list of distinct values of the column. Limited to a maximum of 1000 values."
|
|
371
|
+
),
|
|
372
|
+
] = None
|
|
373
|
+
has_null: Annotated[
|
|
374
|
+
Optional[bool],
|
|
375
|
+
Field(description="If true, null value was detected within the column."),
|
|
376
|
+
] = None
|
|
377
|
+
|
|
378
|
+
|
|
289
379
|
class SourceColumn(CustomBaseModel):
|
|
290
380
|
id: Annotated[str, Field(description="The unique identifier of a source column")]
|
|
291
381
|
name: Annotated[str, Field(description="The name of a source column")]
|
|
@@ -296,6 +386,9 @@ class SourceColumn(CustomBaseModel):
|
|
|
296
386
|
),
|
|
297
387
|
]
|
|
298
388
|
model_encoding_type: Annotated[ModelEncodingType, Field(alias="modelEncodingType")]
|
|
389
|
+
value_range: Annotated[
|
|
390
|
+
Optional[SourceColumnValueRange], Field(alias="valueRange")
|
|
391
|
+
] = None
|
|
299
392
|
|
|
300
393
|
|
|
301
394
|
class SourceForeignKey(CustomBaseModel):
|
|
@@ -541,6 +634,13 @@ class SyntheticDatasetUsage(CustomBaseModel):
|
|
|
541
634
|
description="The total compute time in seconds used for generating this synthetic dataset. \nThis is the sum of the compute time of all trained tasks.\n",
|
|
542
635
|
),
|
|
543
636
|
] = None
|
|
637
|
+
no_of_shares: Annotated[
|
|
638
|
+
Optional[int],
|
|
639
|
+
Field(
|
|
640
|
+
alias="noOfShares",
|
|
641
|
+
description="Number of shares of this synthetic dataset.",
|
|
642
|
+
),
|
|
643
|
+
] = None
|
|
544
644
|
|
|
545
645
|
|
|
546
646
|
class SyntheticDatasetListItem(CustomBaseModel):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "mostlyai"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.5"
|
|
4
4
|
description = "The official Python client for the MOSTLY AI platform."
|
|
5
5
|
homepage = "https://app.mostly.ai/"
|
|
6
6
|
authors = ["MOSTLY AI <office@mostly.ai>"]
|
|
@@ -9,6 +9,7 @@ readme = "README.md"
|
|
|
9
9
|
packages = [
|
|
10
10
|
{ include = "mostlyai" }
|
|
11
11
|
]
|
|
12
|
+
exclude = ["tools/", "tools/**/*"]
|
|
12
13
|
|
|
13
14
|
[tool.poetry.dependencies]
|
|
14
15
|
python = "^3.9"
|
|
@@ -23,7 +24,7 @@ pytest = "^7.0.0"
|
|
|
23
24
|
mypy = "^0.931"
|
|
24
25
|
pylint = "^2.12.2"
|
|
25
26
|
isort = "^5.10.1"
|
|
26
|
-
black = "^
|
|
27
|
+
black = "^24.4.0"
|
|
27
28
|
pre-commit = "^2.17.0"
|
|
28
29
|
datamodel-code-generator = { version = "^0.22.0", extras = ["http"] }
|
|
29
30
|
|
|
@@ -33,6 +34,9 @@ ruff = "^0.2.2"
|
|
|
33
34
|
respx = "^0.20.2"
|
|
34
35
|
twine = "^5.0.0"
|
|
35
36
|
commitizen = "^3.18.0"
|
|
37
|
+
mkdocs = "^1.5.3"
|
|
38
|
+
mkdocstrings = "^0.24.1"
|
|
39
|
+
mkdocs-material = "^9.5.13"
|
|
36
40
|
|
|
37
41
|
[tool.mypy]
|
|
38
42
|
python_version = "3.9"
|
|
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
|