databricks-sdk 0.28.0__py3-none-any.whl → 0.30.0__py3-none-any.whl
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.
Potentially problematic release.
This version of databricks-sdk might be problematic. Click here for more details.
- databricks/sdk/__init__.py +74 -22
- databricks/sdk/config.py +89 -48
- databricks/sdk/core.py +38 -9
- databricks/sdk/credentials_provider.py +134 -57
- databricks/sdk/data_plane.py +65 -0
- databricks/sdk/dbutils.py +81 -3
- databricks/sdk/mixins/files.py +12 -4
- databricks/sdk/oauth.py +8 -6
- databricks/sdk/service/apps.py +977 -0
- databricks/sdk/service/billing.py +602 -218
- databricks/sdk/service/catalog.py +263 -62
- databricks/sdk/service/compute.py +515 -94
- databricks/sdk/service/dashboards.py +1310 -2
- databricks/sdk/service/iam.py +99 -88
- databricks/sdk/service/jobs.py +159 -166
- databricks/sdk/service/marketplace.py +74 -58
- databricks/sdk/service/oauth2.py +149 -70
- databricks/sdk/service/pipelines.py +73 -53
- databricks/sdk/service/serving.py +332 -694
- databricks/sdk/service/settings.py +424 -4
- databricks/sdk/service/sharing.py +235 -26
- databricks/sdk/service/sql.py +2484 -553
- databricks/sdk/service/vectorsearch.py +75 -0
- databricks/sdk/useragent.py +144 -0
- databricks/sdk/version.py +1 -1
- {databricks_sdk-0.28.0.dist-info → databricks_sdk-0.30.0.dist-info}/METADATA +37 -16
- {databricks_sdk-0.28.0.dist-info → databricks_sdk-0.30.0.dist-info}/RECORD +31 -28
- {databricks_sdk-0.28.0.dist-info → databricks_sdk-0.30.0.dist-info}/WHEEL +1 -1
- {databricks_sdk-0.28.0.dist-info → databricks_sdk-0.30.0.dist-info}/LICENSE +0 -0
- {databricks_sdk-0.28.0.dist-info → databricks_sdk-0.30.0.dist-info}/NOTICE +0 -0
- {databricks_sdk-0.28.0.dist-info → databricks_sdk-0.30.0.dist-info}/top_level.txt +0 -0
|
@@ -10,29 +10,44 @@ from datetime import timedelta
|
|
|
10
10
|
from enum import Enum
|
|
11
11
|
from typing import Any, BinaryIO, Callable, Dict, Iterator, List, Optional
|
|
12
12
|
|
|
13
|
+
import requests
|
|
14
|
+
|
|
15
|
+
from ..data_plane import DataPlaneService
|
|
13
16
|
from ..errors import OperationFailed
|
|
14
17
|
from ._internal import Wait, _enum, _from_dict, _repeated_dict
|
|
15
18
|
|
|
16
19
|
_LOG = logging.getLogger('databricks.sdk')
|
|
17
20
|
|
|
21
|
+
from databricks.sdk.service import oauth2
|
|
22
|
+
|
|
18
23
|
# all definitions in this file are in alphabetical order
|
|
19
24
|
|
|
20
25
|
|
|
21
26
|
@dataclass
|
|
22
27
|
class Ai21LabsConfig:
|
|
23
|
-
ai21labs_api_key: str
|
|
24
|
-
"""The Databricks secret key reference for an
|
|
28
|
+
ai21labs_api_key: Optional[str] = None
|
|
29
|
+
"""The Databricks secret key reference for an AI21 Labs API key. If you prefer to paste your API
|
|
30
|
+
key directly, see `ai21labs_api_key_plaintext`. You must provide an API key using one of the
|
|
31
|
+
following fields: `ai21labs_api_key` or `ai21labs_api_key_plaintext`."""
|
|
32
|
+
|
|
33
|
+
ai21labs_api_key_plaintext: Optional[str] = None
|
|
34
|
+
"""An AI21 Labs API key provided as a plaintext string. If you prefer to reference your key using
|
|
35
|
+
Databricks Secrets, see `ai21labs_api_key`. You must provide an API key using one of the
|
|
36
|
+
following fields: `ai21labs_api_key` or `ai21labs_api_key_plaintext`."""
|
|
25
37
|
|
|
26
38
|
def as_dict(self) -> dict:
|
|
27
39
|
"""Serializes the Ai21LabsConfig into a dictionary suitable for use as a JSON request body."""
|
|
28
40
|
body = {}
|
|
29
41
|
if self.ai21labs_api_key is not None: body['ai21labs_api_key'] = self.ai21labs_api_key
|
|
42
|
+
if self.ai21labs_api_key_plaintext is not None:
|
|
43
|
+
body['ai21labs_api_key_plaintext'] = self.ai21labs_api_key_plaintext
|
|
30
44
|
return body
|
|
31
45
|
|
|
32
46
|
@classmethod
|
|
33
47
|
def from_dict(cls, d: Dict[str, any]) -> Ai21LabsConfig:
|
|
34
48
|
"""Deserializes the Ai21LabsConfig from a dictionary."""
|
|
35
|
-
return cls(ai21labs_api_key=d.get('ai21labs_api_key', None)
|
|
49
|
+
return cls(ai21labs_api_key=d.get('ai21labs_api_key', None),
|
|
50
|
+
ai21labs_api_key_plaintext=d.get('ai21labs_api_key_plaintext', None))
|
|
36
51
|
|
|
37
52
|
|
|
38
53
|
@dataclass
|
|
@@ -40,24 +55,44 @@ class AmazonBedrockConfig:
|
|
|
40
55
|
aws_region: str
|
|
41
56
|
"""The AWS region to use. Bedrock has to be enabled there."""
|
|
42
57
|
|
|
43
|
-
aws_access_key_id: str
|
|
44
|
-
"""The Databricks secret key reference for an AWS Access Key ID with permissions to interact with
|
|
45
|
-
Bedrock services."""
|
|
46
|
-
|
|
47
|
-
aws_secret_access_key: str
|
|
48
|
-
"""The Databricks secret key reference for an AWS Secret Access Key paired with the access key ID,
|
|
49
|
-
with permissions to interact with Bedrock services."""
|
|
50
|
-
|
|
51
58
|
bedrock_provider: AmazonBedrockConfigBedrockProvider
|
|
52
59
|
"""The underlying provider in Amazon Bedrock. Supported values (case insensitive) include:
|
|
53
60
|
Anthropic, Cohere, AI21Labs, Amazon."""
|
|
54
61
|
|
|
62
|
+
aws_access_key_id: Optional[str] = None
|
|
63
|
+
"""The Databricks secret key reference for an AWS access key ID with permissions to interact with
|
|
64
|
+
Bedrock services. If you prefer to paste your API key directly, see `aws_access_key_id`. You
|
|
65
|
+
must provide an API key using one of the following fields: `aws_access_key_id` or
|
|
66
|
+
`aws_access_key_id_plaintext`."""
|
|
67
|
+
|
|
68
|
+
aws_access_key_id_plaintext: Optional[str] = None
|
|
69
|
+
"""An AWS access key ID with permissions to interact with Bedrock services provided as a plaintext
|
|
70
|
+
string. If you prefer to reference your key using Databricks Secrets, see `aws_access_key_id`.
|
|
71
|
+
You must provide an API key using one of the following fields: `aws_access_key_id` or
|
|
72
|
+
`aws_access_key_id_plaintext`."""
|
|
73
|
+
|
|
74
|
+
aws_secret_access_key: Optional[str] = None
|
|
75
|
+
"""The Databricks secret key reference for an AWS secret access key paired with the access key ID,
|
|
76
|
+
with permissions to interact with Bedrock services. If you prefer to paste your API key
|
|
77
|
+
directly, see `aws_secret_access_key_plaintext`. You must provide an API key using one of the
|
|
78
|
+
following fields: `aws_secret_access_key` or `aws_secret_access_key_plaintext`."""
|
|
79
|
+
|
|
80
|
+
aws_secret_access_key_plaintext: Optional[str] = None
|
|
81
|
+
"""An AWS secret access key paired with the access key ID, with permissions to interact with
|
|
82
|
+
Bedrock services provided as a plaintext string. If you prefer to reference your key using
|
|
83
|
+
Databricks Secrets, see `aws_secret_access_key`. You must provide an API key using one of the
|
|
84
|
+
following fields: `aws_secret_access_key` or `aws_secret_access_key_plaintext`."""
|
|
85
|
+
|
|
55
86
|
def as_dict(self) -> dict:
|
|
56
87
|
"""Serializes the AmazonBedrockConfig into a dictionary suitable for use as a JSON request body."""
|
|
57
88
|
body = {}
|
|
58
89
|
if self.aws_access_key_id is not None: body['aws_access_key_id'] = self.aws_access_key_id
|
|
90
|
+
if self.aws_access_key_id_plaintext is not None:
|
|
91
|
+
body['aws_access_key_id_plaintext'] = self.aws_access_key_id_plaintext
|
|
59
92
|
if self.aws_region is not None: body['aws_region'] = self.aws_region
|
|
60
93
|
if self.aws_secret_access_key is not None: body['aws_secret_access_key'] = self.aws_secret_access_key
|
|
94
|
+
if self.aws_secret_access_key_plaintext is not None:
|
|
95
|
+
body['aws_secret_access_key_plaintext'] = self.aws_secret_access_key_plaintext
|
|
61
96
|
if self.bedrock_provider is not None: body['bedrock_provider'] = self.bedrock_provider.value
|
|
62
97
|
return body
|
|
63
98
|
|
|
@@ -65,8 +100,10 @@ class AmazonBedrockConfig:
|
|
|
65
100
|
def from_dict(cls, d: Dict[str, any]) -> AmazonBedrockConfig:
|
|
66
101
|
"""Deserializes the AmazonBedrockConfig from a dictionary."""
|
|
67
102
|
return cls(aws_access_key_id=d.get('aws_access_key_id', None),
|
|
103
|
+
aws_access_key_id_plaintext=d.get('aws_access_key_id_plaintext', None),
|
|
68
104
|
aws_region=d.get('aws_region', None),
|
|
69
105
|
aws_secret_access_key=d.get('aws_secret_access_key', None),
|
|
106
|
+
aws_secret_access_key_plaintext=d.get('aws_secret_access_key_plaintext', None),
|
|
70
107
|
bedrock_provider=_enum(d, 'bedrock_provider', AmazonBedrockConfigBedrockProvider))
|
|
71
108
|
|
|
72
109
|
|
|
@@ -82,248 +119,47 @@ class AmazonBedrockConfigBedrockProvider(Enum):
|
|
|
82
119
|
|
|
83
120
|
@dataclass
|
|
84
121
|
class AnthropicConfig:
|
|
85
|
-
anthropic_api_key: str
|
|
86
|
-
"""The Databricks secret key reference for an Anthropic API key.
|
|
122
|
+
anthropic_api_key: Optional[str] = None
|
|
123
|
+
"""The Databricks secret key reference for an Anthropic API key. If you prefer to paste your API
|
|
124
|
+
key directly, see `anthropic_api_key_plaintext`. You must provide an API key using one of the
|
|
125
|
+
following fields: `anthropic_api_key` or `anthropic_api_key_plaintext`."""
|
|
126
|
+
|
|
127
|
+
anthropic_api_key_plaintext: Optional[str] = None
|
|
128
|
+
"""The Anthropic API key provided as a plaintext string. If you prefer to reference your key using
|
|
129
|
+
Databricks Secrets, see `anthropic_api_key`. You must provide an API key using one of the
|
|
130
|
+
following fields: `anthropic_api_key` or `anthropic_api_key_plaintext`."""
|
|
87
131
|
|
|
88
132
|
def as_dict(self) -> dict:
|
|
89
133
|
"""Serializes the AnthropicConfig into a dictionary suitable for use as a JSON request body."""
|
|
90
134
|
body = {}
|
|
91
135
|
if self.anthropic_api_key is not None: body['anthropic_api_key'] = self.anthropic_api_key
|
|
136
|
+
if self.anthropic_api_key_plaintext is not None:
|
|
137
|
+
body['anthropic_api_key_plaintext'] = self.anthropic_api_key_plaintext
|
|
92
138
|
return body
|
|
93
139
|
|
|
94
140
|
@classmethod
|
|
95
141
|
def from_dict(cls, d: Dict[str, any]) -> AnthropicConfig:
|
|
96
142
|
"""Deserializes the AnthropicConfig from a dictionary."""
|
|
97
|
-
return cls(anthropic_api_key=d.get('anthropic_api_key', None)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
@dataclass
|
|
101
|
-
class App:
|
|
102
|
-
name: str
|
|
103
|
-
"""The name of the app. The name must contain only lowercase alphanumeric characters and hyphens
|
|
104
|
-
and be between 2 and 30 characters long. It must be unique within the workspace."""
|
|
105
|
-
|
|
106
|
-
active_deployment: Optional[AppDeployment] = None
|
|
107
|
-
"""The active deployment of the app."""
|
|
108
|
-
|
|
109
|
-
create_time: Optional[str] = None
|
|
110
|
-
"""The creation time of the app. Formatted timestamp in ISO 6801."""
|
|
111
|
-
|
|
112
|
-
creator: Optional[str] = None
|
|
113
|
-
"""The email of the user that created the app."""
|
|
114
|
-
|
|
115
|
-
description: Optional[str] = None
|
|
116
|
-
"""The description of the app."""
|
|
117
|
-
|
|
118
|
-
pending_deployment: Optional[AppDeployment] = None
|
|
119
|
-
"""The pending deployment of the app."""
|
|
120
|
-
|
|
121
|
-
status: Optional[AppStatus] = None
|
|
122
|
-
|
|
123
|
-
update_time: Optional[str] = None
|
|
124
|
-
"""The update time of the app. Formatted timestamp in ISO 6801."""
|
|
125
|
-
|
|
126
|
-
updater: Optional[str] = None
|
|
127
|
-
"""The email of the user that last updated the app."""
|
|
128
|
-
|
|
129
|
-
url: Optional[str] = None
|
|
130
|
-
"""The URL of the app once it is deployed."""
|
|
131
|
-
|
|
132
|
-
def as_dict(self) -> dict:
|
|
133
|
-
"""Serializes the App into a dictionary suitable for use as a JSON request body."""
|
|
134
|
-
body = {}
|
|
135
|
-
if self.active_deployment: body['active_deployment'] = self.active_deployment.as_dict()
|
|
136
|
-
if self.create_time is not None: body['create_time'] = self.create_time
|
|
137
|
-
if self.creator is not None: body['creator'] = self.creator
|
|
138
|
-
if self.description is not None: body['description'] = self.description
|
|
139
|
-
if self.name is not None: body['name'] = self.name
|
|
140
|
-
if self.pending_deployment: body['pending_deployment'] = self.pending_deployment.as_dict()
|
|
141
|
-
if self.status: body['status'] = self.status.as_dict()
|
|
142
|
-
if self.update_time is not None: body['update_time'] = self.update_time
|
|
143
|
-
if self.updater is not None: body['updater'] = self.updater
|
|
144
|
-
if self.url is not None: body['url'] = self.url
|
|
145
|
-
return body
|
|
146
|
-
|
|
147
|
-
@classmethod
|
|
148
|
-
def from_dict(cls, d: Dict[str, any]) -> App:
|
|
149
|
-
"""Deserializes the App from a dictionary."""
|
|
150
|
-
return cls(active_deployment=_from_dict(d, 'active_deployment', AppDeployment),
|
|
151
|
-
create_time=d.get('create_time', None),
|
|
152
|
-
creator=d.get('creator', None),
|
|
153
|
-
description=d.get('description', None),
|
|
154
|
-
name=d.get('name', None),
|
|
155
|
-
pending_deployment=_from_dict(d, 'pending_deployment', AppDeployment),
|
|
156
|
-
status=_from_dict(d, 'status', AppStatus),
|
|
157
|
-
update_time=d.get('update_time', None),
|
|
158
|
-
updater=d.get('updater', None),
|
|
159
|
-
url=d.get('url', None))
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
@dataclass
|
|
163
|
-
class AppDeployment:
|
|
164
|
-
source_code_path: str
|
|
165
|
-
"""The source code path of the deployment."""
|
|
166
|
-
|
|
167
|
-
create_time: Optional[str] = None
|
|
168
|
-
"""The creation time of the deployment. Formatted timestamp in ISO 6801."""
|
|
169
|
-
|
|
170
|
-
creator: Optional[str] = None
|
|
171
|
-
"""The email of the user creates the deployment."""
|
|
172
|
-
|
|
173
|
-
deployment_artifacts: Optional[AppDeploymentArtifacts] = None
|
|
174
|
-
"""The deployment artifacts for an app."""
|
|
175
|
-
|
|
176
|
-
deployment_id: Optional[str] = None
|
|
177
|
-
"""The unique id of the deployment."""
|
|
178
|
-
|
|
179
|
-
status: Optional[AppDeploymentStatus] = None
|
|
180
|
-
"""Status and status message of the deployment"""
|
|
181
|
-
|
|
182
|
-
update_time: Optional[str] = None
|
|
183
|
-
"""The update time of the deployment. Formatted timestamp in ISO 6801."""
|
|
184
|
-
|
|
185
|
-
def as_dict(self) -> dict:
|
|
186
|
-
"""Serializes the AppDeployment into a dictionary suitable for use as a JSON request body."""
|
|
187
|
-
body = {}
|
|
188
|
-
if self.create_time is not None: body['create_time'] = self.create_time
|
|
189
|
-
if self.creator is not None: body['creator'] = self.creator
|
|
190
|
-
if self.deployment_artifacts: body['deployment_artifacts'] = self.deployment_artifacts.as_dict()
|
|
191
|
-
if self.deployment_id is not None: body['deployment_id'] = self.deployment_id
|
|
192
|
-
if self.source_code_path is not None: body['source_code_path'] = self.source_code_path
|
|
193
|
-
if self.status: body['status'] = self.status.as_dict()
|
|
194
|
-
if self.update_time is not None: body['update_time'] = self.update_time
|
|
195
|
-
return body
|
|
196
|
-
|
|
197
|
-
@classmethod
|
|
198
|
-
def from_dict(cls, d: Dict[str, any]) -> AppDeployment:
|
|
199
|
-
"""Deserializes the AppDeployment from a dictionary."""
|
|
200
|
-
return cls(create_time=d.get('create_time', None),
|
|
201
|
-
creator=d.get('creator', None),
|
|
202
|
-
deployment_artifacts=_from_dict(d, 'deployment_artifacts', AppDeploymentArtifacts),
|
|
203
|
-
deployment_id=d.get('deployment_id', None),
|
|
204
|
-
source_code_path=d.get('source_code_path', None),
|
|
205
|
-
status=_from_dict(d, 'status', AppDeploymentStatus),
|
|
206
|
-
update_time=d.get('update_time', None))
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
@dataclass
|
|
210
|
-
class AppDeploymentArtifacts:
|
|
211
|
-
source_code_path: Optional[str] = None
|
|
212
|
-
"""The source code of the deployment."""
|
|
213
|
-
|
|
214
|
-
def as_dict(self) -> dict:
|
|
215
|
-
"""Serializes the AppDeploymentArtifacts into a dictionary suitable for use as a JSON request body."""
|
|
216
|
-
body = {}
|
|
217
|
-
if self.source_code_path is not None: body['source_code_path'] = self.source_code_path
|
|
218
|
-
return body
|
|
219
|
-
|
|
220
|
-
@classmethod
|
|
221
|
-
def from_dict(cls, d: Dict[str, any]) -> AppDeploymentArtifacts:
|
|
222
|
-
"""Deserializes the AppDeploymentArtifacts from a dictionary."""
|
|
223
|
-
return cls(source_code_path=d.get('source_code_path', None))
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
class AppDeploymentState(Enum):
|
|
227
|
-
|
|
228
|
-
CANCELLED = 'CANCELLED'
|
|
229
|
-
FAILED = 'FAILED'
|
|
230
|
-
IN_PROGRESS = 'IN_PROGRESS'
|
|
231
|
-
STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'
|
|
232
|
-
STOPPED = 'STOPPED'
|
|
233
|
-
SUCCEEDED = 'SUCCEEDED'
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
@dataclass
|
|
237
|
-
class AppDeploymentStatus:
|
|
238
|
-
message: Optional[str] = None
|
|
239
|
-
"""Message corresponding with the deployment state."""
|
|
240
|
-
|
|
241
|
-
state: Optional[AppDeploymentState] = None
|
|
242
|
-
"""State of the deployment."""
|
|
243
|
-
|
|
244
|
-
def as_dict(self) -> dict:
|
|
245
|
-
"""Serializes the AppDeploymentStatus into a dictionary suitable for use as a JSON request body."""
|
|
246
|
-
body = {}
|
|
247
|
-
if self.message is not None: body['message'] = self.message
|
|
248
|
-
if self.state is not None: body['state'] = self.state.value
|
|
249
|
-
return body
|
|
250
|
-
|
|
251
|
-
@classmethod
|
|
252
|
-
def from_dict(cls, d: Dict[str, any]) -> AppDeploymentStatus:
|
|
253
|
-
"""Deserializes the AppDeploymentStatus from a dictionary."""
|
|
254
|
-
return cls(message=d.get('message', None), state=_enum(d, 'state', AppDeploymentState))
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
@dataclass
|
|
258
|
-
class AppEnvironment:
|
|
259
|
-
env: Optional[List[EnvVariable]] = None
|
|
260
|
-
|
|
261
|
-
def as_dict(self) -> dict:
|
|
262
|
-
"""Serializes the AppEnvironment into a dictionary suitable for use as a JSON request body."""
|
|
263
|
-
body = {}
|
|
264
|
-
if self.env: body['env'] = [v.as_dict() for v in self.env]
|
|
265
|
-
return body
|
|
266
|
-
|
|
267
|
-
@classmethod
|
|
268
|
-
def from_dict(cls, d: Dict[str, any]) -> AppEnvironment:
|
|
269
|
-
"""Deserializes the AppEnvironment from a dictionary."""
|
|
270
|
-
return cls(env=_repeated_dict(d, 'env', EnvVariable))
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
class AppState(Enum):
|
|
274
|
-
|
|
275
|
-
CREATING = 'CREATING'
|
|
276
|
-
DELETED = 'DELETED'
|
|
277
|
-
DELETING = 'DELETING'
|
|
278
|
-
DEPLOYED = 'DEPLOYED'
|
|
279
|
-
DEPLOYING = 'DEPLOYING'
|
|
280
|
-
ERROR = 'ERROR'
|
|
281
|
-
IDLE = 'IDLE'
|
|
282
|
-
READY = 'READY'
|
|
283
|
-
RUNNING = 'RUNNING'
|
|
284
|
-
STARTING = 'STARTING'
|
|
285
|
-
STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'
|
|
286
|
-
UPDATING = 'UPDATING'
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
@dataclass
|
|
290
|
-
class AppStatus:
|
|
291
|
-
message: Optional[str] = None
|
|
292
|
-
"""Message corresponding with the app state."""
|
|
293
|
-
|
|
294
|
-
state: Optional[AppState] = None
|
|
295
|
-
"""State of the app."""
|
|
296
|
-
|
|
297
|
-
def as_dict(self) -> dict:
|
|
298
|
-
"""Serializes the AppStatus into a dictionary suitable for use as a JSON request body."""
|
|
299
|
-
body = {}
|
|
300
|
-
if self.message is not None: body['message'] = self.message
|
|
301
|
-
if self.state is not None: body['state'] = self.state.value
|
|
302
|
-
return body
|
|
303
|
-
|
|
304
|
-
@classmethod
|
|
305
|
-
def from_dict(cls, d: Dict[str, any]) -> AppStatus:
|
|
306
|
-
"""Deserializes the AppStatus from a dictionary."""
|
|
307
|
-
return cls(message=d.get('message', None), state=_enum(d, 'state', AppState))
|
|
143
|
+
return cls(anthropic_api_key=d.get('anthropic_api_key', None),
|
|
144
|
+
anthropic_api_key_plaintext=d.get('anthropic_api_key_plaintext', None))
|
|
308
145
|
|
|
309
146
|
|
|
310
147
|
@dataclass
|
|
311
148
|
class AutoCaptureConfigInput:
|
|
312
149
|
catalog_name: Optional[str] = None
|
|
313
150
|
"""The name of the catalog in Unity Catalog. NOTE: On update, you cannot change the catalog name if
|
|
314
|
-
|
|
151
|
+
the inference table is already enabled."""
|
|
315
152
|
|
|
316
153
|
enabled: Optional[bool] = None
|
|
317
|
-
"""
|
|
318
|
-
you cannot enable again."""
|
|
154
|
+
"""Indicates whether the inference table is enabled."""
|
|
319
155
|
|
|
320
156
|
schema_name: Optional[str] = None
|
|
321
157
|
"""The name of the schema in Unity Catalog. NOTE: On update, you cannot change the schema name if
|
|
322
|
-
|
|
158
|
+
the inference table is already enabled."""
|
|
323
159
|
|
|
324
160
|
table_name_prefix: Optional[str] = None
|
|
325
161
|
"""The prefix of the table in Unity Catalog. NOTE: On update, you cannot change the prefix name if
|
|
326
|
-
|
|
162
|
+
the inference table is already enabled."""
|
|
327
163
|
|
|
328
164
|
def as_dict(self) -> dict:
|
|
329
165
|
"""Serializes the AutoCaptureConfigInput into a dictionary suitable for use as a JSON request body."""
|
|
@@ -349,7 +185,7 @@ class AutoCaptureConfigOutput:
|
|
|
349
185
|
"""The name of the catalog in Unity Catalog."""
|
|
350
186
|
|
|
351
187
|
enabled: Optional[bool] = None
|
|
352
|
-
"""
|
|
188
|
+
"""Indicates whether the inference table is enabled."""
|
|
353
189
|
|
|
354
190
|
schema_name: Optional[str] = None
|
|
355
191
|
"""The name of the schema in Unity Catalog."""
|
|
@@ -443,62 +279,35 @@ class ChatMessageRole(Enum):
|
|
|
443
279
|
|
|
444
280
|
@dataclass
|
|
445
281
|
class CohereConfig:
|
|
446
|
-
|
|
447
|
-
"""
|
|
282
|
+
cohere_api_base: Optional[str] = None
|
|
283
|
+
"""This is an optional field to provide a customized base URL for the Cohere API. If left
|
|
284
|
+
unspecified, the standard Cohere base URL is used."""
|
|
285
|
+
|
|
286
|
+
cohere_api_key: Optional[str] = None
|
|
287
|
+
"""The Databricks secret key reference for a Cohere API key. If you prefer to paste your API key
|
|
288
|
+
directly, see `cohere_api_key_plaintext`. You must provide an API key using one of the following
|
|
289
|
+
fields: `cohere_api_key` or `cohere_api_key_plaintext`."""
|
|
290
|
+
|
|
291
|
+
cohere_api_key_plaintext: Optional[str] = None
|
|
292
|
+
"""The Cohere API key provided as a plaintext string. If you prefer to reference your key using
|
|
293
|
+
Databricks Secrets, see `cohere_api_key`. You must provide an API key using one of the following
|
|
294
|
+
fields: `cohere_api_key` or `cohere_api_key_plaintext`."""
|
|
448
295
|
|
|
449
296
|
def as_dict(self) -> dict:
|
|
450
297
|
"""Serializes the CohereConfig into a dictionary suitable for use as a JSON request body."""
|
|
451
298
|
body = {}
|
|
299
|
+
if self.cohere_api_base is not None: body['cohere_api_base'] = self.cohere_api_base
|
|
452
300
|
if self.cohere_api_key is not None: body['cohere_api_key'] = self.cohere_api_key
|
|
301
|
+
if self.cohere_api_key_plaintext is not None:
|
|
302
|
+
body['cohere_api_key_plaintext'] = self.cohere_api_key_plaintext
|
|
453
303
|
return body
|
|
454
304
|
|
|
455
305
|
@classmethod
|
|
456
306
|
def from_dict(cls, d: Dict[str, any]) -> CohereConfig:
|
|
457
307
|
"""Deserializes the CohereConfig from a dictionary."""
|
|
458
|
-
return cls(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
@dataclass
|
|
462
|
-
class CreateAppDeploymentRequest:
|
|
463
|
-
source_code_path: str
|
|
464
|
-
"""The source code path of the deployment."""
|
|
465
|
-
|
|
466
|
-
app_name: Optional[str] = None
|
|
467
|
-
"""The name of the app."""
|
|
468
|
-
|
|
469
|
-
def as_dict(self) -> dict:
|
|
470
|
-
"""Serializes the CreateAppDeploymentRequest into a dictionary suitable for use as a JSON request body."""
|
|
471
|
-
body = {}
|
|
472
|
-
if self.app_name is not None: body['app_name'] = self.app_name
|
|
473
|
-
if self.source_code_path is not None: body['source_code_path'] = self.source_code_path
|
|
474
|
-
return body
|
|
475
|
-
|
|
476
|
-
@classmethod
|
|
477
|
-
def from_dict(cls, d: Dict[str, any]) -> CreateAppDeploymentRequest:
|
|
478
|
-
"""Deserializes the CreateAppDeploymentRequest from a dictionary."""
|
|
479
|
-
return cls(app_name=d.get('app_name', None), source_code_path=d.get('source_code_path', None))
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
@dataclass
|
|
483
|
-
class CreateAppRequest:
|
|
484
|
-
name: str
|
|
485
|
-
"""The name of the app. The name must contain only lowercase alphanumeric characters and hyphens
|
|
486
|
-
and be between 2 and 30 characters long. It must be unique within the workspace."""
|
|
487
|
-
|
|
488
|
-
description: Optional[str] = None
|
|
489
|
-
"""The description of the app."""
|
|
490
|
-
|
|
491
|
-
def as_dict(self) -> dict:
|
|
492
|
-
"""Serializes the CreateAppRequest into a dictionary suitable for use as a JSON request body."""
|
|
493
|
-
body = {}
|
|
494
|
-
if self.description is not None: body['description'] = self.description
|
|
495
|
-
if self.name is not None: body['name'] = self.name
|
|
496
|
-
return body
|
|
497
|
-
|
|
498
|
-
@classmethod
|
|
499
|
-
def from_dict(cls, d: Dict[str, any]) -> CreateAppRequest:
|
|
500
|
-
"""Deserializes the CreateAppRequest from a dictionary."""
|
|
501
|
-
return cls(description=d.get('description', None), name=d.get('name', None))
|
|
308
|
+
return cls(cohere_api_base=d.get('cohere_api_base', None),
|
|
309
|
+
cohere_api_key=d.get('cohere_api_key', None),
|
|
310
|
+
cohere_api_key_plaintext=d.get('cohere_api_key_plaintext', None))
|
|
502
311
|
|
|
503
312
|
|
|
504
313
|
@dataclass
|
|
@@ -542,19 +351,30 @@ class CreateServingEndpoint:
|
|
|
542
351
|
|
|
543
352
|
@dataclass
|
|
544
353
|
class DatabricksModelServingConfig:
|
|
545
|
-
databricks_api_token: str
|
|
546
|
-
"""The Databricks secret key reference for a Databricks API token that corresponds to a user or
|
|
547
|
-
service principal with Can Query access to the model serving endpoint pointed to by this
|
|
548
|
-
external model."""
|
|
549
|
-
|
|
550
354
|
databricks_workspace_url: str
|
|
551
355
|
"""The URL of the Databricks workspace containing the model serving endpoint pointed to by this
|
|
552
356
|
external model."""
|
|
553
357
|
|
|
358
|
+
databricks_api_token: Optional[str] = None
|
|
359
|
+
"""The Databricks secret key reference for a Databricks API token that corresponds to a user or
|
|
360
|
+
service principal with Can Query access to the model serving endpoint pointed to by this
|
|
361
|
+
external model. If you prefer to paste your API key directly, see
|
|
362
|
+
`databricks_api_token_plaintext`. You must provide an API key using one of the following fields:
|
|
363
|
+
`databricks_api_token` or `databricks_api_token_plaintext`."""
|
|
364
|
+
|
|
365
|
+
databricks_api_token_plaintext: Optional[str] = None
|
|
366
|
+
"""The Databricks API token that corresponds to a user or service principal with Can Query access
|
|
367
|
+
to the model serving endpoint pointed to by this external model provided as a plaintext string.
|
|
368
|
+
If you prefer to reference your key using Databricks Secrets, see `databricks_api_token`. You
|
|
369
|
+
must provide an API key using one of the following fields: `databricks_api_token` or
|
|
370
|
+
`databricks_api_token_plaintext`."""
|
|
371
|
+
|
|
554
372
|
def as_dict(self) -> dict:
|
|
555
373
|
"""Serializes the DatabricksModelServingConfig into a dictionary suitable for use as a JSON request body."""
|
|
556
374
|
body = {}
|
|
557
375
|
if self.databricks_api_token is not None: body['databricks_api_token'] = self.databricks_api_token
|
|
376
|
+
if self.databricks_api_token_plaintext is not None:
|
|
377
|
+
body['databricks_api_token_plaintext'] = self.databricks_api_token_plaintext
|
|
558
378
|
if self.databricks_workspace_url is not None:
|
|
559
379
|
body['databricks_workspace_url'] = self.databricks_workspace_url
|
|
560
380
|
return body
|
|
@@ -563,6 +383,7 @@ class DatabricksModelServingConfig:
|
|
|
563
383
|
def from_dict(cls, d: Dict[str, any]) -> DatabricksModelServingConfig:
|
|
564
384
|
"""Deserializes the DatabricksModelServingConfig from a dictionary."""
|
|
565
385
|
return cls(databricks_api_token=d.get('databricks_api_token', None),
|
|
386
|
+
databricks_api_token_plaintext=d.get('databricks_api_token_plaintext', None),
|
|
566
387
|
databricks_workspace_url=d.get('databricks_workspace_url', None))
|
|
567
388
|
|
|
568
389
|
|
|
@@ -815,6 +636,7 @@ class EndpointStateConfigUpdate(Enum):
|
|
|
815
636
|
|
|
816
637
|
IN_PROGRESS = 'IN_PROGRESS'
|
|
817
638
|
NOT_UPDATING = 'NOT_UPDATING'
|
|
639
|
+
UPDATE_CANCELED = 'UPDATE_CANCELED'
|
|
818
640
|
UPDATE_FAILED = 'UPDATE_FAILED'
|
|
819
641
|
|
|
820
642
|
|
|
@@ -848,28 +670,6 @@ class EndpointTag:
|
|
|
848
670
|
return cls(key=d.get('key', None), value=d.get('value', None))
|
|
849
671
|
|
|
850
672
|
|
|
851
|
-
@dataclass
|
|
852
|
-
class EnvVariable:
|
|
853
|
-
name: Optional[str] = None
|
|
854
|
-
|
|
855
|
-
value: Optional[str] = None
|
|
856
|
-
|
|
857
|
-
value_from: Optional[str] = None
|
|
858
|
-
|
|
859
|
-
def as_dict(self) -> dict:
|
|
860
|
-
"""Serializes the EnvVariable into a dictionary suitable for use as a JSON request body."""
|
|
861
|
-
body = {}
|
|
862
|
-
if self.name is not None: body['name'] = self.name
|
|
863
|
-
if self.value is not None: body['value'] = self.value
|
|
864
|
-
if self.value_from is not None: body['value_from'] = self.value_from
|
|
865
|
-
return body
|
|
866
|
-
|
|
867
|
-
@classmethod
|
|
868
|
-
def from_dict(cls, d: Dict[str, any]) -> EnvVariable:
|
|
869
|
-
"""Deserializes the EnvVariable from a dictionary."""
|
|
870
|
-
return cls(name=d.get('name', None), value=d.get('value', None), value_from=d.get('value_from', None))
|
|
871
|
-
|
|
872
|
-
|
|
873
673
|
@dataclass
|
|
874
674
|
class ExportMetricsResponse:
|
|
875
675
|
contents: Optional[BinaryIO] = None
|
|
@@ -890,8 +690,8 @@ class ExportMetricsResponse:
|
|
|
890
690
|
class ExternalModel:
|
|
891
691
|
provider: ExternalModelProvider
|
|
892
692
|
"""The name of the provider for the external model. Currently, the supported providers are
|
|
893
|
-
'ai21labs', 'anthropic', 'amazon-bedrock', 'cohere', 'databricks-model-serving',
|
|
894
|
-
'palm'.","""
|
|
693
|
+
'ai21labs', 'anthropic', 'amazon-bedrock', 'cohere', 'databricks-model-serving',
|
|
694
|
+
'google-cloud-vertex-ai', 'openai', and 'palm'.","""
|
|
895
695
|
|
|
896
696
|
name: str
|
|
897
697
|
"""The name of the external model."""
|
|
@@ -914,6 +714,9 @@ class ExternalModel:
|
|
|
914
714
|
databricks_model_serving_config: Optional[DatabricksModelServingConfig] = None
|
|
915
715
|
"""Databricks Model Serving Config. Only required if the provider is 'databricks-model-serving'."""
|
|
916
716
|
|
|
717
|
+
google_cloud_vertex_ai_config: Optional[GoogleCloudVertexAiConfig] = None
|
|
718
|
+
"""Google Cloud Vertex AI Config. Only required if the provider is 'google-cloud-vertex-ai'."""
|
|
719
|
+
|
|
917
720
|
openai_config: Optional[OpenAiConfig] = None
|
|
918
721
|
"""OpenAI Config. Only required if the provider is 'openai'."""
|
|
919
722
|
|
|
@@ -929,6 +732,8 @@ class ExternalModel:
|
|
|
929
732
|
if self.cohere_config: body['cohere_config'] = self.cohere_config.as_dict()
|
|
930
733
|
if self.databricks_model_serving_config:
|
|
931
734
|
body['databricks_model_serving_config'] = self.databricks_model_serving_config.as_dict()
|
|
735
|
+
if self.google_cloud_vertex_ai_config:
|
|
736
|
+
body['google_cloud_vertex_ai_config'] = self.google_cloud_vertex_ai_config.as_dict()
|
|
932
737
|
if self.name is not None: body['name'] = self.name
|
|
933
738
|
if self.openai_config: body['openai_config'] = self.openai_config.as_dict()
|
|
934
739
|
if self.palm_config: body['palm_config'] = self.palm_config.as_dict()
|
|
@@ -945,6 +750,8 @@ class ExternalModel:
|
|
|
945
750
|
cohere_config=_from_dict(d, 'cohere_config', CohereConfig),
|
|
946
751
|
databricks_model_serving_config=_from_dict(d, 'databricks_model_serving_config',
|
|
947
752
|
DatabricksModelServingConfig),
|
|
753
|
+
google_cloud_vertex_ai_config=_from_dict(d, 'google_cloud_vertex_ai_config',
|
|
754
|
+
GoogleCloudVertexAiConfig),
|
|
948
755
|
name=d.get('name', None),
|
|
949
756
|
openai_config=_from_dict(d, 'openai_config', OpenAiConfig),
|
|
950
757
|
palm_config=_from_dict(d, 'palm_config', PaLmConfig),
|
|
@@ -954,14 +761,15 @@ class ExternalModel:
|
|
|
954
761
|
|
|
955
762
|
class ExternalModelProvider(Enum):
|
|
956
763
|
"""The name of the provider for the external model. Currently, the supported providers are
|
|
957
|
-
'ai21labs', 'anthropic', 'amazon-bedrock', 'cohere', 'databricks-model-serving',
|
|
958
|
-
'palm'.","""
|
|
764
|
+
'ai21labs', 'anthropic', 'amazon-bedrock', 'cohere', 'databricks-model-serving',
|
|
765
|
+
'google-cloud-vertex-ai', 'openai', and 'palm'.","""
|
|
959
766
|
|
|
960
767
|
AI21LABS = 'ai21labs'
|
|
961
768
|
AMAZON_BEDROCK = 'amazon-bedrock'
|
|
962
769
|
ANTHROPIC = 'anthropic'
|
|
963
770
|
COHERE = 'cohere'
|
|
964
771
|
DATABRICKS_MODEL_SERVING = 'databricks-model-serving'
|
|
772
|
+
GOOGLE_CLOUD_VERTEX_AI = 'google-cloud-vertex-ai'
|
|
965
773
|
OPENAI = 'openai'
|
|
966
774
|
PALM = 'palm'
|
|
967
775
|
|
|
@@ -1060,45 +868,48 @@ class GetServingEndpointPermissionLevelsResponse:
|
|
|
1060
868
|
|
|
1061
869
|
|
|
1062
870
|
@dataclass
|
|
1063
|
-
class
|
|
1064
|
-
|
|
1065
|
-
"""
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
"""Serializes the ListAppDeploymentsResponse into a dictionary suitable for use as a JSON request body."""
|
|
1072
|
-
body = {}
|
|
1073
|
-
if self.app_deployments: body['app_deployments'] = [v.as_dict() for v in self.app_deployments]
|
|
1074
|
-
if self.next_page_token is not None: body['next_page_token'] = self.next_page_token
|
|
1075
|
-
return body
|
|
871
|
+
class GoogleCloudVertexAiConfig:
|
|
872
|
+
private_key: Optional[str] = None
|
|
873
|
+
"""The Databricks secret key reference for a private key for the service account which has access
|
|
874
|
+
to the Google Cloud Vertex AI Service. See [Best practices for managing service account keys].
|
|
875
|
+
If you prefer to paste your API key directly, see `private_key_plaintext`. You must provide an
|
|
876
|
+
API key using one of the following fields: `private_key` or `private_key_plaintext`
|
|
877
|
+
|
|
878
|
+
[Best practices for managing service account keys]: https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys"""
|
|
1076
879
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
880
|
+
private_key_plaintext: Optional[str] = None
|
|
881
|
+
"""The private key for the service account which has access to the Google Cloud Vertex AI Service
|
|
882
|
+
provided as a plaintext secret. See [Best practices for managing service account keys]. If you
|
|
883
|
+
prefer to reference your key using Databricks Secrets, see `private_key`. You must provide an
|
|
884
|
+
API key using one of the following fields: `private_key` or `private_key_plaintext`.
|
|
885
|
+
|
|
886
|
+
[Best practices for managing service account keys]: https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys"""
|
|
1082
887
|
|
|
888
|
+
project_id: Optional[str] = None
|
|
889
|
+
"""This is the Google Cloud project id that the service account is associated with."""
|
|
1083
890
|
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
"""Pagination token to request the next page of apps."""
|
|
891
|
+
region: Optional[str] = None
|
|
892
|
+
"""This is the region for the Google Cloud Vertex AI Service. See [supported regions] for more
|
|
893
|
+
details. Some models are only available in specific regions.
|
|
894
|
+
|
|
895
|
+
[supported regions]: https://cloud.google.com/vertex-ai/docs/general/locations"""
|
|
1090
896
|
|
|
1091
897
|
def as_dict(self) -> dict:
|
|
1092
|
-
"""Serializes the
|
|
898
|
+
"""Serializes the GoogleCloudVertexAiConfig into a dictionary suitable for use as a JSON request body."""
|
|
1093
899
|
body = {}
|
|
1094
|
-
if self.
|
|
1095
|
-
if self.
|
|
900
|
+
if self.private_key is not None: body['private_key'] = self.private_key
|
|
901
|
+
if self.private_key_plaintext is not None: body['private_key_plaintext'] = self.private_key_plaintext
|
|
902
|
+
if self.project_id is not None: body['project_id'] = self.project_id
|
|
903
|
+
if self.region is not None: body['region'] = self.region
|
|
1096
904
|
return body
|
|
1097
905
|
|
|
1098
906
|
@classmethod
|
|
1099
|
-
def from_dict(cls, d: Dict[str, any]) ->
|
|
1100
|
-
"""Deserializes the
|
|
1101
|
-
return cls(
|
|
907
|
+
def from_dict(cls, d: Dict[str, any]) -> GoogleCloudVertexAiConfig:
|
|
908
|
+
"""Deserializes the GoogleCloudVertexAiConfig from a dictionary."""
|
|
909
|
+
return cls(private_key=d.get('private_key', None),
|
|
910
|
+
private_key_plaintext=d.get('private_key_plaintext', None),
|
|
911
|
+
project_id=d.get('project_id', None),
|
|
912
|
+
region=d.get('region', None))
|
|
1102
913
|
|
|
1103
914
|
|
|
1104
915
|
@dataclass
|
|
@@ -1118,25 +929,58 @@ class ListEndpointsResponse:
|
|
|
1118
929
|
return cls(endpoints=_repeated_dict(d, 'endpoints', ServingEndpoint))
|
|
1119
930
|
|
|
1120
931
|
|
|
932
|
+
@dataclass
|
|
933
|
+
class ModelDataPlaneInfo:
|
|
934
|
+
query_info: Optional[oauth2.DataPlaneInfo] = None
|
|
935
|
+
"""Information required to query DataPlane API 'query' endpoint."""
|
|
936
|
+
|
|
937
|
+
def as_dict(self) -> dict:
|
|
938
|
+
"""Serializes the ModelDataPlaneInfo into a dictionary suitable for use as a JSON request body."""
|
|
939
|
+
body = {}
|
|
940
|
+
if self.query_info: body['query_info'] = self.query_info.as_dict()
|
|
941
|
+
return body
|
|
942
|
+
|
|
943
|
+
@classmethod
|
|
944
|
+
def from_dict(cls, d: Dict[str, any]) -> ModelDataPlaneInfo:
|
|
945
|
+
"""Deserializes the ModelDataPlaneInfo from a dictionary."""
|
|
946
|
+
return cls(query_info=_from_dict(d, 'query_info', oauth2.DataPlaneInfo))
|
|
947
|
+
|
|
948
|
+
|
|
1121
949
|
@dataclass
|
|
1122
950
|
class OpenAiConfig:
|
|
1123
951
|
microsoft_entra_client_id: Optional[str] = None
|
|
1124
952
|
"""This field is only required for Azure AD OpenAI and is the Microsoft Entra Client ID."""
|
|
1125
953
|
|
|
1126
954
|
microsoft_entra_client_secret: Optional[str] = None
|
|
1127
|
-
"""The Databricks secret key reference for
|
|
1128
|
-
|
|
955
|
+
"""The Databricks secret key reference for a client secret used for Microsoft Entra ID
|
|
956
|
+
authentication. If you prefer to paste your client secret directly, see
|
|
957
|
+
`microsoft_entra_client_secret_plaintext`. You must provide an API key using one of the
|
|
958
|
+
following fields: `microsoft_entra_client_secret` or `microsoft_entra_client_secret_plaintext`."""
|
|
959
|
+
|
|
960
|
+
microsoft_entra_client_secret_plaintext: Optional[str] = None
|
|
961
|
+
"""The client secret used for Microsoft Entra ID authentication provided as a plaintext string. If
|
|
962
|
+
you prefer to reference your key using Databricks Secrets, see `microsoft_entra_client_secret`.
|
|
963
|
+
You must provide an API key using one of the following fields: `microsoft_entra_client_secret`
|
|
964
|
+
or `microsoft_entra_client_secret_plaintext`."""
|
|
1129
965
|
|
|
1130
966
|
microsoft_entra_tenant_id: Optional[str] = None
|
|
1131
967
|
"""This field is only required for Azure AD OpenAI and is the Microsoft Entra Tenant ID."""
|
|
1132
968
|
|
|
1133
969
|
openai_api_base: Optional[str] = None
|
|
1134
|
-
"""This is
|
|
1135
|
-
|
|
1136
|
-
|
|
970
|
+
"""This is a field to provide a customized base URl for the OpenAI API. For Azure OpenAI, this
|
|
971
|
+
field is required, and is the base URL for the Azure OpenAI API service provided by Azure. For
|
|
972
|
+
other OpenAI API types, this field is optional, and if left unspecified, the standard OpenAI
|
|
973
|
+
base URL is used."""
|
|
1137
974
|
|
|
1138
975
|
openai_api_key: Optional[str] = None
|
|
1139
|
-
"""The Databricks secret key reference for an OpenAI
|
|
976
|
+
"""The Databricks secret key reference for an OpenAI API key using the OpenAI or Azure service. If
|
|
977
|
+
you prefer to paste your API key directly, see `openai_api_key_plaintext`. You must provide an
|
|
978
|
+
API key using one of the following fields: `openai_api_key` or `openai_api_key_plaintext`."""
|
|
979
|
+
|
|
980
|
+
openai_api_key_plaintext: Optional[str] = None
|
|
981
|
+
"""The OpenAI API key using the OpenAI or Azure service provided as a plaintext string. If you
|
|
982
|
+
prefer to reference your key using Databricks Secrets, see `openai_api_key`. You must provide an
|
|
983
|
+
API key using one of the following fields: `openai_api_key` or `openai_api_key_plaintext`."""
|
|
1140
984
|
|
|
1141
985
|
openai_api_type: Optional[str] = None
|
|
1142
986
|
"""This is an optional field to specify the type of OpenAI API to use. For Azure OpenAI, this field
|
|
@@ -1162,10 +1006,14 @@ class OpenAiConfig:
|
|
|
1162
1006
|
body['microsoft_entra_client_id'] = self.microsoft_entra_client_id
|
|
1163
1007
|
if self.microsoft_entra_client_secret is not None:
|
|
1164
1008
|
body['microsoft_entra_client_secret'] = self.microsoft_entra_client_secret
|
|
1009
|
+
if self.microsoft_entra_client_secret_plaintext is not None:
|
|
1010
|
+
body['microsoft_entra_client_secret_plaintext'] = self.microsoft_entra_client_secret_plaintext
|
|
1165
1011
|
if self.microsoft_entra_tenant_id is not None:
|
|
1166
1012
|
body['microsoft_entra_tenant_id'] = self.microsoft_entra_tenant_id
|
|
1167
1013
|
if self.openai_api_base is not None: body['openai_api_base'] = self.openai_api_base
|
|
1168
1014
|
if self.openai_api_key is not None: body['openai_api_key'] = self.openai_api_key
|
|
1015
|
+
if self.openai_api_key_plaintext is not None:
|
|
1016
|
+
body['openai_api_key_plaintext'] = self.openai_api_key_plaintext
|
|
1169
1017
|
if self.openai_api_type is not None: body['openai_api_type'] = self.openai_api_type
|
|
1170
1018
|
if self.openai_api_version is not None: body['openai_api_version'] = self.openai_api_version
|
|
1171
1019
|
if self.openai_deployment_name is not None:
|
|
@@ -1178,9 +1026,12 @@ class OpenAiConfig:
|
|
|
1178
1026
|
"""Deserializes the OpenAiConfig from a dictionary."""
|
|
1179
1027
|
return cls(microsoft_entra_client_id=d.get('microsoft_entra_client_id', None),
|
|
1180
1028
|
microsoft_entra_client_secret=d.get('microsoft_entra_client_secret', None),
|
|
1029
|
+
microsoft_entra_client_secret_plaintext=d.get('microsoft_entra_client_secret_plaintext',
|
|
1030
|
+
None),
|
|
1181
1031
|
microsoft_entra_tenant_id=d.get('microsoft_entra_tenant_id', None),
|
|
1182
1032
|
openai_api_base=d.get('openai_api_base', None),
|
|
1183
1033
|
openai_api_key=d.get('openai_api_key', None),
|
|
1034
|
+
openai_api_key_plaintext=d.get('openai_api_key_plaintext', None),
|
|
1184
1035
|
openai_api_type=d.get('openai_api_type', None),
|
|
1185
1036
|
openai_api_version=d.get('openai_api_version', None),
|
|
1186
1037
|
openai_deployment_name=d.get('openai_deployment_name', None),
|
|
@@ -1189,19 +1040,29 @@ class OpenAiConfig:
|
|
|
1189
1040
|
|
|
1190
1041
|
@dataclass
|
|
1191
1042
|
class PaLmConfig:
|
|
1192
|
-
palm_api_key: str
|
|
1193
|
-
"""The Databricks secret key reference for a PaLM API key.
|
|
1043
|
+
palm_api_key: Optional[str] = None
|
|
1044
|
+
"""The Databricks secret key reference for a PaLM API key. If you prefer to paste your API key
|
|
1045
|
+
directly, see `palm_api_key_plaintext`. You must provide an API key using one of the following
|
|
1046
|
+
fields: `palm_api_key` or `palm_api_key_plaintext`."""
|
|
1047
|
+
|
|
1048
|
+
palm_api_key_plaintext: Optional[str] = None
|
|
1049
|
+
"""The PaLM API key provided as a plaintext string. If you prefer to reference your key using
|
|
1050
|
+
Databricks Secrets, see `palm_api_key`. You must provide an API key using one of the following
|
|
1051
|
+
fields: `palm_api_key` or `palm_api_key_plaintext`."""
|
|
1194
1052
|
|
|
1195
1053
|
def as_dict(self) -> dict:
|
|
1196
1054
|
"""Serializes the PaLmConfig into a dictionary suitable for use as a JSON request body."""
|
|
1197
1055
|
body = {}
|
|
1198
1056
|
if self.palm_api_key is not None: body['palm_api_key'] = self.palm_api_key
|
|
1057
|
+
if self.palm_api_key_plaintext is not None:
|
|
1058
|
+
body['palm_api_key_plaintext'] = self.palm_api_key_plaintext
|
|
1199
1059
|
return body
|
|
1200
1060
|
|
|
1201
1061
|
@classmethod
|
|
1202
1062
|
def from_dict(cls, d: Dict[str, any]) -> PaLmConfig:
|
|
1203
1063
|
"""Deserializes the PaLmConfig from a dictionary."""
|
|
1204
|
-
return cls(palm_api_key=d.get('palm_api_key', None)
|
|
1064
|
+
return cls(palm_api_key=d.get('palm_api_key', None),
|
|
1065
|
+
palm_api_key_plaintext=d.get('palm_api_key_plaintext', None))
|
|
1205
1066
|
|
|
1206
1067
|
|
|
1207
1068
|
@dataclass
|
|
@@ -1533,11 +1394,10 @@ class ServedEntityInput:
|
|
|
1533
1394
|
external_model: Optional[ExternalModel] = None
|
|
1534
1395
|
"""The external model to be served. NOTE: Only one of external_model and (entity_name,
|
|
1535
1396
|
entity_version, workload_size, workload_type, and scale_to_zero_enabled) can be specified with
|
|
1536
|
-
the latter set being used for custom model serving for a Databricks registered model.
|
|
1537
|
-
|
|
1538
|
-
an existing endpoint with external_model, it can not be updated to an endpoint without
|
|
1397
|
+
the latter set being used for custom model serving for a Databricks registered model. For an
|
|
1398
|
+
existing endpoint with external_model, it cannot be updated to an endpoint without
|
|
1539
1399
|
external_model. If the endpoint is created without external_model, users cannot update it to add
|
|
1540
|
-
external_model later."""
|
|
1400
|
+
external_model later. The task type of all external models within an endpoint must be the same."""
|
|
1541
1401
|
|
|
1542
1402
|
instance_profile_arn: Optional[str] = None
|
|
1543
1403
|
"""ARN of the instance profile that the served entity uses to access AWS resources."""
|
|
@@ -2172,6 +2032,9 @@ class ServingEndpointDetailed:
|
|
|
2172
2032
|
creator: Optional[str] = None
|
|
2173
2033
|
"""The email of the user who created the serving endpoint."""
|
|
2174
2034
|
|
|
2035
|
+
data_plane_info: Optional[ModelDataPlaneInfo] = None
|
|
2036
|
+
"""Information required to query DataPlane APIs."""
|
|
2037
|
+
|
|
2175
2038
|
endpoint_url: Optional[str] = None
|
|
2176
2039
|
"""Endpoint invocation url if route optimization is enabled for endpoint"""
|
|
2177
2040
|
|
|
@@ -2209,6 +2072,7 @@ class ServingEndpointDetailed:
|
|
|
2209
2072
|
if self.config: body['config'] = self.config.as_dict()
|
|
2210
2073
|
if self.creation_timestamp is not None: body['creation_timestamp'] = self.creation_timestamp
|
|
2211
2074
|
if self.creator is not None: body['creator'] = self.creator
|
|
2075
|
+
if self.data_plane_info: body['data_plane_info'] = self.data_plane_info.as_dict()
|
|
2212
2076
|
if self.endpoint_url is not None: body['endpoint_url'] = self.endpoint_url
|
|
2213
2077
|
if self.id is not None: body['id'] = self.id
|
|
2214
2078
|
if self.last_updated_timestamp is not None:
|
|
@@ -2228,6 +2092,7 @@ class ServingEndpointDetailed:
|
|
|
2228
2092
|
return cls(config=_from_dict(d, 'config', EndpointCoreConfigOutput),
|
|
2229
2093
|
creation_timestamp=d.get('creation_timestamp', None),
|
|
2230
2094
|
creator=d.get('creator', None),
|
|
2095
|
+
data_plane_info=_from_dict(d, 'data_plane_info', ModelDataPlaneInfo),
|
|
2231
2096
|
endpoint_url=d.get('endpoint_url', None),
|
|
2232
2097
|
id=d.get('id', None),
|
|
2233
2098
|
last_updated_timestamp=d.get('last_updated_timestamp', None),
|
|
@@ -2351,26 +2216,6 @@ class ServingEndpointPermissionsRequest:
|
|
|
2351
2216
|
serving_endpoint_id=d.get('serving_endpoint_id', None))
|
|
2352
2217
|
|
|
2353
2218
|
|
|
2354
|
-
@dataclass
|
|
2355
|
-
class StopAppRequest:
|
|
2356
|
-
name: Optional[str] = None
|
|
2357
|
-
"""The name of the app."""
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
@dataclass
|
|
2361
|
-
class StopAppResponse:
|
|
2362
|
-
|
|
2363
|
-
def as_dict(self) -> dict:
|
|
2364
|
-
"""Serializes the StopAppResponse into a dictionary suitable for use as a JSON request body."""
|
|
2365
|
-
body = {}
|
|
2366
|
-
return body
|
|
2367
|
-
|
|
2368
|
-
@classmethod
|
|
2369
|
-
def from_dict(cls, d: Dict[str, any]) -> StopAppResponse:
|
|
2370
|
-
"""Deserializes the StopAppResponse from a dictionary."""
|
|
2371
|
-
return cls()
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
2219
|
@dataclass
|
|
2375
2220
|
class TrafficConfig:
|
|
2376
2221
|
routes: Optional[List[Route]] = None
|
|
@@ -2388,28 +2233,6 @@ class TrafficConfig:
|
|
|
2388
2233
|
return cls(routes=_repeated_dict(d, 'routes', Route))
|
|
2389
2234
|
|
|
2390
2235
|
|
|
2391
|
-
@dataclass
|
|
2392
|
-
class UpdateAppRequest:
|
|
2393
|
-
name: str
|
|
2394
|
-
"""The name of the app. The name must contain only lowercase alphanumeric characters and hyphens
|
|
2395
|
-
and be between 2 and 30 characters long. It must be unique within the workspace."""
|
|
2396
|
-
|
|
2397
|
-
description: Optional[str] = None
|
|
2398
|
-
"""The description of the app."""
|
|
2399
|
-
|
|
2400
|
-
def as_dict(self) -> dict:
|
|
2401
|
-
"""Serializes the UpdateAppRequest into a dictionary suitable for use as a JSON request body."""
|
|
2402
|
-
body = {}
|
|
2403
|
-
if self.description is not None: body['description'] = self.description
|
|
2404
|
-
if self.name is not None: body['name'] = self.name
|
|
2405
|
-
return body
|
|
2406
|
-
|
|
2407
|
-
@classmethod
|
|
2408
|
-
def from_dict(cls, d: Dict[str, any]) -> UpdateAppRequest:
|
|
2409
|
-
"""Deserializes the UpdateAppRequest from a dictionary."""
|
|
2410
|
-
return cls(description=d.get('description', None), name=d.get('name', None))
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
2236
|
@dataclass
|
|
2414
2237
|
class V1ResponseChoiceElement:
|
|
2415
2238
|
finish_reason: Optional[str] = None
|
|
@@ -2447,307 +2270,6 @@ class V1ResponseChoiceElement:
|
|
|
2447
2270
|
text=d.get('text', None))
|
|
2448
2271
|
|
|
2449
2272
|
|
|
2450
|
-
class AppsAPI:
|
|
2451
|
-
"""Apps run directly on a customer’s Databricks instance, integrate with their data, use and extend
|
|
2452
|
-
Databricks services, and enable users to interact through single sign-on."""
|
|
2453
|
-
|
|
2454
|
-
def __init__(self, api_client):
|
|
2455
|
-
self._api = api_client
|
|
2456
|
-
|
|
2457
|
-
def wait_get_app_idle(self,
|
|
2458
|
-
name: str,
|
|
2459
|
-
timeout=timedelta(minutes=20),
|
|
2460
|
-
callback: Optional[Callable[[App], None]] = None) -> App:
|
|
2461
|
-
deadline = time.time() + timeout.total_seconds()
|
|
2462
|
-
target_states = (AppState.IDLE, )
|
|
2463
|
-
failure_states = (AppState.ERROR, )
|
|
2464
|
-
status_message = 'polling...'
|
|
2465
|
-
attempt = 1
|
|
2466
|
-
while time.time() < deadline:
|
|
2467
|
-
poll = self.get(name=name)
|
|
2468
|
-
status = poll.status.state
|
|
2469
|
-
status_message = f'current status: {status}'
|
|
2470
|
-
if poll.status:
|
|
2471
|
-
status_message = poll.status.message
|
|
2472
|
-
if status in target_states:
|
|
2473
|
-
return poll
|
|
2474
|
-
if callback:
|
|
2475
|
-
callback(poll)
|
|
2476
|
-
if status in failure_states:
|
|
2477
|
-
msg = f'failed to reach IDLE, got {status}: {status_message}'
|
|
2478
|
-
raise OperationFailed(msg)
|
|
2479
|
-
prefix = f"name={name}"
|
|
2480
|
-
sleep = attempt
|
|
2481
|
-
if sleep > 10:
|
|
2482
|
-
# sleep 10s max per attempt
|
|
2483
|
-
sleep = 10
|
|
2484
|
-
_LOG.debug(f'{prefix}: ({status}) {status_message} (sleeping ~{sleep}s)')
|
|
2485
|
-
time.sleep(sleep + random.random())
|
|
2486
|
-
attempt += 1
|
|
2487
|
-
raise TimeoutError(f'timed out after {timeout}: {status_message}')
|
|
2488
|
-
|
|
2489
|
-
def wait_get_deployment_app_succeeded(
|
|
2490
|
-
self,
|
|
2491
|
-
app_name: str,
|
|
2492
|
-
deployment_id: str,
|
|
2493
|
-
timeout=timedelta(minutes=20),
|
|
2494
|
-
callback: Optional[Callable[[AppDeployment], None]] = None) -> AppDeployment:
|
|
2495
|
-
deadline = time.time() + timeout.total_seconds()
|
|
2496
|
-
target_states = (AppDeploymentState.SUCCEEDED, )
|
|
2497
|
-
failure_states = (AppDeploymentState.FAILED, )
|
|
2498
|
-
status_message = 'polling...'
|
|
2499
|
-
attempt = 1
|
|
2500
|
-
while time.time() < deadline:
|
|
2501
|
-
poll = self.get_deployment(app_name=app_name, deployment_id=deployment_id)
|
|
2502
|
-
status = poll.status.state
|
|
2503
|
-
status_message = f'current status: {status}'
|
|
2504
|
-
if poll.status:
|
|
2505
|
-
status_message = poll.status.message
|
|
2506
|
-
if status in target_states:
|
|
2507
|
-
return poll
|
|
2508
|
-
if callback:
|
|
2509
|
-
callback(poll)
|
|
2510
|
-
if status in failure_states:
|
|
2511
|
-
msg = f'failed to reach SUCCEEDED, got {status}: {status_message}'
|
|
2512
|
-
raise OperationFailed(msg)
|
|
2513
|
-
prefix = f"app_name={app_name}, deployment_id={deployment_id}"
|
|
2514
|
-
sleep = attempt
|
|
2515
|
-
if sleep > 10:
|
|
2516
|
-
# sleep 10s max per attempt
|
|
2517
|
-
sleep = 10
|
|
2518
|
-
_LOG.debug(f'{prefix}: ({status}) {status_message} (sleeping ~{sleep}s)')
|
|
2519
|
-
time.sleep(sleep + random.random())
|
|
2520
|
-
attempt += 1
|
|
2521
|
-
raise TimeoutError(f'timed out after {timeout}: {status_message}')
|
|
2522
|
-
|
|
2523
|
-
def create(self, name: str, *, description: Optional[str] = None) -> Wait[App]:
|
|
2524
|
-
"""Create an App.
|
|
2525
|
-
|
|
2526
|
-
Creates a new app.
|
|
2527
|
-
|
|
2528
|
-
:param name: str
|
|
2529
|
-
The name of the app. The name must contain only lowercase alphanumeric characters and hyphens and be
|
|
2530
|
-
between 2 and 30 characters long. It must be unique within the workspace.
|
|
2531
|
-
:param description: str (optional)
|
|
2532
|
-
The description of the app.
|
|
2533
|
-
|
|
2534
|
-
:returns:
|
|
2535
|
-
Long-running operation waiter for :class:`App`.
|
|
2536
|
-
See :method:wait_get_app_idle for more details.
|
|
2537
|
-
"""
|
|
2538
|
-
body = {}
|
|
2539
|
-
if description is not None: body['description'] = description
|
|
2540
|
-
if name is not None: body['name'] = name
|
|
2541
|
-
headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
|
|
2542
|
-
|
|
2543
|
-
op_response = self._api.do('POST', '/api/2.0/preview/apps', body=body, headers=headers)
|
|
2544
|
-
return Wait(self.wait_get_app_idle, response=App.from_dict(op_response), name=op_response['name'])
|
|
2545
|
-
|
|
2546
|
-
def create_and_wait(self,
|
|
2547
|
-
name: str,
|
|
2548
|
-
*,
|
|
2549
|
-
description: Optional[str] = None,
|
|
2550
|
-
timeout=timedelta(minutes=20)) -> App:
|
|
2551
|
-
return self.create(description=description, name=name).result(timeout=timeout)
|
|
2552
|
-
|
|
2553
|
-
def create_deployment(self, app_name: str, source_code_path: str) -> Wait[AppDeployment]:
|
|
2554
|
-
"""Create an App Deployment.
|
|
2555
|
-
|
|
2556
|
-
Creates an app deployment for the app with the supplied name.
|
|
2557
|
-
|
|
2558
|
-
:param app_name: str
|
|
2559
|
-
The name of the app.
|
|
2560
|
-
:param source_code_path: str
|
|
2561
|
-
The source code path of the deployment.
|
|
2562
|
-
|
|
2563
|
-
:returns:
|
|
2564
|
-
Long-running operation waiter for :class:`AppDeployment`.
|
|
2565
|
-
See :method:wait_get_deployment_app_succeeded for more details.
|
|
2566
|
-
"""
|
|
2567
|
-
body = {}
|
|
2568
|
-
if source_code_path is not None: body['source_code_path'] = source_code_path
|
|
2569
|
-
headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
|
|
2570
|
-
|
|
2571
|
-
op_response = self._api.do('POST',
|
|
2572
|
-
f'/api/2.0/preview/apps/{app_name}/deployments',
|
|
2573
|
-
body=body,
|
|
2574
|
-
headers=headers)
|
|
2575
|
-
return Wait(self.wait_get_deployment_app_succeeded,
|
|
2576
|
-
response=AppDeployment.from_dict(op_response),
|
|
2577
|
-
app_name=app_name,
|
|
2578
|
-
deployment_id=op_response['deployment_id'])
|
|
2579
|
-
|
|
2580
|
-
def create_deployment_and_wait(self, app_name: str, source_code_path: str,
|
|
2581
|
-
timeout=timedelta(minutes=20)) -> AppDeployment:
|
|
2582
|
-
return self.create_deployment(app_name=app_name,
|
|
2583
|
-
source_code_path=source_code_path).result(timeout=timeout)
|
|
2584
|
-
|
|
2585
|
-
def delete(self, name: str):
|
|
2586
|
-
"""Delete an App.
|
|
2587
|
-
|
|
2588
|
-
Deletes an app.
|
|
2589
|
-
|
|
2590
|
-
:param name: str
|
|
2591
|
-
The name of the app.
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
"""
|
|
2595
|
-
|
|
2596
|
-
headers = {'Accept': 'application/json', }
|
|
2597
|
-
|
|
2598
|
-
self._api.do('DELETE', f'/api/2.0/preview/apps/{name}', headers=headers)
|
|
2599
|
-
|
|
2600
|
-
def get(self, name: str) -> App:
|
|
2601
|
-
"""Get an App.
|
|
2602
|
-
|
|
2603
|
-
Retrieves information for the app with the supplied name.
|
|
2604
|
-
|
|
2605
|
-
:param name: str
|
|
2606
|
-
The name of the app.
|
|
2607
|
-
|
|
2608
|
-
:returns: :class:`App`
|
|
2609
|
-
"""
|
|
2610
|
-
|
|
2611
|
-
headers = {'Accept': 'application/json', }
|
|
2612
|
-
|
|
2613
|
-
res = self._api.do('GET', f'/api/2.0/preview/apps/{name}', headers=headers)
|
|
2614
|
-
return App.from_dict(res)
|
|
2615
|
-
|
|
2616
|
-
def get_deployment(self, app_name: str, deployment_id: str) -> AppDeployment:
|
|
2617
|
-
"""Get an App Deployment.
|
|
2618
|
-
|
|
2619
|
-
Retrieves information for the app deployment with the supplied name and deployment id.
|
|
2620
|
-
|
|
2621
|
-
:param app_name: str
|
|
2622
|
-
The name of the app.
|
|
2623
|
-
:param deployment_id: str
|
|
2624
|
-
The unique id of the deployment.
|
|
2625
|
-
|
|
2626
|
-
:returns: :class:`AppDeployment`
|
|
2627
|
-
"""
|
|
2628
|
-
|
|
2629
|
-
headers = {'Accept': 'application/json', }
|
|
2630
|
-
|
|
2631
|
-
res = self._api.do('GET',
|
|
2632
|
-
f'/api/2.0/preview/apps/{app_name}/deployments/{deployment_id}',
|
|
2633
|
-
headers=headers)
|
|
2634
|
-
return AppDeployment.from_dict(res)
|
|
2635
|
-
|
|
2636
|
-
def get_environment(self, name: str) -> AppEnvironment:
|
|
2637
|
-
"""Get App Environment.
|
|
2638
|
-
|
|
2639
|
-
Retrieves app environment.
|
|
2640
|
-
|
|
2641
|
-
:param name: str
|
|
2642
|
-
The name of the app.
|
|
2643
|
-
|
|
2644
|
-
:returns: :class:`AppEnvironment`
|
|
2645
|
-
"""
|
|
2646
|
-
|
|
2647
|
-
headers = {'Accept': 'application/json', }
|
|
2648
|
-
|
|
2649
|
-
res = self._api.do('GET', f'/api/2.0/preview/apps/{name}/environment', headers=headers)
|
|
2650
|
-
return AppEnvironment.from_dict(res)
|
|
2651
|
-
|
|
2652
|
-
def list(self, *, page_size: Optional[int] = None, page_token: Optional[str] = None) -> Iterator[App]:
|
|
2653
|
-
"""List Apps.
|
|
2654
|
-
|
|
2655
|
-
Lists all apps in the workspace.
|
|
2656
|
-
|
|
2657
|
-
:param page_size: int (optional)
|
|
2658
|
-
Upper bound for items returned.
|
|
2659
|
-
:param page_token: str (optional)
|
|
2660
|
-
Pagination token to go to the next page of apps. Requests first page if absent.
|
|
2661
|
-
|
|
2662
|
-
:returns: Iterator over :class:`App`
|
|
2663
|
-
"""
|
|
2664
|
-
|
|
2665
|
-
query = {}
|
|
2666
|
-
if page_size is not None: query['page_size'] = page_size
|
|
2667
|
-
if page_token is not None: query['page_token'] = page_token
|
|
2668
|
-
headers = {'Accept': 'application/json', }
|
|
2669
|
-
|
|
2670
|
-
while True:
|
|
2671
|
-
json = self._api.do('GET', '/api/2.0/preview/apps', query=query, headers=headers)
|
|
2672
|
-
if 'apps' in json:
|
|
2673
|
-
for v in json['apps']:
|
|
2674
|
-
yield App.from_dict(v)
|
|
2675
|
-
if 'next_page_token' not in json or not json['next_page_token']:
|
|
2676
|
-
return
|
|
2677
|
-
query['page_token'] = json['next_page_token']
|
|
2678
|
-
|
|
2679
|
-
def list_deployments(self,
|
|
2680
|
-
app_name: str,
|
|
2681
|
-
*,
|
|
2682
|
-
page_size: Optional[int] = None,
|
|
2683
|
-
page_token: Optional[str] = None) -> Iterator[AppDeployment]:
|
|
2684
|
-
"""List App Deployments.
|
|
2685
|
-
|
|
2686
|
-
Lists all app deployments for the app with the supplied name.
|
|
2687
|
-
|
|
2688
|
-
:param app_name: str
|
|
2689
|
-
The name of the app.
|
|
2690
|
-
:param page_size: int (optional)
|
|
2691
|
-
Upper bound for items returned.
|
|
2692
|
-
:param page_token: str (optional)
|
|
2693
|
-
Pagination token to go to the next page of apps. Requests first page if absent.
|
|
2694
|
-
|
|
2695
|
-
:returns: Iterator over :class:`AppDeployment`
|
|
2696
|
-
"""
|
|
2697
|
-
|
|
2698
|
-
query = {}
|
|
2699
|
-
if page_size is not None: query['page_size'] = page_size
|
|
2700
|
-
if page_token is not None: query['page_token'] = page_token
|
|
2701
|
-
headers = {'Accept': 'application/json', }
|
|
2702
|
-
|
|
2703
|
-
while True:
|
|
2704
|
-
json = self._api.do('GET',
|
|
2705
|
-
f'/api/2.0/preview/apps/{app_name}/deployments',
|
|
2706
|
-
query=query,
|
|
2707
|
-
headers=headers)
|
|
2708
|
-
if 'app_deployments' in json:
|
|
2709
|
-
for v in json['app_deployments']:
|
|
2710
|
-
yield AppDeployment.from_dict(v)
|
|
2711
|
-
if 'next_page_token' not in json or not json['next_page_token']:
|
|
2712
|
-
return
|
|
2713
|
-
query['page_token'] = json['next_page_token']
|
|
2714
|
-
|
|
2715
|
-
def stop(self, name: str):
|
|
2716
|
-
"""Stop an App.
|
|
2717
|
-
|
|
2718
|
-
Stops the active deployment of the app in the workspace.
|
|
2719
|
-
|
|
2720
|
-
:param name: str
|
|
2721
|
-
The name of the app.
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
"""
|
|
2725
|
-
|
|
2726
|
-
headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
|
|
2727
|
-
|
|
2728
|
-
self._api.do('POST', f'/api/2.0/preview/apps/{name}/stop', headers=headers)
|
|
2729
|
-
|
|
2730
|
-
def update(self, name: str, *, description: Optional[str] = None) -> App:
|
|
2731
|
-
"""Update an App.
|
|
2732
|
-
|
|
2733
|
-
Updates the app with the supplied name.
|
|
2734
|
-
|
|
2735
|
-
:param name: str
|
|
2736
|
-
The name of the app. The name must contain only lowercase alphanumeric characters and hyphens and be
|
|
2737
|
-
between 2 and 30 characters long. It must be unique within the workspace.
|
|
2738
|
-
:param description: str (optional)
|
|
2739
|
-
The description of the app.
|
|
2740
|
-
|
|
2741
|
-
:returns: :class:`App`
|
|
2742
|
-
"""
|
|
2743
|
-
body = {}
|
|
2744
|
-
if description is not None: body['description'] = description
|
|
2745
|
-
headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
|
|
2746
|
-
|
|
2747
|
-
res = self._api.do('PATCH', f'/api/2.0/preview/apps/{name}', body=body, headers=headers)
|
|
2748
|
-
return App.from_dict(res)
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
2273
|
class ServingEndpointsAPI:
|
|
2752
2274
|
"""The Serving Endpoints API allows you to create, update, and delete model serving endpoints.
|
|
2753
2275
|
|
|
@@ -2770,7 +2292,8 @@ class ServingEndpointsAPI:
|
|
|
2770
2292
|
callback: Optional[Callable[[ServingEndpointDetailed], None]] = None) -> ServingEndpointDetailed:
|
|
2771
2293
|
deadline = time.time() + timeout.total_seconds()
|
|
2772
2294
|
target_states = (EndpointStateConfigUpdate.NOT_UPDATING, )
|
|
2773
|
-
failure_states = (EndpointStateConfigUpdate.UPDATE_FAILED,
|
|
2295
|
+
failure_states = (EndpointStateConfigUpdate.UPDATE_FAILED, EndpointStateConfigUpdate.UPDATE_CANCELED,
|
|
2296
|
+
)
|
|
2774
2297
|
status_message = 'polling...'
|
|
2775
2298
|
attempt = 1
|
|
2776
2299
|
while time.time() < deadline:
|
|
@@ -3250,3 +2773,118 @@ class ServingEndpointsAPI:
|
|
|
3250
2773
|
body=body,
|
|
3251
2774
|
headers=headers)
|
|
3252
2775
|
return ServingEndpointPermissions.from_dict(res)
|
|
2776
|
+
|
|
2777
|
+
|
|
2778
|
+
class ServingEndpointsDataPlaneAPI:
|
|
2779
|
+
"""Serving endpoints DataPlane provides a set of operations to interact with data plane endpoints for Serving
|
|
2780
|
+
endpoints service."""
|
|
2781
|
+
|
|
2782
|
+
def __init__(self, api_client, control_plane):
|
|
2783
|
+
self._api = api_client
|
|
2784
|
+
self._control_plane = control_plane
|
|
2785
|
+
self._data_plane_service = DataPlaneService()
|
|
2786
|
+
|
|
2787
|
+
def query(self,
|
|
2788
|
+
name: str,
|
|
2789
|
+
*,
|
|
2790
|
+
dataframe_records: Optional[List[Any]] = None,
|
|
2791
|
+
dataframe_split: Optional[DataframeSplitInput] = None,
|
|
2792
|
+
extra_params: Optional[Dict[str, str]] = None,
|
|
2793
|
+
input: Optional[Any] = None,
|
|
2794
|
+
inputs: Optional[Any] = None,
|
|
2795
|
+
instances: Optional[List[Any]] = None,
|
|
2796
|
+
max_tokens: Optional[int] = None,
|
|
2797
|
+
messages: Optional[List[ChatMessage]] = None,
|
|
2798
|
+
n: Optional[int] = None,
|
|
2799
|
+
prompt: Optional[Any] = None,
|
|
2800
|
+
stop: Optional[List[str]] = None,
|
|
2801
|
+
stream: Optional[bool] = None,
|
|
2802
|
+
temperature: Optional[float] = None) -> QueryEndpointResponse:
|
|
2803
|
+
"""Query a serving endpoint.
|
|
2804
|
+
|
|
2805
|
+
:param name: str
|
|
2806
|
+
The name of the serving endpoint. This field is required.
|
|
2807
|
+
:param dataframe_records: List[Any] (optional)
|
|
2808
|
+
Pandas Dataframe input in the records orientation.
|
|
2809
|
+
:param dataframe_split: :class:`DataframeSplitInput` (optional)
|
|
2810
|
+
Pandas Dataframe input in the split orientation.
|
|
2811
|
+
:param extra_params: Dict[str,str] (optional)
|
|
2812
|
+
The extra parameters field used ONLY for __completions, chat,__ and __embeddings external &
|
|
2813
|
+
foundation model__ serving endpoints. This is a map of strings and should only be used with other
|
|
2814
|
+
external/foundation model query fields.
|
|
2815
|
+
:param input: Any (optional)
|
|
2816
|
+
The input string (or array of strings) field used ONLY for __embeddings external & foundation
|
|
2817
|
+
model__ serving endpoints and is the only field (along with extra_params if needed) used by
|
|
2818
|
+
embeddings queries.
|
|
2819
|
+
:param inputs: Any (optional)
|
|
2820
|
+
Tensor-based input in columnar format.
|
|
2821
|
+
:param instances: List[Any] (optional)
|
|
2822
|
+
Tensor-based input in row format.
|
|
2823
|
+
:param max_tokens: int (optional)
|
|
2824
|
+
The max tokens field used ONLY for __completions__ and __chat external & foundation model__ serving
|
|
2825
|
+
endpoints. This is an integer and should only be used with other chat/completions query fields.
|
|
2826
|
+
:param messages: List[:class:`ChatMessage`] (optional)
|
|
2827
|
+
The messages field used ONLY for __chat external & foundation model__ serving endpoints. This is a
|
|
2828
|
+
map of strings and should only be used with other chat query fields.
|
|
2829
|
+
:param n: int (optional)
|
|
2830
|
+
The n (number of candidates) field used ONLY for __completions__ and __chat external & foundation
|
|
2831
|
+
model__ serving endpoints. This is an integer between 1 and 5 with a default of 1 and should only be
|
|
2832
|
+
used with other chat/completions query fields.
|
|
2833
|
+
:param prompt: Any (optional)
|
|
2834
|
+
The prompt string (or array of strings) field used ONLY for __completions external & foundation
|
|
2835
|
+
model__ serving endpoints and should only be used with other completions query fields.
|
|
2836
|
+
:param stop: List[str] (optional)
|
|
2837
|
+
The stop sequences field used ONLY for __completions__ and __chat external & foundation model__
|
|
2838
|
+
serving endpoints. This is a list of strings and should only be used with other chat/completions
|
|
2839
|
+
query fields.
|
|
2840
|
+
:param stream: bool (optional)
|
|
2841
|
+
The stream field used ONLY for __completions__ and __chat external & foundation model__ serving
|
|
2842
|
+
endpoints. This is a boolean defaulting to false and should only be used with other chat/completions
|
|
2843
|
+
query fields.
|
|
2844
|
+
:param temperature: float (optional)
|
|
2845
|
+
The temperature field used ONLY for __completions__ and __chat external & foundation model__ serving
|
|
2846
|
+
endpoints. This is a float between 0.0 and 2.0 with a default of 1.0 and should only be used with
|
|
2847
|
+
other chat/completions query fields.
|
|
2848
|
+
|
|
2849
|
+
:returns: :class:`QueryEndpointResponse`
|
|
2850
|
+
"""
|
|
2851
|
+
body = {}
|
|
2852
|
+
if dataframe_records is not None: body['dataframe_records'] = [v for v in dataframe_records]
|
|
2853
|
+
if dataframe_split is not None: body['dataframe_split'] = dataframe_split.as_dict()
|
|
2854
|
+
if extra_params is not None: body['extra_params'] = extra_params
|
|
2855
|
+
if input is not None: body['input'] = input
|
|
2856
|
+
if inputs is not None: body['inputs'] = inputs
|
|
2857
|
+
if instances is not None: body['instances'] = [v for v in instances]
|
|
2858
|
+
if max_tokens is not None: body['max_tokens'] = max_tokens
|
|
2859
|
+
if messages is not None: body['messages'] = [v.as_dict() for v in messages]
|
|
2860
|
+
if n is not None: body['n'] = n
|
|
2861
|
+
if prompt is not None: body['prompt'] = prompt
|
|
2862
|
+
if stop is not None: body['stop'] = [v for v in stop]
|
|
2863
|
+
if stream is not None: body['stream'] = stream
|
|
2864
|
+
if temperature is not None: body['temperature'] = temperature
|
|
2865
|
+
|
|
2866
|
+
def info_getter():
|
|
2867
|
+
response = self._control_plane.get(name=name, )
|
|
2868
|
+
if response.data_plane_info is None:
|
|
2869
|
+
raise Exception("Resource does not support direct Data Plane access")
|
|
2870
|
+
return response.data_plane_info.query_info
|
|
2871
|
+
|
|
2872
|
+
get_params = [name, ]
|
|
2873
|
+
data_plane_details = self._data_plane_service.get_data_plane_details('query', get_params, info_getter,
|
|
2874
|
+
self._api.get_oauth_token)
|
|
2875
|
+
token = data_plane_details.token
|
|
2876
|
+
|
|
2877
|
+
def auth(r: requests.PreparedRequest) -> requests.PreparedRequest:
|
|
2878
|
+
authorization = f"{token.token_type} {token.access_token}"
|
|
2879
|
+
r.headers["Authorization"] = authorization
|
|
2880
|
+
return r
|
|
2881
|
+
|
|
2882
|
+
headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
|
|
2883
|
+
response_headers = ['served-model-name', ]
|
|
2884
|
+
res = self._api.do('POST',
|
|
2885
|
+
url=data_plane_details.endpoint_url,
|
|
2886
|
+
body=body,
|
|
2887
|
+
headers=headers,
|
|
2888
|
+
response_headers=response_headers,
|
|
2889
|
+
auth=auth)
|
|
2890
|
+
return QueryEndpointResponse.from_dict(res)
|