Fixed instrument_dir estimation to be bottom up, ie, based on path to file. Otherwise, it does not work when dima used as submodule

This commit is contained in:
2024-09-19 15:47:11 +02:00
parent 9eeb9d6380
commit 0dbec94374

View File

@ -17,12 +17,11 @@ def read_txt_files_as_dict(filename: str, instruments_dir: str = None, work_with
# If instruments_dir is not provided, use the default path relative to the module directory
if not instruments_dir:
# Assuming the instruments folder is one level up from the source module directory
#module_dir = os.path.dirname(__file__)
#instruments_dir = os.path.join(module_dir, '..', 'instruments')
instruments_dir = os.path.join(root_dir,'instruments')
module_dir = os.path.dirname(__file__)
instruments_dir = os.path.join(module_dir, '..')
# Normalize the path (resolves any '..' in the path)
instrument_configs_path = os.path.abspath(os.path.join(instruments_dir,'readers/config_text_reader.yaml'))
instrument_configs_path = os.path.abspath(os.path.join(instruments_dir,'readers','config_text_reader.yaml'))
with open(instrument_configs_path,'r') as stream:
try: