Update to pipelines/data_integration.py. Added feature to use environment variable MOUNT_DRIVE defined in .env file.

This commit is contained in:
2025-06-22 12:11:48 +02:00
parent be7cf0ba12
commit f3ff32e049

View File

@ -81,6 +81,22 @@ def load_config_and_setup_logging(yaml_config_file_path, log_dir):
if missing_keys: if missing_keys:
raise KeyError(f"Missing required keys in YAML configuration: {missing_keys}") raise KeyError(f"Missing required keys in YAML configuration: {missing_keys}")
# Look for all placeholders like ${VAR_NAME}
input_dir = config_dict['input_file_directory']
placeholders = re.findall(r'\$\{([^}^{]+)\}', input_dir)
success = utils.load_env_from_root()
print(f'Success : {success}')
for var in placeholders:
env_value = os.environ.get(var)
if env_value is None:
raise ValueError(f"Environment variable '{var}' is not set but used in the config.")
input_dir = input_dir.replace(f"${{{var}}}", env_value)
config_dict['input_file_directory'] = input_dir
# Check the instrument_datafolder required type and ensure the list is of at least length one. # Check the instrument_datafolder required type and ensure the list is of at least length one.
if isinstance(config_dict['instrument_datafolder'], list) and not len(config_dict['instrument_datafolder'])>=1: if isinstance(config_dict['instrument_datafolder'], list) and not len(config_dict['instrument_datafolder'])>=1:
raise ValueError('Invalid value for key "instrument_datafolder". Expected a list of strings with at least one item.' raise ValueError('Invalid value for key "instrument_datafolder". Expected a list of strings with at least one item.'