Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen/_openapi_sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
805d88b51faa37301c51d1848da2db5a2e6ed921
55d22d7e7879e6be815cfe8e3e4cf7130f822c94
4 changes: 3 additions & 1 deletion NEXT_CHANGELOG.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@
* Add `facet_column_count` and `facet_columns` fields for `databricks.sdk.service.vectorsearch.ResultManifest`.
* Add `dangerously_force_discard_all` field for `databricks.sdk.service.workspace.UpdateRepoRequest`.
* [Breaking] Remove `databricks.sdk.service.bundle` package.
* [Breaking] Remove [w.bundle](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/bundle/bundle.html) workspace-level service.
* [Breaking] Remove [w.bundle](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/bundle/bundle.html) workspace-level service.
* Add `accelerated_sync` field for `databricks.sdk.service.database.SyncedTableSpec`.
* Add `accelerated_sync` field for `databricks.sdk.service.postgres.SyncedTableSyncedTableSpec`.
9 changes: 9 additions & 0 deletions databricks/sdk/service/database.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions databricks/sdk/service/postgres.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/workspace/catalog/catalogs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

w = WorkspaceClient()

new_catalog = w.catalogs.create(name=f"sdk-{time.time_ns()}")
created_catalog = w.catalogs.create(name=f"sdk-{time.time_ns()}")

# cleanup
w.catalogs.delete(name=new_catalog.name, force=True)
w.catalogs.delete(name=created_catalog.name, force=True)

Creates a new catalog instance in the parent metastore if the caller is a metastore admin or has the
**CREATE_CATALOG** privilege.
Expand Down
20 changes: 10 additions & 10 deletions docs/workspace/catalog/external_locations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,20 @@

credential = w.storage_credentials.create(
name=f"sdk-{time.time_ns()}",
aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
)

created = w.external_locations.create(
name=f"sdk-{time.time_ns()}",
credential_name=credential.name,
url=f's3://{os.environ["TEST_BUCKET"]}/sdk-{time.time_ns()}',
url="s3://%s/%s" % (os.environ["TEST_BUCKET"], f"sdk-{time.time_ns()}"),
)

_ = w.external_locations.get(get=created.name)
_ = w.external_locations.get(name=created.name)

# cleanup
w.storage_credentials.delete(delete=credential.name)
w.external_locations.delete(delete=created.name)
w.storage_credentials.delete(name=credential.name)
w.external_locations.delete(name=created.name)

Gets an external location from the metastore. The caller must be either a metastore admin, the owner
of the external location, or a user that has some privilege on the external location.
Expand Down Expand Up @@ -200,24 +200,24 @@

credential = w.storage_credentials.create(
name=f"sdk-{time.time_ns()}",
aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
)

created = w.external_locations.create(
name=f"sdk-{time.time_ns()}",
credential_name=credential.name,
url=f's3://{os.environ["TEST_BUCKET"]}/sdk-{time.time_ns()}',
url="s3://%s/%s" % (os.environ["TEST_BUCKET"], f"sdk-{time.time_ns()}"),
)

_ = w.external_locations.update(
name=created.name,
credential_name=credential.name,
url=f's3://{os.environ["TEST_BUCKET"]}/sdk-{time.time_ns()}',
url="s3://%s/%s" % (os.environ["TEST_BUCKET"], f"sdk-{time.time_ns()}"),
)

# cleanup
w.storage_credentials.delete(delete=credential.name)
w.external_locations.delete(delete=created.name)
w.storage_credentials.delete(name=credential.name)
w.external_locations.delete(name=created.name)

Updates an external location in the metastore. The caller must be the owner of the external location,
or be a metastore admin. In the second case, the admin can only update the name of the external
Expand Down
8 changes: 4 additions & 4 deletions docs/workspace/catalog/schemas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

w = WorkspaceClient()

new_catalog = w.catalogs.create(name=f"sdk-{time.time_ns()}")
created_catalog = w.catalogs.create(name=f"sdk-{time.time_ns()}")

created = w.schemas.create(name=f"sdk-{time.time_ns()}", catalog_name=new_catalog.name)
created_schema = w.schemas.create(name=f"sdk-{time.time_ns()}", catalog_name=created_catalog.name)

# cleanup
w.catalogs.delete(name=new_catalog.name, force=True)
w.schemas.delete(full_name=created.full_name)
w.catalogs.delete(name=created_catalog.name, force=True)
w.schemas.delete(full_name=created_schema.full_name)

Creates a new schema for catalog in the Metastore. The caller must be a metastore admin, or have the
**CREATE_SCHEMA** privilege in the parent catalog.
Expand Down
14 changes: 8 additions & 6 deletions docs/workspace/catalog/storage_credentials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@

w = WorkspaceClient()

created = w.storage_credentials.create(
storage_credential = w.storage_credentials.create(
name=f"sdk-{time.time_ns()}",
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
comment="created via SDK",
)

# cleanup
w.storage_credentials.delete(name=created.name)
w.storage_credentials.delete(name=storage_credential.name)

Creates a new storage credential.

Expand Down Expand Up @@ -98,13 +99,13 @@

created = w.storage_credentials.create(
name=f"sdk-{time.time_ns()}",
aws_iam_role=catalog.AwsIamRole(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
aws_iam_role=catalog.AwsIamRoleRequest(role_arn=os.environ["TEST_METASTORE_DATA_ACCESS_ARN"]),
)

by_name = w.storage_credentials.get(get=created.name)
by_name = w.storage_credentials.get(name=created.name)

# cleanup
w.storage_credentials.delete(delete=created.name)
w.storage_credentials.delete(name=created.name)

Gets a storage credential from the metastore. The caller must be a metastore admin, the owner of the
storage credential, or have some permission on the storage credential.
Expand All @@ -123,10 +124,11 @@
.. code-block::

from databricks.sdk import WorkspaceClient
from databricks.sdk.service import catalog

w = WorkspaceClient()

all = w.storage_credentials.list()
all = w.storage_credentials.list(catalog.ListStorageCredentialsRequest())

Gets an array of storage credentials (as __StorageCredentialInfo__ objects). The array is limited to
only those storage credentials the caller has permission to access. If the caller is a metastore
Expand Down
2 changes: 1 addition & 1 deletion docs/workspace/iam/permissions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

obj = w.workspace.get_status(path=notebook_path)

_ = w.permissions.get(request_object_type="notebooks", request_object_id="%d" % (obj.object_id))
levels = w.permissions.get_permission_levels(request_object_type="notebooks", request_object_id="%d" % (obj.object_id))

Gets the permissions of an object. Objects can inherit permissions from their parent objects or root
object.
Expand Down
15 changes: 8 additions & 7 deletions docs/workspace/ml/model_registry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@

w = WorkspaceClient()

created = w.model_registry.create_model(name=f"sdk-{time.time_ns()}")
model = w.model_registry.create_model(name=f"sdk-{time.time_ns()}")

created = w.model_registry.create_model_version(name=model.registered_model.name, source="dbfs:/tmp")

Creates a new registered model with the name specified in the request body. Throws
`RESOURCE_ALREADY_EXISTS` if a registered model with the given name exists.
Expand Down Expand Up @@ -120,7 +122,7 @@

model = w.model_registry.create_model(name=f"sdk-{time.time_ns()}")

mv = w.model_registry.create_model_version(name=model.registered_model.name, source="dbfs:/tmp")
created = w.model_registry.create_model_version(name=model.registered_model.name, source="dbfs:/tmp")

Creates a model version.

Expand Down Expand Up @@ -734,14 +736,13 @@

w = WorkspaceClient()

model = w.model_registry.create_model(name=f"sdk-{time.time_ns()}")
created = w.model_registry.create_model(name=f"sdk-{time.time_ns()}")

created = w.model_registry.create_model_version(name=model.registered_model.name, source="dbfs:/tmp")
model = w.model_registry.get_model(name=created.registered_model.name)

w.model_registry.update_model_version(
w.model_registry.update_model(
name=model.registered_model_databricks.name,
description=f"sdk-{time.time_ns()}",
name=created.model_version.name,
version=created.model_version.version,
)

Updates a registered model.
Expand Down
29 changes: 17 additions & 12 deletions docs/workspace/workspace/workspace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@

w = WorkspaceClient()

notebook_path = f"/Users/{w.current_user.me().user_name}/sdk-{time.time_ns()}"
notebook = f"/Users/{w.current_user.me().user_name}/sdk-{time.time_ns()}"

obj = w.workspace.get_status(path=notebook_path)
get_status_response = w.workspace.get_status(path=notebook)

Gets the status of an object or a directory. If `path` does not exist, this call returns an error
`RESOURCE_DOES_NOT_EXIST`.
Expand Down Expand Up @@ -181,11 +181,18 @@
notebook_path = f"/Users/{w.current_user.me().user_name}/sdk-{time.time_ns()}"

w.workspace.import_(
content=base64.b64encode(("CREATE LIVE TABLE dlt_sample AS SELECT 1").encode()).decode(),
format=workspace.ImportFormat.SOURCE,
language=workspace.Language.SQL,
overwrite=true_,
path=notebook_path,
overwrite=true_,
format=workspace.ImportFormat.SOURCE,
language=workspace.Language.PYTHON,
content=base64.b64encode(
(
"""import time
time.sleep(10)
dbutils.notebook.exit('hello')
"""
).encode()
).decode(),
)

Imports a workspace object (for example, a notebook or file) or the contents of an entire directory.
Expand Down Expand Up @@ -229,16 +236,14 @@

.. code-block::

import os
import time

from databricks.sdk import WorkspaceClient

w = WorkspaceClient()

notebook = f"/Users/{w.current_user.me().user_name}/sdk-{time.time_ns()}"

objects = w.workspace.list(path=os.path.dirname(notebook))
names = []
for i in w.workspace.list(f"/Users/{w.current_user.me().user_name}", recursive=True):
names.append(i.path)
assert len(names) > 0

List workspace objects

Expand Down
Loading