Skip to content

Commit

Permalink
Merge pull request #185 from TheoChem-VU/184-do-not-run-a-calculation…
Browse files Browse the repository at this point in the history
…-if-its-set-up-failed

184 do not run a calculation if its set up failed
  • Loading branch information
YHordijk authored Mar 25, 2024
2 parents aaaffdf + f4c63ce commit 700e42b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/tcutility/job/adf.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,14 @@ def functional(self, funtional_name: str, dispersion: str = None):
self._functional = functional

if functional == 'r2SCAN-3c' and self._basis_set != 'mTZ2P':
log.warn(f'Switching basis set from {self._basis_set} to mTZ2P for r2SCAN-3c.')
log.info(f'Switching basis set from {self._basis_set} to mTZ2P for r2SCAN-3c.')
self.basis_set('mTZ2P')

if functional == 'SSB-D':
log.error('There are two functionals called SSB-D, please use "GGA:SSB-D" or "MetaGGA:SSB-D".')
return
raise ValueError('There are two functionals called SSB-D, please use "GGA:SSB-D" or "MetaGGA:SSB-D".')

if not data.functionals.get(functional):
log.warn(f'XC-functional {functional} not found. Please ask a TheoCheM developer to add it. Adding functional as LibXC.')
self.settings.input.adf.XC.LibXC = functional
raise ValueError(f'XC-functional {functional} not found.')
else:
func = data.functionals.get(functional)
self.settings.input.adf.update(func.adf_settings)
Expand Down
6 changes: 5 additions & 1 deletion src/tcutility/job/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ def __init__(self, test_mode: bool = False, overwrite: bool = False, wait_for_fi
def __enter__(self):
return self

def __exit__(self, *args):
def __exit__(self, exc_type, exc_value, exc_tb):
if exc_type:
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
log.error(f'Job set-up failed with exception: {exc_type.__name__}({exc_value}) in File "{fname}", line {exc_tb.tb_lineno}.')
return True
self.run()

def can_skip(self):
Expand Down

0 comments on commit 700e42b

Please sign in to comment.