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
6 changes: 5 additions & 1 deletion databricks/sdk/dbutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ def __init__(self) -> None:
class RemoteDbUtils:

def __init__(self, config: "Config" = None):
self._config = Config() if not config else config
# Create a shallow copy of the config to allow the use of a custom
# user-agent while avoiding modifying the original config.
self._config = Config() if not config else config.copy()
self._config.with_user_agent_extra("dbutils", "remote")

self._client = ApiClient(self._config)
self._clusters = compute_ext.ClustersExt(self._client)
self._commands = compute.CommandExecutionAPI(self._client)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_dbutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,12 @@ def test_dbutils_proxy_overrides(dbutils, mocker, restorable_env):
return_value="test_cluster_id",
)
assert dbutils.notebook.entry_point.getDbutils().notebook().getContext().notebookPath().get() == "test_source_file"


def test_dbutils_adds_user_agent(config):
from databricks.sdk.dbutils import RemoteDbUtils

# Create dbutils and check that user-agent includes sdk-feature/dbutils
dbutils = RemoteDbUtils(config)

assert "dbutils/remote" in dbutils._config.user_agent
Loading