Skip to content

Commit 2ef5e15

Browse files
committed
.
1 parent 3ef6716 commit 2ef5e15

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

arc/scheduler_test.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
This module contains unit tests for the arc.scheduler module
66
"""
77

8+
import math
89
import unittest
910
from unittest.mock import MagicMock, patch
1011
import os
@@ -18,6 +19,7 @@
1819
from arc.plotter import save_conformers_file
1920
from arc.scheduler import Scheduler, species_has_freq, species_has_geo, species_has_sp, species_has_sp_and_freq
2021
from arc.imports import settings
22+
from arc.settings.settings import input_filenames
2123
from arc.reaction import ARCReaction
2224
from arc.species.converter import str_to_xyz
2325
from arc.species.species import ARCSpecies, TSGuess
@@ -865,6 +867,63 @@ def test_troubleshoot_ess_orca_increases_total_memory_when_not_capped(self):
865867
self.assertEqual(kwargs['cpu_cores'], 24)
866868
self.assertEqual(kwargs['memory'], 250)
867869
self.assertIn('memory', kwargs['ess_trsh_methods'])
870+
871+
def test_troubleshoot_ess_orca_rewrites_input_with_reduced_cores_and_higher_maxcore(self):
872+
"""Test ORCA troubleshooting end-to-end from failure to rewritten input file."""
873+
label = 'methylamine'
874+
self.sched1.output = dict()
875+
self.sched1.initialize_output_dict()
876+
877+
job = MagicMock()
878+
job.job_name = 'sp_a205'
879+
job.job_type = 'sp'
880+
job.job_adapter = 'orca'
881+
job.level = Level(repr={'method': 'dlpno-ccsd(T)'})
882+
job.server = 'server1'
883+
job.fine = True
884+
job.cpu_cores = 32
885+
job.job_memory_gb = 250
886+
job.ess_trsh_methods = list()
887+
job.torsions = None
888+
job.dihedrals = None
889+
job.directed_scan_type = None
890+
job.rotor_index = None
891+
job.job_status = ['done', {'status': 'errored',
892+
'keywords': ['MDCI', 'Memory', 'max_total_job_memory'],
893+
'error': 'Orca suggests to increase per cpu core memory to 10218 MB.',
894+
'line': 'Please increase MaxCore'}]
895+
896+
with patch.object(self.sched1, 'run_job') as mock_run_job, \
897+
patch.object(self.sched1, 'save_restart_dict'):
898+
self.sched1.troubleshoot_ess(label=label, job=job, level_of_theory=job.level)
899+
900+
kwargs = mock_run_job.call_args.kwargs
901+
temp_project_dir = os.path.join(ARC_TESTING_PATH, 'test_scheduler_orca_trsh_input')
902+
try:
903+
rerun_job = job_factory(job_adapter=kwargs['job_adapter'],
904+
project='project_test_scheduler_orca_trsh_input',
905+
ess_settings=self.ess_settings,
906+
species=[self.spc1],
907+
xyz=self.spc1.get_xyz(),
908+
job_type=kwargs['job_type'],
909+
level=kwargs['level_of_theory'],
910+
project_directory=temp_project_dir,
911+
cpu_cores=kwargs['cpu_cores'],
912+
job_memory_gb=kwargs['memory'],
913+
ess_trsh_methods=kwargs['ess_trsh_methods'],
914+
execution_type='incore',
915+
fine=kwargs['fine'],
916+
server=job.server,
917+
testing=True)
918+
rerun_job.write_input_file()
919+
with open(os.path.join(rerun_job.local_path, input_filenames[rerun_job.job_adapter]), 'r') as f:
920+
content = f.read()
921+
original_maxcore = math.ceil(rerun_job.job_memory_gb * 1024 / job.cpu_cores)
922+
self.assertIn('%pal nprocs 24 end', content)
923+
self.assertIn(f'%maxcore {rerun_job.input_file_memory}', content)
924+
self.assertGreater(rerun_job.input_file_memory, original_maxcore)
925+
finally:
926+
shutil.rmtree(temp_project_dir, ignore_errors=True)
868927

869928
@patch('arc.scheduler.Scheduler.run_opt_job')
870929
def test_switch_ts_cleanup(self, mock_run_opt):

0 commit comments

Comments
 (0)