Skip to content

Commit 42b0798

Browse files
committed
Fixes
1 parent a18828f commit 42b0798

6 files changed

Lines changed: 33 additions & 14 deletions

File tree

arc/job/adapters/gaussian.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __init__(self,
155155
self.incore_capacity = 1
156156
self.job_adapter = 'gaussian'
157157
self.execution_type = execution_type or 'queue'
158-
self.command = ['g03', 'g09', 'g16']
158+
self.command = ['g16', 'g09', 'g03']
159159
self.url = 'https://gaussian.com/'
160160

161161
if species is None:
@@ -500,13 +500,15 @@ def execute_incore(self):
500500
"""
501501
Execute a job incore.
502502
"""
503-
which(self.command,
504-
return_bool=True,
505-
raise_error=True,
506-
raise_msg=f'Please install {self.job_adapter}, see {self.url} for more information.',
507-
)
503+
binary = which(self.command,
504+
return_bool=False,
505+
raise_error=True,
506+
raise_msg=f'Please install {self.job_adapter}, see {self.url} for more information.',
507+
)
508+
binary_name = os.path.basename(binary)
508509
self._log_job_execution()
509-
execute_command(incore_commands[self.job_adapter])
510+
commands = [cmd.replace('g16', binary_name) for cmd in incore_commands[self.job_adapter]]
511+
execute_command(commands)
510512

511513
def execute_queue(self):
512514
"""

arc/job/pipe/pipe_run.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,19 @@ def write_submit_script(self) -> str:
211211
f'No pipe submit template for cluster software: {self.cluster_software}. '
212212
f'Available templates: {list(pipe_submit.keys())}')
213213
cpus, memory_mb, array_size = self._submission_resources()
214+
server = servers_dict.get('local', {})
215+
queue, _ = next(iter(server.get('queues', {}).items()), ('', None))
216+
engine = self.tasks[0].engine if self.tasks else ''
217+
env_setup = pipe_settings.get('env_setup', {}).get(engine, '')
214218
content = pipe_submit[template_key].format(
215219
name=f'pipe_{self.run_id}',
216220
max_task_num=array_size,
217221
pipe_root=self.pipe_root,
218222
python_exe=sys.executable,
219223
cpus=cpus,
220224
memory=memory_mb,
225+
queue=queue,
226+
env_setup=env_setup,
221227
)
222228
filename = 'submit.sub' if self.cluster_software == 'htcondor' else 'submit.sh'
223229
submit_path = os.path.join(self.pipe_root, filename)

arc/job/pipe/pipe_run_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ def test_pbs_content(self):
159159
path = run.write_submit_script()
160160
with open(path) as f:
161161
content = f.read()
162-
self.assertIn('#PBS -t 1-8', content)
163-
self.assertIn('WORKER_ID=$PBS_ARRAYID', content)
162+
self.assertIn('#PBS -J 1-8', content)
163+
self.assertIn('WORKER_ID="$PBS_ARRAY_INDEX"', content)
164164

165165
def test_htcondor_content(self):
166166
run = self._make_run('htcondor', max_workers=12, n_tasks=12)

arc/scripts/pipe_worker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ def _run_adapter(spec: TaskSpec, scratch_dir: str, job_type: str, **extra_kwargs
262262
**extra_kwargs,
263263
)
264264
job.execute()
265+
output_file = getattr(job, 'local_path_to_output_file', None)
266+
if output_file and not os.path.isfile(output_file):
267+
raise RuntimeError(f'{spec.engine} produced no output file at {output_file}. '
268+
f'The engine may not be installed or configured on this node.')
265269

266270

267271
# ---------------------------------------------------------------------------

arc/settings/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@
313313
'max_workers': 100, # Upper bound on array worker slots per PipeRun.
314314
'max_attempts': 3, # Retry budget per task before terminal failure.
315315
'lease_duration_s': 86400, # Worker lease duration in seconds (default 24h).
316+
'env_setup': {}, # Engine-specific shell setup commands, e.g.,
317+
# {'gaussian': 'source /usr/local/g09/setup.sh',
318+
# 'orca': 'source /usr/local/orca/setup.sh'}
316319
}
317320

318321
# Criteria for identification of imaginary frequencies for transition states.

arc/settings/submit.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,41 @@
5050
pipe_submit = {
5151
'slurm': """#!/bin/bash -l
5252
#SBATCH -J {name}
53+
#SBATCH -p {queue}
5354
#SBATCH -N 1
5455
#SBATCH -n {cpus}
5556
#SBATCH --mem={memory}
5657
#SBATCH --array=1-{max_task_num}
5758
#SBATCH -o {pipe_root}/out_%a.txt
5859
#SBATCH -e {pipe_root}/err_%a.txt
5960
61+
{env_setup}
6062
WORKER_ID=$SLURM_ARRAY_TASK_ID
6163
6264
{python_exe} -m arc.scripts.pipe_worker --pipe_root {pipe_root} --worker_id $WORKER_ID
6365
""",
6466
'pbs': """#!/bin/bash -l
6567
#PBS -N {name}
68+
#PBS -q {queue}
6669
#PBS -l ncpus={cpus}
6770
#PBS -l mem={memory}mb
68-
#PBS -t 1-{max_task_num}
69-
#PBS -o {pipe_root}/out_$PBS_ARRAYID.txt
70-
#PBS -e {pipe_root}/err_$PBS_ARRAYID.txt
71+
#PBS -J 1-{max_task_num}
7172
72-
WORKER_ID=$PBS_ARRAYID
73+
{env_setup}
74+
WORKER_ID="$PBS_ARRAY_INDEX"
7375
74-
{python_exe} -m arc.scripts.pipe_worker --pipe_root {pipe_root} --worker_id $WORKER_ID
76+
{python_exe} -m arc.scripts.pipe_worker --pipe_root {pipe_root} --worker_id "$WORKER_ID"
7577
""",
7678
'sge': """#!/bin/bash -l
7779
#$ -N {name}
80+
#$ -q {queue}
7881
#$ -pe smp {cpus}
7982
#$ -l h_vmem={memory}M
8083
#$ -t 1-{max_task_num}
8184
#$ -o {pipe_root}/out_$SGE_TASK_ID.txt
8285
#$ -e {pipe_root}/err_$SGE_TASK_ID.txt
8386
87+
{env_setup}
8488
WORKER_ID=$SGE_TASK_ID
8589
8690
{python_exe} -m arc.scripts.pipe_worker --pipe_root {pipe_root} --worker_id $WORKER_ID

0 commit comments

Comments
 (0)