vitessce / vitessce-python

Python API and Jupyter widget for Vitessce
https://python-docs.vitessce.io
MIT License
38 stars 7 forks source link

Define a plugin class/dataclass to couple on_config_change and anywidget.invoke handlers with plugin_esm #347

Closed keller-mark closed 2 months ago

keller-mark commented 4 months ago

Certain types of plugins will entail both custom JS and Python functions that need to work together.

337 documents the support for plugin_esm, but we should add a way to specify both the JS and Python so that users can pull them in together. Unclear exactly what the API should be

class VitesscePlugin:
  plugin_esm: str
  on_config_change: Function
  # everything else: assumed to be needed for .invoke / need to be registered as `@anywidget.command` on VitessceWidget class?

then can just pass an array of VitesscePlugin subclass instances like

vc.widget(plugins=[MyVitesscePlugin()]

keller-mark commented 3 months ago

Optional commands as dictionary of string to function with signature like:

def my_command(widget, plugin, values, buffers):
    new_values = {}
    new_buffers = []
    return new_values, new_buffers

where widget and plugin are self for the Widget and Plugin instances, respectively