From a6d1cb78fe22363b2524ad09802a6433c9216930 Mon Sep 17 00:00:00 2001 From: "Matthew W. Thompson" Date: Thu, 13 Jul 2023 09:17:58 -0500 Subject: [PATCH] Add `requires_openeye` decorators --- .pre-commit-config.yaml | 2 +- openff/bespokefit/executor/utilities/depiction.py | 3 +++ openff/bespokefit/utilities/molecule.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a904853b..c55f50cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: check-yaml - id: debug-statements - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black files: ^openff diff --git a/openff/bespokefit/executor/utilities/depiction.py b/openff/bespokefit/executor/utilities/depiction.py index fe6a3fd8..c0a8422a 100644 --- a/openff/bespokefit/executor/utilities/depiction.py +++ b/openff/bespokefit/executor/utilities/depiction.py @@ -1,11 +1,14 @@ import functools from typing import Optional, Tuple +from openff.utilities.utilities import requires_oe_module + IMAGE_UNAVAILABLE_SVG = """ PreviewUnavailable """ +@requires_oe_module("oechem") def _oe_smiles_to_image(smiles: str, highlight_atoms: Tuple[int]) -> str: from openeye import oechem, oedepict diff --git a/openff/bespokefit/utilities/molecule.py b/openff/bespokefit/utilities/molecule.py index fd0f16bf..42f84d5d 100644 --- a/openff/bespokefit/utilities/molecule.py +++ b/openff/bespokefit/utilities/molecule.py @@ -3,8 +3,10 @@ from openff.toolkit.topology import Molecule from openff.toolkit.utils.exceptions import ToolkitUnavailableException +from openff.utilities.utilities import requires_oe_module +@requires_oe_module("oechem") def _oe_get_atom_symmetries(molecule: Molecule) -> List[int]: from openeye import oechem @@ -31,6 +33,7 @@ def get_atom_symmetries(molecule: Molecule) -> List[int]: return _rd_get_atom_symmetries(molecule) +@requires_oe_module("oechem") def _oe_canonical_atom_order(molecule: Molecule) -> List[int]: from openeye import oechem