Skip to content

Commit cc0e2ec

Browse files
Update SDK API to 6700bbe74746844cbb713c810c90e9187056b894 (#1199)
This PR updates the SDK to the latest API changes. NO_CHANGELOG=true Co-authored-by: databricks-ci-ghec-1[bot] <184311507+databricks-ci-ghec-1[bot]@users.noreply.github.com>
1 parent c3b7b44 commit cc0e2ec

File tree

7 files changed

+39
-36
lines changed

7 files changed

+39
-36
lines changed

.codegen/_openapi_sha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e16060430295515f0c147e5252a3fee3c19fde9f
1+
6700bbe74746844cbb713c810c90e9187056b894

docs/account/iam/workspace_assignment.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
4444
a = AccountClient()
4545
46-
workspace_id = os.environ["TEST_WORKSPACE_ID"]
46+
workspace_id = os.environ["DUMMY_WORKSPACE_ID"]
4747
48-
all = a.workspace_assignment.list(list=workspace_id)
48+
all = a.workspace_assignment.list(workspace_id=workspace_id)
4949
5050
Get the permission assignments for the specified Databricks account and Databricks workspace.
5151

@@ -74,9 +74,9 @@
7474
7575
spn_id = spn.id
7676
77-
workspace_id = os.environ["DUMMY_WORKSPACE_ID"]
77+
workspace_id = os.environ["TEST_WORKSPACE_ID"]
7878
79-
_ = a.workspace_assignment.update(
79+
a.workspace_assignment.update(
8080
workspace_id=workspace_id,
8181
principal_id=spn_id,
8282
permissions=[iam.WorkspacePermission.USER],

docs/workspace/catalog/catalogs.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
2525
w = WorkspaceClient()
2626
27-
created = w.catalogs.create(name=f"sdk-{time.time_ns()}")
27+
created_catalog = w.catalogs.create(name=f"sdk-{time.time_ns()}")
2828
2929
# cleanup
30-
w.catalogs.delete(name=created.name, force=True)
30+
w.catalogs.delete(name=created_catalog.name, force=True)
3131
3232
Creates a new catalog instance in the parent metastore if the caller is a metastore admin or has the
3333
**CREATE_CATALOG** privilege.

docs/workspace/catalog/external_locations.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,22 @@
3030
3131
w = WorkspaceClient()
3232
33-
credential = w.storage_credentials.create(
33+
storage_credential = w.storage_credentials.create(
3434
name=f"sdk-{time.time_ns()}",
3535
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
36+
comment="created via SDK",
3637
)
3738
38-
created = w.external_locations.create(
39+
external_location = w.external_locations.create(
3940
name=f"sdk-{time.time_ns()}",
40-
credential_name=credential.name,
41-
url="s3://%s/%s" % (os.environ["TEST_BUCKET"], f"sdk-{time.time_ns()}"),
41+
credential_name=storage_credential.name,
42+
comment="created via SDK",
43+
url="s3://" + os.environ["TEST_BUCKET"] + "/" + f"sdk-{time.time_ns()}",
4244
)
4345
4446
# cleanup
45-
w.storage_credentials.delete(name=credential.name)
46-
w.external_locations.delete(name=created.name)
47+
w.storage_credentials.delete(name=storage_credential.name)
48+
w.external_locations.delete(name=external_location.name)
4749
4850
Creates a new external location entry in the metastore. The caller must be a metastore admin or have
4951
the **CREATE_EXTERNAL_LOCATION** privilege on both the metastore and the associated storage

docs/workspace/catalog/storage_credentials.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@
3030
3131
w = WorkspaceClient()
3232
33-
credential = w.storage_credentials.create(
33+
storage_credential = w.storage_credentials.create(
3434
name=f"sdk-{time.time_ns()}",
3535
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
36+
comment="created via SDK",
3637
)
3738
3839
# cleanup
39-
w.storage_credentials.delete(name=credential.name)
40+
w.storage_credentials.delete(name=storage_credential.name)
4041
4142
Creates a new storage credential.
4243

@@ -98,13 +99,13 @@
9899
99100
created = w.storage_credentials.create(
100101
name=f"sdk-{time.time_ns()}",
101-
aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
102+
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
102103
)
103104
104-
by_name = w.storage_credentials.get(get=created.name)
105+
by_name = w.storage_credentials.get(name=created.name)
105106
106107
# cleanup
107-
w.storage_credentials.delete(delete=created.name)
108+
w.storage_credentials.delete(name=created.name)
108109
109110
Gets a storage credential from the metastore. The caller must be a metastore admin, the owner of the
110111
storage credential, or have some permission on the storage credential.
@@ -123,10 +124,11 @@
123124
.. code-block::
124125
125126
from databricks.sdk import WorkspaceClient
127+
from databricks.sdk.service import catalog
126128
127129
w = WorkspaceClient()
128130
129-
all = w.storage_credentials.list()
131+
all = w.storage_credentials.list(catalog.ListStorageCredentialsRequest())
130132
131133
Gets an array of storage credentials (as __StorageCredentialInfo__ objects). The array is limited to
132134
only those storage credentials the caller has permission to access. If the caller is a metastore

docs/workspace/ml/model_registry.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
9191
w = WorkspaceClient()
9292
93-
model = w.model_registry.create_model(name=f"sdk-{time.time_ns()}")
93+
created = w.model_registry.create_model(name=f"sdk-{time.time_ns()}")
9494
9595
Creates a new registered model with the name specified in the request body. Throws
9696
`RESOURCE_ALREADY_EXISTS` if a registered model with the given name exists.
@@ -120,7 +120,7 @@
120120
121121
model = w.model_registry.create_model(name=f"sdk-{time.time_ns()}")
122122
123-
created = w.model_registry.create_model_version(name=model.registered_model.name, source="dbfs:/tmp")
123+
mv = w.model_registry.create_model_version(name=model.registered_model.name, source="dbfs:/tmp")
124124
125125
Creates a model version.
126126

@@ -734,14 +734,13 @@
734734
735735
w = WorkspaceClient()
736736
737-
model = w.model_registry.create_model(name=f"sdk-{time.time_ns()}")
737+
created = w.model_registry.create_model(name=f"sdk-{time.time_ns()}")
738738
739-
created = w.model_registry.create_model_version(name=model.registered_model.name, source="dbfs:/tmp")
739+
model = w.model_registry.get_model(name=created.registered_model.name)
740740
741-
w.model_registry.update_model_version(
741+
w.model_registry.update_model(
742+
name=model.registered_model_databricks.name,
742743
description=f"sdk-{time.time_ns()}",
743-
name=created.model_version.name,
744-
version=created.model_version.version,
745744
)
746745
747746
Updates a registered model.

docs/workspace/workspace/workspace.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@
148148
149149
w = WorkspaceClient()
150150
151-
notebook_path = f"/Users/{w.current_user.me().user_name}/sdk-{time.time_ns()}"
151+
notebook = f"/Users/{w.current_user.me().user_name}/sdk-{time.time_ns()}"
152152
153-
obj = w.workspace.get_status(path=notebook_path)
153+
get_status_response = w.workspace.get_status(path=notebook)
154154
155155
Gets the status of an object or a directory. If `path` does not exist, this call returns an error
156156
`RESOURCE_DOES_NOT_EXIST`.
@@ -180,14 +180,12 @@
180180
181181
w.workspace.import_(
182182
path=notebook_path,
183-
overwrite=true_,
183+
overwrite=True,
184184
format=workspace.ImportFormat.SOURCE,
185185
language=workspace.Language.PYTHON,
186186
content=base64.b64encode(
187187
(
188-
"""import time
189-
time.sleep(10)
190-
dbutils.notebook.exit('hello')
188+
"""print(1)
191189
"""
192190
).encode()
193191
).decode(),
@@ -234,14 +232,16 @@
234232

235233
.. code-block::
236234
235+
import os
236+
import time
237+
237238
from databricks.sdk import WorkspaceClient
238239
239240
w = WorkspaceClient()
240241
241-
names = []
242-
for i in w.workspace.list(f"/Users/{w.current_user.me().user_name}", recursive=True):
243-
names.append(i.path)
244-
assert len(names) > 0
242+
notebook = f"/Users/{w.current_user.me().user_name}/sdk-{time.time_ns()}"
243+
244+
objects = w.workspace.list(path=os.path.dirname(notebook))
245245
246246
List workspace objects
247247

0 commit comments

Comments
 (0)