Open agoose77 opened 2 weeks ago
Can we auto detect that in the transform and expand plugin.py
to the dict?
e.g.
project:
plugins:
- test.mjs
- plugin.py
Which is basically what you wrote, but slightly nicer UX / overhead for the user. :)
Note that the way you wrote it should also work, as I see now the javascript could also be an executable.
@rowanc1 yes, I think the forward-looking preferred syntax would be the verbose kind. For single strings, we should only support known extensions but IPC plugins don't have a specific extension. If we added support for Python as in #1325, then we'd be able to write
plugins:
- foo.mjs
- bar.py
Otherwise, we expand non-.mjs
plugins to executable
plugins, and then down the road this breaks when we add support for e.g. .py
.
This PR fixes #1298 in a different way to #1325 by adding a new "executable" type of plugin (the approach taken in https://gist.github.com/agoose77/66700b2a172b4c11d4801f742534e4f7). Unlike #1325, this PR adds support for Python via an IPC mechanism (stdout, stdin).
1325 and this PR are not mutually exclusive; #1325 adds support for an in-process Python executor, which supports sharing stateful proxies between JS and Python. This PR, meanwhile, is fully decoupled and allows for further languages. Note that, unlike #1325, we do not vendor Python, so it is possible that users may define plugins whose environment is not sufficiently reproducible and thus see build errors.
To implement such a plugin, the executable needs to support the following invocation modes:
proc
Return the "spec" of the plugin, i.e. the implementation-freeplugin
blockproc --directive <DIRECTIVE>
Execute the implementation of a directive<DIRECTIVE>
proc --role <ROLE>
Execute the implementation of a role<DIRECTIVE>
proc --transform <TRANSFORM>
Execute the implementation of a transform<DIRECTIVE>
whereby the auxillary data for these executions is provided viastdin
, the results read out fromstdout
, and error/debug information read fromstderr
.Right now, I didn't add the
validate
method. We could; it's not much extra work. But do we need it? An example of a directive and transform is given in the docs of this PR.