Writing an editor plugin¶
An editor backend is what nf-meta editor --editor <name> launches. This walks through adding
one as an installable plugin. See BaseEditor for the full contract.
1. Subclass BaseEditor¶
# my_editor_package/editor.py
from nf_meta.editor import BaseEditor
class MyEditor(BaseEditor):
EDITOR_NAME = "my-editor"
def start(self) -> None:
... # block until the user is done editing
EDITOR_NAMEis required. Defining it registers the class (viaBaseEditor.__init_subclass__) and is the string users pass to--editor.- Don't override
__init__.self.options(anEditorOptions) is already set; readself.options.host/.portfrom there if your backend serves over HTTP. start()should block until the user is finished (the built-inBrowserEditorruns its server synchronously in the calling thread). It isn't expected to return while editing is still in progress.
2. Advertise it as a plugin¶
nf-meta discovers editor plugins via the nf_meta.editors entry-point group:
Once installed alongside nf-meta, my-editor appears in nf-meta editor --editor without any
change to nf-meta itself.
3. Verify¶
pip install -e . # or however your plugin package installs
nf-meta editor --editor my-editor metapipeline.yaml
As with runner plugins, a plugin module that fails to import is skipped with a logged warning
rather than a hard failure. Check that first if my-editor doesn't show up as a choice.