Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove boilerplate for plugin instantiation #78

Open
eirrgang opened this issue May 29, 2018 · 1 comment
Open

Remove boilerplate for plugin instantiation #78

eirrgang opened this issue May 29, 2018 · 1 comment
Labels
task Task in support of a larger issue

Comments

@eirrgang
Copy link
Collaborator

eirrgang commented May 29, 2018

The Builder stuff in the sample_restraint doesn't belong there. It needs to be removed to a gmxapi feature (provided headers) and greatly improved. It will become a configurable Director to construct the part of the Session corresponding to the plugin. Client code will configure it with available inputs, outputs, and parameters with pybind-like syntax. Relates to #44 but does not need to wait for resolution to that issue to simplify sample_restraint. Relates to #47

The long term solution to all things surrounding the plugin environment is basically this:

  • plugin code uses Session resources for input, output, supporting operations, and state data
  • plugin developer just writes functions (not classes) and defines all of the input, output, and state through descriptive templating mechanisms (inspired by pybind and boost)

In addition to (hopefully) simplifying the development environment a bit, we can simultaneously address aspects of other issues, like #36, #40, #69.

We can implement this one part at a time, starting with state data. By storing state data in an object received from the Session, we can eliminate private data members and automatically checkpoint everything about a plugin. There are several optimizations that will be easier to make, but one potential performance challenge is the dichotomy of type safety and custom data structures.

We can consider less type safety, run-time type information, or building more templated code in the plugin.

Regardless, I think the plugin developer interface is the same, so hopefully if we choose wrong we only have to ask developers to update headers and recompile.

@eirrgang
Copy link
Collaborator Author

eirrgang commented Jul 3, 2018

The resources a plugin receives will either have to be templated on the plugin or have a whole lot of casting and/or run-time type stuff, I think, so I'm going to first explore templating. The early result will look like I am replacing the class that the developer previously defined with a class I cobble together with templating, I expect.

  • developer defines a struct to hold their state. The types it can hold are limited to types our API knows how to serialize.
  • developer writes the functions they want called. State variables are instead accessed through a member (with the struct type) of a (templated) resources argument passed in.
  • developer expresses a template to connect the pieces.
  • developer calls functions on the resulting object for each member of the state data structure to declare their keyword name, type, behavior, and initialization.

I don't know how to check for uninitialized struct members in this case. We might be able to build up a constructor call that would only compile if we are able to use the automatic POD aggregate constructor.

It isn't worth conjecturing further until I experiment a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task Task in support of a larger issue
Projects
None yet
Development

No branches or pull requests

1 participant