From 4eaef2041329ddba2fa0e8b7e851f60eca18d0f1 Mon Sep 17 00:00:00 2001 From: Filippo Bigi <98903385+frostedoyster@users.noreply.github.com> Date: Sat, 2 Nov 2024 16:45:18 +0100 Subject: [PATCH] Prevent new `xtb` module from crashing simulations (#389) * Update xtb.py * Smarter import error --- drivers/py/pes/xtb.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/py/pes/xtb.py b/drivers/py/pes/xtb.py index c2b7947fd..144a07c67 100644 --- a/drivers/py/pes/xtb.py +++ b/drivers/py/pes/xtb.py @@ -13,10 +13,9 @@ try: import tblite.interface as tb -except ImportError as e: - raise ModuleNotFoundError( - "Could not find tblite for xtb driver. Please install tblite-python with mamba" - ) from e +except ImportError: + tb = None + __DRIVER_NAME__ = "xtb" __DRIVER_CLASS__ = "TBLiteDriver" @@ -31,6 +30,12 @@ def __init__( verbose=False, ): """Initialized dummy drivers""" + + if tb is None: + raise ModuleNotFoundError( + "Could not find tblite for xtb driver. Please install tblite-python with mamba" + ) + config = json.loads(args) try: self.method = config["method"]