diff --git a/pipelines/data_integration.py b/pipelines/data_integration.py index af0c2cc..aaf49a4 100644 --- a/pipelines/data_integration.py +++ b/pipelines/data_integration.py @@ -1,7 +1,17 @@ import sys import os -root_dir = os.path.abspath(os.curdir) -sys.path.append(root_dir) + +try: + thisFilePath = os.path.abspath(__file__) +except NameError: + print("Error: __file__ is not available. Ensure the script is being run from a file.") + print("[Notice] Path to DIMA package may not be resolved properly.") + thisFilePath = os.getcwd() # Use current directory or specify a default + +dimaPath = os.path.normpath(os.path.join(thisFilePath, "..",'..')) # Move up to project root + +if dimaPath not in sys.path: # Avoid duplicate entries + sys.path.append(dimaPath) import yaml diff --git a/pipelines/metadata_revision.py b/pipelines/metadata_revision.py index c22deb3..363243e 100644 --- a/pipelines/metadata_revision.py +++ b/pipelines/metadata_revision.py @@ -1,8 +1,17 @@ import sys import os -# Add the parent directory to the system path -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +try: + thisFilePath = os.path.abspath(__file__) +except NameError: + print("Error: __file__ is not available. Ensure the script is being run from a file.") + print("[Notice] Path to DIMA package may not be resolved properly.") + thisFilePath = os.getcwd() # Use current directory or specify a default + +dimaPath = os.path.normpath(os.path.join(thisFilePath, "..",'..')) # Move up to project root + +if dimaPath not in sys.path: # Avoid duplicate entries + sys.path.append(dimaPath) import h5py import yaml