Add utility functions add_project_path_to_sys_path() to set up path to DIMA's modules dynamically.
This commit is contained in:
16
notebooks/nbutils.py
Normal file
16
notebooks/nbutils.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
def add_project_path_to_sys_path():
|
||||||
|
"""
|
||||||
|
Adds the project path (root directory containing the package) to sys.path.
|
||||||
|
"""
|
||||||
|
# Determine the root directory (project_root, which contains 'dima')
|
||||||
|
notebook_dir = os.getcwd() # Current working directory (assumes running from notebooks/)
|
||||||
|
project_path = os.path.normpath(os.path.join(notebook_dir, "..")) # Move up to project root
|
||||||
|
|
||||||
|
if project_path not in sys.path: # Avoid duplicate entries
|
||||||
|
sys.path.append(project_path)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
add_project_path_to_sys_path()
|
Reference in New Issue
Block a user