- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 04:28 AM - edited 06-17-2024 04:29 AM
Hey @tramtran,
I didn't try with repos, but it works with a Workspace path the following way (we're doing it like this so I validated it for you). I guess since Repos are also inside /Workspace, it will work the same way.
Lets use the default /Workspace/Shared folder for this example.
1. Add the .py file with your table_exists function to the /Workspace/Shared folder. Lets call the file function_file.py for this example.
2. Create an __init__.py file in this/Workspace/Shared directory as well. So Databricks knows this is a package index.
3. In the notebook you want to import the function from the .py file, add this:
import sys
sys.path.append("/Workspace/Shared")
then import the function like this:
from function_file import table_exists
Hope this helps, good luck!