Skip to content

Commit

Permalink
Update deephaven-plugin to latest, fixed API breaking changes
Browse files Browse the repository at this point in the history
Also fixed minor style issues
  • Loading branch information
niloc132 committed Aug 10, 2023
1 parent 0cd5fba commit efbfec2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ package_dir=
=src
packages=find_namespace:
install_requires =
deephaven-plugin
deephaven-plugin>=0.5.0
plotly
include_package_data = True

Expand Down
6 changes: 4 additions & 2 deletions src/deephaven/plugin/plotly/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
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
pio.templates.default = "deephaven"
# 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)
11 changes: 6 additions & 5 deletions src/deephaven/plugin/plotly/figure_type.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit efbfec2

Please sign in to comment.