artsheiko
Databricks Employee
Databricks Employee
  1. Create a repository containing an __init__.py file
  2. Add your library as .py file(s). Let's imagine that our library is composed by multiple sub-folders consolidated in "my_folder", one of sub-folders is named as "math_library" and contains my_awesome_lib.py
  3. In caller Notebook import as a module :
import os
import sys
sys.path.append(os.path.abspath("/Workspace/Repos/<usename>/<repo-name>/<path>/my_folder"))

or use pathlib to adress the folder you need

import os
import sys
from pathlib import Path
 
sys.path.append(str(Path(os.getcwd()).parent.absolute()))

4. Make a call to the function in question :

from math_library import my_awesome_lib
 
my_awesome_lib.<function needed name>()