diff --git a/renumics/spotlight/app.py b/renumics/spotlight/app.py index 8b23e08d..377c4424 100644 --- a/renumics/spotlight/app.py +++ b/renumics/spotlight/app.py @@ -312,6 +312,9 @@ def update(self, config: AppConfig) -> None: self._broadcast(RefreshMessage()) self._update_issues() + for plugin in load_plugins(): + plugin.update(self, config) + if not self._startup_complete: self._startup_complete = True self._connection.send({"kind": "startup_complete"}) diff --git a/renumics/spotlight/data_store.py b/renumics/spotlight/data_store.py index ed4f20cd..26a8d3e0 100644 --- a/renumics/spotlight/data_store.py +++ b/renumics/spotlight/data_store.py @@ -47,6 +47,10 @@ def generation_id(self) -> int: def column_names(self) -> List[str]: return self._data_source.column_names + @property + def data_source(self) -> DataSource: + return self._data_source + @property def dtypes(self) -> DTypeMap: return self._dtypes diff --git a/renumics/spotlight/plugin_loader.py b/renumics/spotlight/plugin_loader.py index 6ebfd4e3..770c9185 100644 --- a/renumics/spotlight/plugin_loader.py +++ b/renumics/spotlight/plugin_loader.py @@ -7,12 +7,13 @@ from dataclasses import dataclass from types import ModuleType from pathlib import Path -from typing import Callable, List, Optional +from typing import Any, Callable, List, Optional from fastapi import FastAPI from renumics.spotlight.settings import settings from renumics.spotlight.develop.project import get_project_info from renumics.spotlight.io.path import is_path_relative_to +from renumics.spotlight.app_config import AppConfig import renumics.spotlight_plugins as plugins_namespace @@ -28,6 +29,7 @@ class Plugin: module: ModuleType init: Callable[[], None] activate: Callable[[FastAPI], None] + update: Callable[[FastAPI, AppConfig], None] dev: bool frontend_entrypoint: Optional[Path] @@ -46,14 +48,9 @@ def load_plugins() -> List[Plugin]: if _plugins is not None: return _plugins - def noinit() -> None: + def noop(*_args: Any, **_kwargs: Any) -> None: """ - noop impl for __init__ - """ - - def noactivate(_: FastAPI) -> None: - """ - noop impl for __activate__ + noop impl for plugin hooks """ plugins = {} @@ -73,8 +70,9 @@ def noactivate(_: FastAPI) -> None: plugins[name] = Plugin( name=name, priority=getattr(module, "__priority__", 1000), - init=getattr(module, "__register__", noinit), - activate=getattr(module, "__activate__", noactivate), + init=getattr(module, "__register__", noop), + activate=getattr(module, "__activate__", noop), + update=getattr(module, "__update__", noop), module=module, dev=dev, frontend_entrypoint=main_js if main_js.exists() else None,