Skip to content

Commit 1ea4956

Browse files
Update SDK API to b7f0bdef8060a7daec78568f87fae44773f598c5 (#1181)
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 80d47e5 commit 1ea4956

File tree

13 files changed

+52
-64
lines changed

13 files changed

+52
-64
lines changed

.codegen/_openapi_sha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b5283a925ecf8929263b63f41b182246745d81a0
1+
b7f0bdef8060a7daec78568f87fae44773f598c5

NEXT_CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@
3838
* [Breaking] Remove `branch_logical_size_limit_bytes`, `compute_last_active_time`, `default_endpoint_settings`, `display_name`, `effective_default_endpoint_settings`, `effective_display_name`, `effective_history_retention_duration`, `effective_pg_version`, `effective_settings`, `history_retention_duration`, `pg_version`, `settings` and `synthetic_storage_size_bytes` fields for `databricks.sdk.service.postgres.Project`.
3939
* Add `command` and `env_vars` fields for `databricks.sdk.service.apps.AppDeployment`.
4040
* Add `full_name` and `securable_type` fields for `databricks.sdk.service.catalog.AccessRequestDestinations`.
41-
* [Breaking] Change `delete_kafka_config()` method for [w.feature_engineering](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/ml/feature_engineering.html) workspace-level service . Method path has changed.
41+
* [Breaking] Change `delete_kafka_config()` method for [w.feature_engineering](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/ml/feature_engineering.html) workspace-level service . Method path has changed.

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_catalog = w.catalogs.create(name=f"sdk-{time.time_ns()}")
27+
created = w.catalogs.create(name=f"sdk-{time.time_ns()}")
2828
2929
# cleanup
30-
w.catalogs.delete(name=created_catalog.name, force=True)
30+
w.catalogs.delete(name=created.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: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,20 @@
3030
3131
w = WorkspaceClient()
3232
33-
storage_credential = w.storage_credentials.create(
33+
credential = w.storage_credentials.create(
3434
name=f"sdk-{time.time_ns()}",
35-
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
36-
comment="created via SDK",
35+
aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
3736
)
3837
39-
external_location = w.external_locations.create(
38+
created = w.external_locations.create(
4039
name=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()}",
40+
credential_name=credential.name,
41+
url=f's3://{os.environ["TEST_BUCKET"]}/sdk-{time.time_ns()}',
4442
)
4543
4644
# cleanup
47-
w.storage_credentials.delete(name=storage_credential.name)
48-
w.external_locations.delete(name=external_location.name)
45+
w.storage_credentials.delete(delete=credential.name)
46+
w.external_locations.delete(delete=created.name)
4947
5048
Creates a new external location entry in the metastore. The caller must be a metastore admin or have
5149
the **CREATE_EXTERNAL_LOCATION** privilege on both the metastore and the associated storage
@@ -142,10 +140,11 @@
142140
.. code-block::
143141
144142
from databricks.sdk import WorkspaceClient
143+
from databricks.sdk.service import catalog
145144
146145
w = WorkspaceClient()
147146
148-
all = w.external_locations.list()
147+
all = w.external_locations.list(catalog.ListExternalLocationsRequest())
149148
150149
Gets an array of external locations (__ExternalLocationInfo__ objects) from the metastore. The caller
151150
must be a metastore admin, the owner of the external location, or a user that has some privilege on
@@ -192,24 +191,24 @@
192191
193192
credential = w.storage_credentials.create(
194193
name=f"sdk-{time.time_ns()}",
195-
aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
194+
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
196195
)
197196
198197
created = w.external_locations.create(
199198
name=f"sdk-{time.time_ns()}",
200199
credential_name=credential.name,
201-
url=f's3://{os.environ["TEST_BUCKET"]}/sdk-{time.time_ns()}',
200+
url="s3://%s/%s" % (os.environ["TEST_BUCKET"], f"sdk-{time.time_ns()}"),
202201
)
203202
204203
_ = w.external_locations.update(
205204
name=created.name,
206205
credential_name=credential.name,
207-
url=f's3://{os.environ["TEST_BUCKET"]}/sdk-{time.time_ns()}',
206+
url="s3://%s/%s" % (os.environ["TEST_BUCKET"], f"sdk-{time.time_ns()}"),
208207
)
209208
210209
# cleanup
211-
w.storage_credentials.delete(delete=credential.name)
212-
w.external_locations.delete(delete=created.name)
210+
w.storage_credentials.delete(name=credential.name)
211+
w.external_locations.delete(name=created.name)
213212
214213
Updates an external location in the metastore. The caller must be the owner of the external location,
215214
or be a metastore admin. In the second case, the admin can only update the name of the external

docs/workspace/catalog/storage_credentials.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
3333
created = w.storage_credentials.create(
3434
name=f"sdk-{time.time_ns()}",
35-
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
35+
aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
3636
)
3737
3838
# cleanup
39-
w.storage_credentials.delete(name=created.name)
39+
w.storage_credentials.delete(delete=created.name)
4040
4141
Creates a new storage credential.
4242

@@ -98,13 +98,13 @@
9898
9999
created = w.storage_credentials.create(
100100
name=f"sdk-{time.time_ns()}",
101-
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
101+
aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
102102
)
103103
104-
by_name = w.storage_credentials.get(name=created.name)
104+
by_name = w.storage_credentials.get(get=created.name)
105105
106106
# cleanup
107-
w.storage_credentials.delete(name=created.name)
107+
w.storage_credentials.delete(delete=created.name)
108108
109109
Gets a storage credential from the metastore. The caller must be a metastore admin, the owner of the
110110
storage credential, or have some permission on the storage credential.
@@ -172,17 +172,17 @@
172172
173173
created = w.storage_credentials.create(
174174
name=f"sdk-{time.time_ns()}",
175-
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
175+
aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
176176
)
177177
178178
_ = w.storage_credentials.update(
179179
name=created.name,
180180
comment=f"sdk-{time.time_ns()}",
181-
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
181+
aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
182182
)
183183
184184
# cleanup
185-
w.storage_credentials.delete(name=created.name)
185+
w.storage_credentials.delete(delete=created.name)
186186
187187
Updates a storage credential on the metastore.
188188

docs/workspace/catalog/tables.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
157157
created_schema = w.schemas.create(name=f"sdk-{time.time_ns()}", catalog_name=created_catalog.name)
158158
159-
summaries = w.tables.list_summaries(catalog_name=created_catalog.name, schema_name_pattern=created_schema.name)
159+
all_tables = w.tables.list(catalog_name=created_catalog.name, schema_name=created_schema.name)
160160
161161
# cleanup
162162
w.schemas.delete(full_name=created_schema.full_name)

docs/workspace/iam/current_user.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
1818
w = WorkspaceClient()
1919
20-
me2 = w.current_user.me()
20+
me = w.current_user.me()
2121
2222
Get details about the current method caller's identity.
2323

docs/workspace/iam/permissions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
4545
obj = w.workspace.get_status(path=notebook_path)
4646
47-
_ = w.permissions.get(request_object_type="notebooks", request_object_id="%d" % (obj.object_id))
47+
levels = w.permissions.get_permission_levels(request_object_type="notebooks", request_object_id="%d" % (obj.object_id))
4848
4949
Gets the permissions of an object. Objects can inherit permissions from their parent objects or root
5050
object.

docs/workspace/jobs/jobs.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,21 +359,23 @@
359359
w.clusters.ensure_cluster_is_running(os.environ["DATABRICKS_CLUSTER_ID"]) and os.environ["DATABRICKS_CLUSTER_ID"]
360360
)
361361
362-
run = w.jobs.submit(
363-
run_name=f"sdk-{time.time_ns()}",
362+
created_job = w.jobs.create(
363+
name=f"sdk-{time.time_ns()}",
364364
tasks=[
365-
jobs.SubmitTask(
365+
jobs.Task(
366+
description="test",
366367
existing_cluster_id=cluster_id,
367368
notebook_task=jobs.NotebookTask(notebook_path=notebook_path),
368-
task_key=f"sdk-{time.time_ns()}",
369+
task_key="test",
370+
timeout_seconds=0,
369371
)
370372
],
371-
).result()
373+
)
372374
373-
output = w.jobs.get_run_output(run_id=run.tasks[0].run_id)
375+
by_id = w.jobs.get(job_id=created_job.job_id)
374376
375377
# cleanup
376-
w.jobs.delete_run(run_id=run.run_id)
378+
w.jobs.delete(job_id=created_job.job_id)
377379
378380
Get a single job.
379381

docs/workspace/ml/model_registry.rst

Lines changed: 1 addition & 1 deletion
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.

0 commit comments

Comments
 (0)