Skip to content

Commit

Permalink
Don't import dbutils.widget until use (#859)
Browse files Browse the repository at this point in the history
## Changes
We should not call dbutils.widget in the init script. This causes
dbutils to internally try to import the widget implementation. When in
notebook environment, the widget implementation shows a special warning
which prompts users to install the sdk version with ipywidget support.

<img width="1059" alt="Screenshot 2023-09-05 at 19 28 24"
src="https://github.com/databricks/databricks-vscode/assets/88345179/59c65c39-5808-4601-8fa9-d17858520835">

## Tests
<!-- How is this tested? -->
  • Loading branch information
kartikgupta-db authored Sep 7, 2023
1 parent a5c26e3 commit 0a9e694
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ def create_and_register_databricks_globals():
# "table", "sc", "sqlContext" are missing
spark: SparkSession = DatabricksSession.builder.getOrCreate()
sql = spark.sql
getArgument = dbutils.widgets.getArgument

# We do this to prevent importing widgets implementation prematurely
# The widget import should prompt users to use the implementation
# which has ipywidget support.
def getArgument(*args, **kwargs):
return dbutils.widgets.getArgument(*args, **kwargs)

globals()['dbutils'] = dbutils
globals()['spark'] = spark
Expand Down

0 comments on commit 0a9e694

Please sign in to comment.