mostlyai 0.3.4__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.4 → mostlyai-0.3.5}/PKG-INFO +1 -1
- {mostlyai-0.3.4 → mostlyai-0.3.5}/mostlyai/api.py +134 -102
- {mostlyai-0.3.4 → mostlyai-0.3.5}/mostlyai/connectors.py +7 -1
- {mostlyai-0.3.4 → mostlyai-0.3.5}/mostlyai/model.py +67 -1
- {mostlyai-0.3.4 → mostlyai-0.3.5}/pyproject.toml +1 -1
- {mostlyai-0.3.4 → mostlyai-0.3.5}/LICENSE +0 -0
- {mostlyai-0.3.4 → mostlyai-0.3.5}/README.md +0 -0
- {mostlyai-0.3.4 → mostlyai-0.3.5}/mostlyai/__init__.py +0 -0
- {mostlyai-0.3.4 → mostlyai-0.3.5}/mostlyai/base.py +0 -0
- {mostlyai-0.3.4 → mostlyai-0.3.5}/mostlyai/exceptions.py +0 -0
- {mostlyai-0.3.4 → mostlyai-0.3.5}/mostlyai/generators.py +0 -0
- {mostlyai-0.3.4 → mostlyai-0.3.5}/mostlyai/shares.py +0 -0
- {mostlyai-0.3.4 → mostlyai-0.3.5}/mostlyai/synthetic_datasets.py +0 -0
- {mostlyai-0.3.4 → 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"
|
|
@@ -250,11 +252,38 @@ class Connector(CustomBaseModel):
|
|
|
250
252
|
For storage connectors, this returns list of folders and files at root, respectively at `prefix` level.
|
|
251
253
|
For DB connectors, this returns list of schemas (or databases for DBs without schema), respectively list of tables if `prefix` is provided.
|
|
252
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`
|
|
253
271
|
:param prefix: The prefix to filter the results by.
|
|
254
272
|
:return: A list of locations (schemas, databases, directories, etc.) on the given level.
|
|
255
273
|
"""
|
|
256
274
|
return self.client._locations(connector_id=self.id, prefix=prefix)
|
|
257
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
|
+
|
|
258
287
|
def config(self) -> dict[str, Any]:
|
|
259
288
|
"""
|
|
260
289
|
Retrieve writeable generator properties
|
|
@@ -313,6 +342,40 @@ class SourceTableIncludeChildren(RootModel[bool]):
|
|
|
313
342
|
]
|
|
314
343
|
|
|
315
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
|
+
|
|
316
379
|
class SourceColumn(CustomBaseModel):
|
|
317
380
|
id: Annotated[str, Field(description="The unique identifier of a source column")]
|
|
318
381
|
name: Annotated[str, Field(description="The name of a source column")]
|
|
@@ -323,6 +386,9 @@ class SourceColumn(CustomBaseModel):
|
|
|
323
386
|
),
|
|
324
387
|
]
|
|
325
388
|
model_encoding_type: Annotated[ModelEncodingType, Field(alias="modelEncodingType")]
|
|
389
|
+
value_range: Annotated[
|
|
390
|
+
Optional[SourceColumnValueRange], Field(alias="valueRange")
|
|
391
|
+
] = None
|
|
326
392
|
|
|
327
393
|
|
|
328
394
|
class SourceForeignKey(CustomBaseModel):
|
|
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
|