Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,6 @@ jobs:
echo "::endgroup::"
julia --version # Check that Julia is installed correctly

- name: Set RMG-Py + database in PATH and PYTHONPATH
shell: micromamba-shell {0}
working-directory: ARC
run: |
# bash devtools/install_rmg.sh
echo "RMG_PY_PATH=$(realpath ../RMG-Py)" >> $GITHUB_ENV
echo "RMG_DB_PATH=$(realpath ../RMG-database)" >> $GITHUB_ENV
echo "PATH=$(realpath ../RMG-Py):$PATH" >> $GITHUB_ENV
echo "PYTHONPATH=$(realpath ../RMG-Py):$PYTHONPATH" >> $GITHUB_ENV

- name: Cache RMG-Py source
uses: actions/cache@v4
with:
path: RMG-Py
key: ${{ runner.os }}-rmgpy-${{ hashFiles('ARC/devtools/install_rmg.sh') }}
restore-keys: ${{ runner.os }}-rmgpy-

- name: Install all extras - CI
shell: micromamba-shell {0}
working-directory: ARC
Expand Down
28 changes: 5 additions & 23 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,17 @@ jobs:
path: ARC
fetch-depth: 1

# ── pull RMG sources ────────────────────────────────────────
- name: Checkout RMG‑Py
uses: actions/checkout@v4
with:
repository: ReactionMechanismGenerator/RMG-Py
path: RMG-Py
fetch-depth: 1

- name: Checkout RMG‑database
uses: actions/checkout@v4
with:
repository: ReactionMechanismGenerator/RMG-database
path: RMG-database
fetch-depth: 1

# ── build‑only env ───────────────────────────────────────────
# ── rmg_env for Arkane/database availability ───────────────
- name: Set up micromamba (rmg_env)
uses: mamba-org/setup-micromamba@v2
with:
environment-name: rmg_env
environment-file: RMG-Py/environment.yml
create-args: >-
-c rmg -c conda-forge python=3.9 numpy<2 rmg=3.3.0 connie::symmetry
cache-environment: true
cache-downloads: true
generate-run-shell: false

- name: Build RMG‑Py in rmg_env
run: micromamba run -n rmg_env make -C RMG-Py -j"$(nproc)"

# ── docs env (wrapper shell) ────────────────────────────────
- name: Set up micromamba (arc_env)
uses: mamba-org/setup-micromamba@v2
Expand Down Expand Up @@ -77,9 +60,8 @@ jobs:
# ── build HTML docs ─────────────────────────────────────────
- name: Set env vars & Build docs
run: |
export RMG_PATH="$GITHUB_WORKSPACE/RMG-Py"
export RMG_DB_PATH="$GITHUB_WORKSPACE/RMG-database"
export PYTHONPATH="$GITHUB_WORKSPACE/RMG-Py:$GITHUB_WORKSPACE/ARC:$PYTHONPATH"
export RMG_DB_PATH="$MAMBA_ROOT_PREFIX/envs/rmg_env/share/RMG-database"
export PYTHONPATH="$GITHUB_WORKSPACE/ARC:$PYTHONPATH"
export PATH="$GITHUB_WORKSPACE/ARC:$PATH"
make -C ARC/docs html
shell: micromamba-shell {0}
Expand Down
36 changes: 0 additions & 36 deletions .github/workflows/update-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,6 @@ jobs:
- name: Checkout ARC
uses: actions/checkout@v4

# ────────── RMG‑Py ──────────
- name: Cache RMG
id: cache-rmg
uses: actions/cache@v4
with:
path: RMG-Py
key: ${{ runner.os }}-rmg-main
restore-keys: |
${{ runner.os }}-rmg-
- name: Checkout RMG-Py
if: steps.cache-rmg.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: ReactionMechanismGenerator/RMG-Py
path: RMG-Py
ref: 55464c54d1fa61b531e865682df598d33718597d
fetch-depth: 1

# ────────── RMG‑database ──────────
- name: Cache RMG-database
id: cache-rmg-db
uses: actions/cache@v4
with:
path: RMG-database
key: ${{ runner.os }}-rmgdb-main
restore-keys: |
${{ runner.os }}-rmgdb-
- name: Checkout RMG-database
if: steps.cache-rmg-db.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: ReactionMechanismGenerator/RMG-database
path: RMG-database
ref: main
fetch-depth: 1

# ────────── AutoTST ──────────
- name: Cache AutoTST
id: cache-autotst
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ build/*

*.log
*.xml

# AI Agent files
AGENTS.md
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
DEVTOOLS_DIR := devtools

.PHONY: all help clean test test-unittests test-functional test-all \
install-all install-ci install-pyrdl install-rmgdb install-autotst install-gcn \
install-all install-ci install-pyrdl install-rmg install-rmgdb install-autotst install-gcn \
install-gcn-cpu install-kinbot install-sella install-xtb install-torchani install-ob \
lite check-env compile

Expand All @@ -28,6 +28,7 @@ help:
@echo " install Install all external dependencies"
@echo " install-ci Install all external dependencies for CI (no clean)"
@echo " install-pyrdl Install PyRDL"
@echo " install-rmg Install RMG (default: packaged, override via RMG_ARGS=...)"
@echo " install-rmgdb Install RMG-database"
@echo " install-autotst Install AutoTST"
@echo " install-gcn Install TS-GCN (GPU)"
Expand Down Expand Up @@ -75,6 +76,9 @@ install-lite:
install-pyrdl:
bash $(DEVTOOLS_DIR)/install_pyrdl.sh

install-rmg:
bash $(DEVTOOLS_DIR)/install_rmg.sh $(RMG_ARGS)

install-rmgdb:
bash $(DEVTOOLS_DIR)/install_rmgdb.sh

Expand Down
21 changes: 19 additions & 2 deletions arc/family/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@
logger = get_logger()


def get_rmg_db_subpath(*parts: str, must_exist: bool = False) -> str:
"""Return a path under the RMG database, handling both source and packaged layouts."""
if RMG_DB_PATH is None:
if must_exist:
raise FileNotFoundError('RMG_DB_PATH is not set; cannot locate the RMG database.')
return os.path.join('input', *parts)
candidates = [
os.path.join(RMG_DB_PATH, 'input', *parts),
os.path.join(RMG_DB_PATH, *parts),
]
if must_exist:
for candidate in candidates:
if os.path.exists(candidate):
return candidate
return candidates[0]


class ReactionFamily(object):
"""
A class for representing a reaction family.
Expand Down Expand Up @@ -72,7 +89,7 @@ def get_groups_file_as_lines(self, consider_arc_families: bool = True) -> List[s
Returns:
List[str]: The groups file as a list of lines.
"""
groups_path = os.path.join(RMG_DB_PATH, 'input', 'kinetics', 'families', self.label, 'groups.py')
groups_path = get_rmg_db_subpath('kinetics', 'families', self.label, 'groups.py', must_exist=True)
if not os.path.isfile(groups_path):
if consider_arc_families:
groups_path = os.path.join(ARC_FAMILIES_PATH, f'{self.label}.py')
Expand Down Expand Up @@ -605,7 +622,7 @@ def get_rmg_recommended_family_sets() -> Dict[str, str]:
Dict[str, str]: The recommended RMG family sets.
"""
family_sets = dict()
recommended_path = os.path.join(RMG_DB_PATH, 'input', 'kinetics', 'families', 'recommended.py')
recommended_path = get_rmg_db_subpath('kinetics', 'families', 'recommended.py', must_exist=True)
if not os.path.isfile(recommended_path):
raise FileNotFoundError(f'Could not find the recommended RMG families file at {recommended_path}')
with open(recommended_path, 'r') as f:
Expand Down
13 changes: 8 additions & 5 deletions arc/family/family_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from arc.family.family import (ReactionFamily,
ARC_FAMILIES_PATH,
RMG_DB_PATH,
get_rmg_db_subpath,
add_labels_to_molecule,
check_product_isomorphism,
descent_complex_group,
Expand Down Expand Up @@ -50,8 +51,10 @@ def setUpClass(cls):

def test_rmgdb_path(self):
"""Test finding the RMG-database path"""
self.assertIn('RMG-database', RMG_DB_PATH)
self.assertTrue(os.path.isdir(RMG_DB_PATH))
self.assertTrue(any(token in RMG_DB_PATH for token in ('RMG-database', 'rmgdatabase', 'rmg_database')))
self.assertTrue(os.path.isdir(os.path.join(RMG_DB_PATH, 'input'))
or os.path.isdir(os.path.join(RMG_DB_PATH, 'kinetics')))

def test_arc_families_path(self):
"""Test finding the ARC families folder path"""
Expand Down Expand Up @@ -920,14 +923,14 @@ def test_get_product_num(self):
def test_get_reactant_groups_from_template(self):
"""Test getting reactant groups from a template"""
fam_1 = ReactionFamily('6_membered_central_C-C_shift')
groups_path = os.path.join(RMG_DB_PATH, 'input', 'kinetics', 'families', fam_1.label, 'groups.py')
groups_path = get_rmg_db_subpath('kinetics', 'families', fam_1.label, 'groups.py', must_exist=True)
with open(groups_path, 'r') as f:
groups = f.readlines()
reactants_1 = get_reactant_groups_from_template(groups)
self.assertEqual(reactants_1, [['1_5_unsaturated_hexane']])

fam_2 = ReactionFamily('H_Abstraction')
groups_path = os.path.join(RMG_DB_PATH, 'input', 'kinetics', 'families', fam_2.label, 'groups.py')
groups_path = get_rmg_db_subpath('kinetics', 'families', fam_2.label, 'groups.py', must_exist=True)
with open(groups_path, 'r') as f:
groups = f.readlines()
reactants_2 = get_reactant_groups_from_template(groups)
Expand All @@ -936,7 +939,7 @@ def test_get_reactant_groups_from_template(self):
self.assertEqual(reactants_2, expected_reactants)

fam_3 = ReactionFamily('1,2-Birad_to_alkene')
groups_path = os.path.join(RMG_DB_PATH, 'input', 'kinetics', 'families', fam_3.label, 'groups.py')
groups_path = get_rmg_db_subpath('kinetics', 'families', fam_3.label, 'groups.py', must_exist=True)
with open(groups_path, 'r') as f:
groups = f.readlines()
reactants_3 = get_reactant_groups_from_template(groups)
Expand Down Expand Up @@ -988,7 +991,7 @@ def test_get_recipe_actions(self):
['LOSE_RADICAL', '*3', '1']])

fam_1 = ReactionFamily('6_membered_central_C-C_shift')
groups_path = os.path.join(RMG_DB_PATH, 'input', 'kinetics', 'families', fam_1.label, 'groups.py')
groups_path = get_rmg_db_subpath('kinetics', 'families', fam_1.label, 'groups.py', must_exist=True)
with open(groups_path, 'r') as f:
groups = f.readlines()
actions = get_recipe_actions(groups)
Expand Down
14 changes: 11 additions & 3 deletions arc/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import arc.plotter as plotter
from arc.common import ARC_PATH, get_logger, read_yaml_file, save_yaml_file
from arc.imports import settings
from arc.level import Level
from arc.job.local import execute_command
from arc.statmech.factory import statmech_factory
Expand Down Expand Up @@ -246,11 +247,15 @@ def compare_thermo(species_for_thermo_lib: list,
species_thermo_path = os.path.join(output_directory, 'RMG_thermo.yml')
save_yaml_file(path=species_thermo_path,
content=[{'label': spc.label, 'adjlist': spc.mol.copy(deep=True).to_adjacency_list()} for spc in species_for_thermo_lib])
env_name = settings.get('RMG_ENV_NAME', 'rmg_env')
rmg_db_path = settings.get('RMG_DB_PATH') or ""
commands = ['bash -lc "set -euo pipefail; '
f'export RMG_DB_PATH=\\"{rmg_db_path}\\"; '
f'export RMG_DATABASE=\\"{rmg_db_path}\\"; '
'if command -v micromamba >/dev/null 2>&1; then '
f' micromamba run -n rmg_env python {THERMO_SCRIPT_PATH} {species_thermo_path}; '
f' micromamba run -n {env_name} python {THERMO_SCRIPT_PATH} {species_thermo_path}; '
'elif command -v conda >/dev/null 2>&1 || command -v mamba >/dev/null 2>&1; then '
f' conda run -n rmg_env python {THERMO_SCRIPT_PATH} {species_thermo_path}; '
f' conda run -n {env_name} python {THERMO_SCRIPT_PATH} {species_thermo_path}; '
'else '
' echo \'❌ Micromamba/Mamba/Conda required\' >&2; exit 1; '
'fi"',
Expand Down Expand Up @@ -300,7 +305,8 @@ def compare_rates(rxns_for_kinetics_lib: list,
'family': rxn.family,
} for rxn in rxns_for_kinetics_lib],
)
env_name = 'rmg_env'
env_name = settings.get('RMG_ENV_NAME', 'rmg_env')
rmg_db_path = settings.get('RMG_DB_PATH') or ""
shell_script = f"""if command -v micromamba &> /dev/null; then
eval "$(micromamba shell hook --shell=bash)"
micromamba activate {env_name}
Expand All @@ -313,6 +319,8 @@ def compare_rates(rxns_for_kinetics_lib: list,
else
exit 1
fi
export RMG_DB_PATH="{rmg_db_path}"
export RMG_DATABASE="{rmg_db_path}"
python {KINETICS_SCRIPT_PATH} {reactions_kinetics_path} > >(tee -a stdout.log) 2> >(tee -a stderr.log >&2)
"""
o, e = execute_command(command=shell_script,
Expand Down
Loading
Loading