You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working with Databricks Asset Bundles (DABs), we've consistently encountered challenges in maintaining a proper sys.path that allows for seamless module imports across various development environments, including:
Local development (VSCode with Databricks Connect)
Databricks UI
Job Clusters
To address this, we've implemented a workaround in nearly all of our notebooks. The following code block is typically used at the beginning of each script script, that acts as a entry point, e.g. notebooks:
if'dbutils'inglobals():
# We're in a Databricks notebookproject_root=Path('../../../').resolve()
else:
fromdatabricks.sdkimportWorkspaceClientw=WorkspaceClient()
dbutils=w.dbutils# We're not in a Databricks notebook (e.g., running with Databricks Connect)current_file_path=Path(file).resolve()
project_root=current_file_path.parents[3]
ifstr(project_root) notinsys.path:
sys.path.insert(0, str(project_root))
To streamline development and improve consistency across environments, we propose that Databricks Asset Bundles (DABs) include a feature to specify the Python root path directly. This enhancement would eliminate the need for the current workarounds.
The text was updated successfully, but these errors were encountered:
When working with Databricks Asset Bundles (DABs), we've consistently encountered challenges in maintaining a proper
sys.path
that allows for seamless module imports across various development environments, including:To address this, we've implemented a workaround in nearly all of our notebooks. The following code block is typically used at the beginning of each script script, that acts as a entry point, e.g. notebooks:
This problem is also discussed in the Databricks Community thread: How to set Python rootpath when deploying with DABs
To streamline development and improve consistency across environments, we propose that Databricks Asset Bundles (DABs) include a feature to specify the Python root path directly. This enhancement would eliminate the need for the current workarounds.
The text was updated successfully, but these errors were encountered: