From ebb71c5f4ecfc1cae4c37f9e995842093660d840 Mon Sep 17 00:00:00 2001 From: Boyuan Deng <40481626+dby-tmwctw@users.noreply.github.com> Date: Thu, 1 Jun 2023 11:12:05 -0700 Subject: [PATCH] [PROD-37531] Exposing REPL credential provider to Python SDK (#130) ## Changes In previous [PR](https://github.com/databricks/universe/pull/316192), we expose a function that will be used by Python SDK's `runtime_native_auth` so that in notebook environment it directly access information from command execution to authenticate. This PR import it from Python runtime to put on last piece of puzzle. ## Tests - [ ] `make test` run locally - [x] `make fmt` applied - [x] relevant integration tests applied --- databricks/sdk/runtime/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/databricks/sdk/runtime/__init__.py b/databricks/sdk/runtime/__init__.py index e83c9d65c..e4a3bfd87 100644 --- a/databricks/sdk/runtime/__init__.py +++ b/databricks/sdk/runtime/__init__.py @@ -6,7 +6,8 @@ # available to be imported from databricks.sdk.runtime.globals. This import can be used # in Python modules so users can access these objects from Files more easily. dbruntime_objects = [ - "display", "displayHTML", "dbutils", "table", "sql", "udf", "getArgument", "sc", "sqlContext", "spark" + "display", "displayHTML", "dbutils", "table", "sql", "udf", "getArgument", "sc", "sqlContext", "spark", + "init_runtime_native_auth" ] RuntimeAuth = Tuple[str, Callable[[], Dict[str, str]]] @@ -23,6 +24,8 @@ def init_runtime_native_auth() -> RuntimeAuth: userNamespaceGlobals = UserNamespaceInitializer.getOrCreate().get_namespace_globals() _globals = globals() for var in dbruntime_objects: + if var not in userNamespaceGlobals: + continue _globals[var] = userNamespaceGlobals[var] is_local_implementation = False except ImportError: