Skip to content

Commit 61cc935

Browse files
committed
runtime: justify broad except in Spark Connect fallback
Add a sentence to the inline comment explaining why the catch is broad rather than typed on PySparkRuntimeError — avoids importing pyspark at SDK import time and keeps unexpected runtime-namespace errors surfaced as a warning + safe fallback instead of a constructor crash.
1 parent 337cc38 commit 61cc935

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

databricks/sdk/runtime/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ def inner() -> Dict[str, str]:
116116
# and raises CONTEXT_UNAVAILABLE_FOR_REMOTE_CLIENT. Treat this like "not in a classic
117117
# runtime" and fall back to the OSS/remote implementation below, which is Spark
118118
# Connect-compatible. Without this, importing databricks.sdk.runtime (and therefore
119-
# constructing a WorkspaceClient on such a cluster) raises at import time.
119+
# constructing a WorkspaceClient on such a cluster) raises at import time. The catch
120+
# is broad rather than typed on PySparkRuntimeError so the SDK does not need to import
121+
# pyspark just to narrow the exception type; any other unexpected failure here is also
122+
# safer surfaced as a warning + remote fallback than as a constructor crash.
120123
logger.warning(f"Runtime namespace unavailable, falling back to remote implementation: {e}")
121124

122125
if not _use_runtime_namespace:

0 commit comments

Comments
 (0)