Corbin
Databricks Employee
Databricks Employee

Hello Robin,

You’ll have to either use wheel files to package your libs and use those (see docs here), to make imports work out of the box. Otherwise, your entry point file needs to add the bundle root directory (or whatever the lib directory is) to your sys.path. This can be achieved by adding a parameter and then process that parameter in the first couple of lines of your entry point file (as defined in the bundle).

For example, if your bundle task looks like so:

- task_key: stream
notebook_task:
notebook_path: /path/to/file.ipynb
base_parameters:
bundle_root: ${workspace.file_path}
job_cluster_key: Job_cluster

note that "bundle_root" is arbitrary, it can be whatever you want it to be called. ${workspace.file_path} will substitute this value at runtime so it will work in different workspaces seemlessly.

Now in your /path/to/file.ipynb file, you would do something like:

root = dbutils.widgets.get("bundle_root")
sys.path.append(root)

 Hope this helps!

View solution in original post