Skip to content

Commit

Permalink
Support HoloViews version
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed Jun 14, 2024
1 parent 92d2c5e commit 6adc3f1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion streamjoy/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def get_first(iterable):

def get_result(future: Future) -> Any:
if isinstance(future, Future):
return future.result()
return future.result(timeout=30)
elif hasattr(future, "compute"):
return future.compute()
else:
Expand Down
15 changes: 9 additions & 6 deletions streamjoy/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
from packaging import version
from inspect import isgenerator
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable
Expand Down Expand Up @@ -399,12 +400,14 @@ def _select_element(hv_obj, key):
clims=clims,
)

if kwargs.get("processes"):
logging.warning(
"HoloViews rendering does not support processes; "
"setting processes=False."
)
kwargs["processes"] = False
if version.parse(hv.__version__) < version.parse("1.19.0"):
if kwargs.get("processes"):
logging.warning(
"HoloViews<1.19.0 rendering does not support processes; "
"setting processes=False; to use processes, upgrade wih "
"`pip install 'holoviews>=1.19.0'`"
)
kwargs["processes"] = False
return Serialized(resources, renderer, renderer_iterables, renderer_kwargs, kwargs)


Expand Down
11 changes: 6 additions & 5 deletions streamjoy/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ def _open_buffer(
"""
], # noqa: E501
)
player = pn.widgets.Player(
self._player = pn.widgets.Player(
name="Time",
start=0,
value=0,
Expand All @@ -1124,8 +1124,8 @@ def _open_buffer(
"""
],
)
player.jslink(tabs, value="active", bidirectional=True)
self._column.objects = [tabs, player]
self._player.jslink(tabs, value="active", bidirectional=True)
self._column.objects = [tabs, self._player]
yield tabs
image = tabs.objects[0]
width = image.object.width
Expand All @@ -1136,7 +1136,7 @@ def _open_buffer(
width=width + 50,
height=height,
)
player.param.update(
self._player.param.update(
width=width,
end=len(tabs) - 1,
)
Expand All @@ -1151,7 +1151,7 @@ def _open_buffer(
max_height=int(height * 1.5),
sizing_mode=sizing_mode,
)
player.param.update(
self._player.param.update(
max_height=150,
max_width=450,
sizing_mode=sizing_mode,
Expand Down Expand Up @@ -1216,6 +1216,7 @@ def _write_images(self, buf: pn.Tabs, images: list[Future], **write_kwargs) -> N
self.fps,
**write_kwargs,
)
self._player.end = len(buf)
del image

def write(
Expand Down
1 change: 1 addition & 0 deletions streamjoy/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def wrapped(*args, **kwargs) -> Path | BytesIO:
import holoviews as hv

backend = kwargs.get("backend", hv.Store.current_backend)
hv.extension(backend)
output = renderer(*args, **kwargs)

hv_obj = output
Expand Down

0 comments on commit 6adc3f1

Please sign in to comment.