Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROD-37531] Exposing REPL credential provider to Python SDK #130

Merged
Merged
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
5 changes: 4 additions & 1 deletion databricks/sdk/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if init_runtime_native_auth is not present in the userNamespaceGlobals in the old DBR versions? please add if var not in userNamespaceGlobals: continue, otherwise SDK might crash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nfx I will add it. However, when I test this against DBR 12.2 LTS (which definitely doesn't have init_runtime_native_auth), it doesn't actually crash. That is surprising considering that if I run this in notebook, it raise a KeyError as expected. Do you have any idea why this is the case? Just curious.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a mystery :)

]

RuntimeAuth = Tuple[str, Callable[[], Dict[str, str]]]
Expand All @@ -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:
Expand Down