Skip to content

Commit e22263e

Browse files
committed
Allows configurable RMG environment and database path
Enables users to specify the RMG environment name and database path. This makes it easier to use different RMG installations and databases. The environment variables RMG_ENV_NAME and RMG_DB_PATH are now respected.
1 parent 5445e45 commit e22263e

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

arc/processor.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import arc.plotter as plotter
1010
from arc.common import ARC_PATH, get_logger, read_yaml_file, save_yaml_file
11+
from arc.imports import settings
1112
from arc.level import Level
1213
from arc.job.local import execute_command
1314
from arc.statmech.factory import statmech_factory
@@ -246,11 +247,15 @@ def compare_thermo(species_for_thermo_lib: list,
246247
species_thermo_path = os.path.join(output_directory, 'RMG_thermo.yml')
247248
save_yaml_file(path=species_thermo_path,
248249
content=[{'label': spc.label, 'adjlist': spc.mol.copy(deep=True).to_adjacency_list()} for spc in species_for_thermo_lib])
250+
env_name = settings.get('RMG_ENV_NAME', 'rmg_env')
251+
rmg_db_path = settings.get('RMG_DB_PATH') or ""
249252
commands = ['bash -lc "set -euo pipefail; '
253+
f'export RMG_DB_PATH=\\"{rmg_db_path}\\"; '
254+
f'export RMG_DATABASE=\\"{rmg_db_path}\\"; '
250255
'if command -v micromamba >/dev/null 2>&1; then '
251-
f' micromamba run -n rmg_env python {THERMO_SCRIPT_PATH} {species_thermo_path}; '
256+
f' micromamba run -n {env_name} python {THERMO_SCRIPT_PATH} {species_thermo_path}; '
252257
'elif command -v conda >/dev/null 2>&1 || command -v mamba >/dev/null 2>&1; then '
253-
f' conda run -n rmg_env python {THERMO_SCRIPT_PATH} {species_thermo_path}; '
258+
f' conda run -n {env_name} python {THERMO_SCRIPT_PATH} {species_thermo_path}; '
254259
'else '
255260
' echo \'❌ Micromamba/Mamba/Conda required\' >&2; exit 1; '
256261
'fi"',
@@ -300,7 +305,8 @@ def compare_rates(rxns_for_kinetics_lib: list,
300305
'family': rxn.family,
301306
} for rxn in rxns_for_kinetics_lib],
302307
)
303-
env_name = 'rmg_env'
308+
env_name = settings.get('RMG_ENV_NAME', 'rmg_env')
309+
rmg_db_path = settings.get('RMG_DB_PATH') or ""
304310
shell_script = f"""if command -v micromamba &> /dev/null; then
305311
eval "$(micromamba shell hook --shell=bash)"
306312
micromamba activate {env_name}
@@ -313,6 +319,8 @@ def compare_rates(rxns_for_kinetics_lib: list,
313319
else
314320
exit 1
315321
fi
322+
export RMG_DB_PATH="{rmg_db_path}"
323+
export RMG_DATABASE="{rmg_db_path}"
316324
python {KINETICS_SCRIPT_PATH} {reactions_kinetics_path} > >(tee -a stdout.log) 2> >(tee -a stderr.log >&2)
317325
"""
318326
o, e = execute_command(command=shell_script,

0 commit comments

Comments
 (0)