openforcefield / openff-toolkit

The Open Forcefield Toolkit provides implementations of the SMIRNOFF format, parameterization engine, and other tools. Documentation available at http://open-forcefield-toolkit.readthedocs.io
http://openforcefield.org
MIT License
318 stars 92 forks source link

OpenEye license check in OpenEyeToolkitWrapper #1895

Open isty2e opened 4 months ago

isty2e commented 4 months ago

Describe the bug https://github.com/openforcefield/openff-toolkit/blob/fd5a20b6094ac0f64f66510f2791244e9e5ef9b4/openff/toolkit/utils/openeye_wrapper.py#L224

This method detects the presence of OpenEye toolkits licenses by checking if any of toolkit licenses is available. However, the OpenEyeToolkitWrapper requires oechem, oeomega, and oequacpac to function. If the user has at least one of these licenses but not all (e.g, only oechem license) and has OE_LICENSE environment variable set, an exception will occur in runtime.

To Reproduce

Output

  File "/path/to/script.py", line 419, in get_ligand_structure
    ligand_system = force_field.create_openmm_system(off_topology)
  File "/path/to/env/lib/python3.9/site-packages/openff/utilities/utilities.py", line 80, in wrapper
    return function(*args, **kwargs)
  File "/path/to/env/lib/python3.9/site-packages/openff/toolkit/typing/engines/smirnoff/forcefield.py", line 1164, in create_openmm_system
    return self.create_interchange(
  File "/path/to/env/lib/python3.9/site-packages/openff/utilities/utilities.py", line 80, in wrapper
    return function(*args, **kwargs)
  File "/path/to/env/lib/python3.9/site-packages/openff/toolkit/typing/engines/smirnoff/forcefield.py", line 1223, in create_interchange
    return Interchange.from_smirnoff(
  File "/path/to/env/lib/python3.9/site-packages/openff/interchange/components/interchange.py", line 270, in from_smirnoff
    return _create_interchange(
  File "/path/to/env/lib/python3.9/site-packages/openff/interchange/smirnoff/_create.py", line 117, in _create_interchange
    _electrostatics(
  File "/path/to/env/lib/python3.9/site-packages/openff/interchange/smirnoff/_create.py", line 270, in _electrostatics
    "Electrostatics": SMIRNOFFElectrostaticsCollection.create(
  File "/path/to/env/lib/python3.9/site-packages/openff/interchange/smirnoff/_nonbonded.py", line 447, in create
    handler.store_matches(
  File "/path/to/env/lib/python3.9/site-packages/openff/interchange/smirnoff/_nonbonded.py", line 861, in store_matches
    matches, potentials = self._find_reference_matches(
  File "/path/to/env/lib/python3.9/site-packages/openff/interchange/smirnoff/_nonbonded.py", line 716, in _find_reference_matches
    ) = cls._find_charge_model_matches(
  File "/path/to/env/lib/python3.9/site-packages/openff/interchange/smirnoff/_nonbonded.py", line 652, in _find_charge_model_matches
    partial_charges = cls._compute_partial_charges(
  File "/path/to/env/lib/python3.9/site-packages/openff/interchange/smirnoff/_nonbonded.py", line 467, in _compute_partial_charges
    molecule.assign_partial_charges(method)
  File "/path/to/env/lib/python3.9/site-packages/openff/toolkit/topology/molecule.py", line 2607, in assign_partial_charges
    toolkit_registry.call(
  File "/path/to/env/lib/python3.9/site-packages/openff/toolkit/utils/toolkit_registry.py", line 352, in call
    return method(*args, **kwargs)
  File "/path/to/env/lib/python3.9/site-packages/openff/toolkit/utils/openeye_wrapper.py", line 2422, in assign_partial_charges
    self.generate_conformers(
  File "/path/to/env/lib/python3.9/site-packages/openff/toolkit/utils/openeye_wrapper.py", line 2158, in generate_conformers
    traceback.print_stack()
LICENSE: No valid license found for omega
LICENSE: File(s) used: /path/to/oe_license.txt
LICENSE: Closest license failed because:
LICENSE: features
mattwthompson commented 4 months ago

We've run into this before (https://github.com/openforcefield/openff-toolkit/issues/825#issuecomment-769287238) and thought we fixed it (https://github.com/openforcefield/openff-toolkit/pull/850); OpenEyeToolkitWrapper returns True if any of those licenses are found, not requiring all to be found.

There could be a separate interaction between different wrapped calls failing and raising unhandled exceptions (https://github.com/openforcefield/openff-toolkit/issues/1863 a little related; it's possible that using RDKit conformers and Quacpac charges fails since it's not clear that's ever been tested or even that it's possible).

Could you fill out the issue template with a reproducible example that demonstrates how I can trigger the specific failure you're encountering? I have access to an OpenEye license and can mock different modules being licensed or unlicensed.

insukjoung commented 4 months ago

On behalf of my colleague, #1896