Skip to content

Commit

Permalink
Refactor job submission and environment setup for CREST integration
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinp0 committed Dec 22, 2024
1 parent 22ffb04 commit 881aa87
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 36 deletions.
24 changes: 15 additions & 9 deletions arc/job/adapters/ts/heuristics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,12 +1080,12 @@ def h_abstraction(arc_reaction: 'ARCReaction',
except (ValueError, KeyError) as e:
logger.error(f"Could not determine the H abstraction atoms, got:\n{e}")

if crest_paths:
crest_jobs = submit_crest_jobs(crest_paths)
monitor_crest_jobs(crest_jobs) # Keep checking job statuses until complete
process_completed_jobs(crest_jobs, xyz_guesses)
else:
logger.error("No CREST paths found")
if crest_paths:
crest_jobs = submit_crest_jobs(crest_paths)
monitor_crest_jobs(crest_jobs) # Keep checking job statuses until complete
process_completed_jobs(crest_jobs, xyz_guesses)
else:
logger.error("No CREST paths found")


return xyz_guesses
Expand Down Expand Up @@ -1147,12 +1147,16 @@ def crest_ts_conformer_search(xyz_guess: dict, a_atom: int, h_atom: int, b_atom:
commands = [
f'{CREST_PATH}',
f' -T {SERVERS["local"].get("cpus", 8)}',
f'{path}/coords.ref',
f'--cinp {path}/constraints.inp',
'coords.ref',
'--cinp constraints.inp',
'--noreftopo'
]
command = ' '.join(commands)
command = f"{CREST_ENV_PATH} && {command}" if CREST_ENV_PATH else command

if CREST_ENV_PATH:
activation_line = CREST_ENV_PATH
else:
activation_line = ''

if SERVERS.get('local') is not None:
if SERVERS['local']['cluster_soft'].lower() in ['condor', 'htcondor']:
Expand All @@ -1172,6 +1176,7 @@ def crest_ts_conformer_search(xyz_guess: dict, a_atom: int, h_atom: int, b_atom:
# Write the crest job
crest_job = submit_scripts['local']['crest_job']
format_params = {
"activation_line": activation_line,
"commands": command,
}
crest_job = crest_job.format(**format_params)
Expand All @@ -1186,6 +1191,7 @@ def crest_ts_conformer_search(xyz_guess: dict, a_atom: int, h_atom: int, b_atom:
"name": f"crest_{xyz_crest_int}",
"cpus": SERVERS['local'].get('cpus', 8),
"memory": SERVERS['local'].get('memory', 32.0) * 1024,
"activation_line": activation_line,
"commands": command,
}
sub_job = sub_job.format(**format_params)
Expand Down
13 changes: 10 additions & 3 deletions arc/settings/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,17 @@
""",
'crest_job': """#!/bin/bash
source ~/.bashrc
touch initial_time
{activation_line}
{commands}
touch final_time
# Remove all files except for crest_best.xyz, coords.ref constraints.inp
rm -vfr !(crest_best.xyz|coords.ref|constraints.inp)
find . ! -name 'crest_best.xyz' ! -name 'coords.ref' ! -name 'constraints.inp' -type f -exec rm -v {} +
""",
# Atlas uses HTCondor, see docs here: https://htcondor.readthedocs.io/en/latest/
Expand Down Expand Up @@ -893,13 +896,17 @@
#PBS -o out.txt
#PBS -e err.txt
source ~/.bashrc
touch initial_time
{activation_line}
{commands}
touch final_time
rm -vrf !(crest_best.xyz|coords.ref|constraints.inp)
find . ! -name 'crest_best.xyz' ! -name 'coords.ref' ! -name 'constraints.inp' -type f -exec rm -v {} +
""",
},
Expand Down
48 changes: 24 additions & 24 deletions devtools/install_crest.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
#!/bin/bash -l

# Check if Micromamba is installed
if [ -x "$(command -v micromamba)" ]; then
echo "Micromamba is installed."
COMMAND_PKG=micromamba
if [[ -x "$(command -v micromamba)" ]]; then
echo "Micromamba is installed."
COMMAND_PKG=micromamba
# Check if Mamba is installed
elif [ -x "$(command -v mamba)" ]; then
echo "Mamba is installed."
COMMAND_PKG=mamba
elif [[ -x "$(command -v mamba)" ]]; then
echo "Mamba is installed."
COMMAND_PKG=mamba
# Check if Conda is installed
elif [ -x "$(command -v conda)" ]; then
echo "Conda is installed."
COMMAND_PKG=conda
elif [[ -x "$(command -v conda)" ]]; then
echo "Conda is installed."
COMMAND_PKG=conda
else
echo "Micromamba, Mamba, and Conda are not installed. Please download and install one of them - we strongly recommend Micromamba or Mamba."
exit 1
echo "Micromamba, Mamba, and Conda are not installed. Please download and install one of them - we strongly recommend Micromamba or Mamba."
exit 1
fi

# Set up Conda/Micromamba environment
if [ "$COMMAND_PKG" = "micromamba" ]; then
eval "$(micromamba shell hook --shell=bash)"
micromamba activate base
BASE=$MAMBA_ROOT_PREFIX
# shellcheck source=/dev/null
. "$BASE/etc/profile.d/micromamba.sh"
if [[ ${COMMAND_PKG} == "micromamba" ]]; then
eval "$(micromamba shell hook --shell=bash)"
micromamba activate base
BASE=${MAMBA_ROOT_PREFIX}
# shellcheck source=/dev/null
. "${BASE}/etc/profile.d/micromamba.sh"
else
BASE=$(conda info --base)
# shellcheck source=/dev/null
. "$BASE/etc/profile.d/conda.sh"
BASE=$(conda info --base)
# shellcheck source=/dev/null
. "${BASE}/etc/profile.d/conda.sh"
fi

# create the environment
echo "Creating the Crest environment..."
$COMMAND_PKG create -n crest_env -c conda-forge python=3.10 crest=2.12 -y
${COMMAND_PKG} create -n crest_env -c conda-forge python=3.10 crest=2.12 -y
# Activate the environment
if [ "$COMMAND_PKG" == "micromamba" ]; then
micromamba activate crest_env
if [[ ${COMMAND_PKG} == "micromamba" ]]; then
micromamba activate crest_env
else
conda activate crest_env
conda activate crest_env
fi

echo "Done installing Crest environment."

0 comments on commit 881aa87

Please sign in to comment.