diff --git a/setup.cfg b/setup.cfg index 77caf02..dae7e69 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ package_dir= =src packages=find_namespace: install_requires = - deephaven-plugin + deephaven-plugin>=0.5.0 plotly include_package_data = True diff --git a/src/deephaven/plugin/plotly/__init__.py b/src/deephaven/plugin/plotly/__init__.py index 7208cef..3b757ca 100644 --- a/src/deephaven/plugin/plotly/__init__.py +++ b/src/deephaven/plugin/plotly/__init__.py @@ -1,8 +1,9 @@ -from deephaven.plugin import Registration +from deephaven.plugin import Registration, Callback from plotly import io as pio __version__ = "0.1.0" + def _init_theme(): # Set the Deephaven style globally from . import theme_deephaven @@ -10,9 +11,10 @@ def _init_theme(): # Disable default renderer to ignore figure.show() pio.renderers.default = None + class PlotlyRegistration(Registration): @classmethod - def register_into(cls, callback: Registration.Callback) -> None: + def register_into(cls, callback: Callback) -> None: _init_theme() from . import figure_type callback.register(figure_type.FigureType) diff --git a/src/deephaven/plugin/plotly/figure_type.py b/src/deephaven/plugin/plotly/figure_type.py index ed4bde7..77d28d0 100644 --- a/src/deephaven/plugin/plotly/figure_type.py +++ b/src/deephaven/plugin/plotly/figure_type.py @@ -1,20 +1,21 @@ from plotly.graph_objects import Figure -from deephaven.plugin.object import Exporter, ObjectType -import json +from deephaven.plugin.object_type import Exporter, FetchOnlyObjectType # Name of the plotly figure object that was exported NAME = "plotly.figure" + def _export_figure(figure): return figure.to_json().encode() -class FigureType(ObjectType): + +class FigureType(FetchOnlyObjectType): @property def name(self) -> str: return NAME - def is_type(self, object) -> bool: - return isinstance(object, Figure) + def is_type(self, obj) -> bool: + return isinstance(obj, Figure) def to_bytes(self, exporter: Exporter, figure: Figure) -> bytes: return _export_figure(figure)