Skip to content

Commit

Permalink
Add dependency on deephaven-plugin (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith authored Jan 10, 2022
1 parent 3121f91 commit 3b54869
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@ jobs:
run: python -m pip install --upgrade setuptools wheel build

- name: Build wheel
run: python -m build --wheel
run: python -m build

- name: Upload dist
uses: actions/upload-artifact@v2
with:
name: dist
path: dist/
if-no-files-found: error

- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To create your build / development environment:
```sh
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip setuptools build matplotlib
pip install --upgrade pip setuptools build deephaven-plugin matplotlib
```

To build:
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ package_dir=
=src
packages=find_namespace:
install_requires =
deephaven-plugin
matplotlib

[options.packages.find]
where=src

[options.entry_points]
deephaven.plugin =
register_into = deephaven.plugin.matplotlib:register_into
registration_cls = deephaven.plugin.matplotlib:MatplotlibRegistration
13 changes: 7 additions & 6 deletions src/deephaven/plugin/matplotlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
__version__ = "0.0.1.dev2"
from deephaven.plugin import Registration

def register_into(callback):
register_object_types_into(callback)
__version__ = "0.0.1.dev4"

def register_object_types_into(callback):
from . import figure_type
callback.register_object_type(figure_type.FigureType())
class MatplotlibRegistration(Registration):
@classmethod
def register_into(cls, callback: Registration.Callback) -> None:
from . import figure_type
callback.register(figure_type.FigureType)
5 changes: 3 additions & 2 deletions src/deephaven/plugin/matplotlib/figure_type.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from io import BytesIO
from matplotlib.figure import Figure
from deephaven.plugin.object import Exporter, ObjectType

NAME = "matplotlib.figure.Figure"

class FigureType:
class FigureType(ObjectType):
@property
def name(self) -> str:
return NAME

def is_type(self, object) -> bool:
return isinstance(object, Figure)

def to_bytes(self, exporter, figure: Figure) -> bytes:
def to_bytes(self, exporter: Exporter, figure: Figure) -> bytes:
buf = BytesIO()
figure.savefig(buf, format='PNG')
return buf.getvalue()

0 comments on commit 3b54869

Please sign in to comment.