Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Call listener when do_replay is True for use_table_listener_hook #313

Merged
merged 4 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/ui/src/deephaven/ui/hooks/use_table_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def use_table_listener(
replay_lock: The lock type used during replay, default is ‘shared’, can also be ‘exclusive’.
"""

if not table.is_refreshing:
# if the table is not refreshing, there is nothing to listen to
if not table.is_refreshing and not do_replay:
# if the table is not refreshing, and is not replaying, there is nothing to listen to
return

def start_listener() -> Callable[[], None]:
Expand Down
29 changes: 28 additions & 1 deletion plugins/ui/test/deephaven/ui/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,27 @@ def _test_table_listener(replayed_table_val=table, listener_val=listener):
if not event.wait(timeout=LISTENER_TIMEOUT):
assert False, "listener was not called"

def verify_table_replayed(self, table):
from deephaven.ui.hooks import use_table_listener
from deephaven.table_listener import TableUpdate

event = threading.Event()

def listener(update: TableUpdate, is_replay: bool) -> None:
nonlocal event
event.set()

def _test_table_listener(replay_table=table, listener_val=listener):
use_table_listener(replay_table, listener_val, do_replay=True)

render_hook(_test_table_listener)

if not event.wait(timeout=LISTENER_TIMEOUT):
assert False, "listener was not called"

def test_table_listener(self):
from deephaven import DynamicTableWriter
from deephaven import DynamicTableWriter, new_table
from deephaven.column import int_col
import deephaven.dtypes as dht

column_definitions = {"Numbers": dht.int32, "Words": dht.string}
Expand All @@ -171,6 +190,14 @@ def test_table_listener(self):

self.verify_table_updated(table_writer, table, (1, "Testing"))

static_table = new_table(
[
int_col("Numbers", [1]),
]
)

self.verify_table_replayed(static_table)

def test_table_data(self):
from deephaven.ui.hooks import use_table_data
from deephaven import new_table
Expand Down
Loading