toolkit_registry_manager

openff.toolkit.utils.toolkit_registry.toolkit_registry_manager(toolkit_registry: ToolkitRegistry | ToolkitWrapper)[source]

A context manager that temporarily changes the ToolkitWrappers in the GLOBAL_TOOLKIT_REGISTRY. This can be useful in cases where one would otherwise need to otherwise manually specify the use of a specific ToolkitWrapper or ToolkitRegistry repeatedly in a block of code, or in cases where there isn’t another way to switch the ToolkitWrappers used for a particular operation.

Examples

>>> from openff.toolkit import Molecule, RDKitToolkitWrapper, AmberToolsToolkitWrapper
>>> from openff.toolkit.utils import toolkit_registry_manager, ToolkitRegistry
>>> mol = Molecule.from_smiles("CCO")
>>> print(mol.to_smiles()) # This will use the OpenEye backend (if installed and licensed)
[H]C([H])([H])C([H])([H])O[H]
>>> with toolkit_registry_manager(ToolkitRegistry([RDKitToolkitWrapper()])):
...    print(mol.to_smiles())
[H][O][C]([H])([H])[C]([H])([H])[H]