Open j-wags opened 5 years ago
Is the main challenge to see which toolkits are registered, which toolkits are used for a given method, or whether a given toolkit has a particular method available?
My original intent was "which toolkits are used for a given method".
That said, I was pretty rushed when I wrote this, so it may not be well thought-through. The only solution I can think of now would be some openforcefield.utils
module-level function. It's not clear to me that it would be superior to a GLOBAL_TOOLKIT_REGISTRY.resolve()
call, especially because it would effectively be a wrapper for that function (except that it would return the ToolkitWrapper
instead of the method)
I find it's easier to design the API if you pitch how you're going to use it.
Do you want to be able to call something like
method = toolkit_registry.resolve_method(method)
or
wrapper = toolkit_registry.resolve_method_supplier(method)
?
wrapper = toolkit_registry.resolve_method_supplier(method)
is what I'm advocating for.
So a possible API would be
class ToolkitRegistry:
def resolve_wrapper(method):
'''
Returns the ToolkitWrapper that would be used to call a given method.
Parameters
----------
method : str
The method name to look up
Returns
-------
wrapper : openforcefield.utils.ToolkitWrapper
The ToolkitWrapper that would be called to perform the method.
The first option you posted (method = toolkit_registry.resolve_method(method)
) actually already exists. https://open-forcefield-toolkit.readthedocs.io/en/topology/api/generated/openforcefield.utils.toolkits.ToolkitRegistry.html#openforcefield.utils.toolkits.ToolkitRegistry.resolve
I came across this wile searching ToolkitRegistry
in the issue tracker. I think this is implemented (although improvements were proposed in #540)?
Currently, the interface to see which toolkits are being used is a bit clunky. The code I sent out to check this is here:
We could think of a better way to do this. Since each function will be resolved independently, and because we kind of hide the fact that
GLOBAL_TOOLKIT_REGISTRY
does the work behind the scenes, something like a cleaner interface toGLOBAL_TOOLKIT_REGISTRY.resolve(method_name)
would be a good solution.