From de627ea2dbb7ca7c62729b8f38bd48cda5a5301f Mon Sep 17 00:00:00 2001 From: Joe Numainville Date: Fri, 23 Feb 2024 10:47:55 -0600 Subject: [PATCH 1/3] wip --- plugins/ui/src/deephaven/ui/hooks/use_table_listener.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/ui/src/deephaven/ui/hooks/use_table_listener.py b/plugins/ui/src/deephaven/ui/hooks/use_table_listener.py index a1ba05929..40fad4ce6 100644 --- a/plugins/ui/src/deephaven/ui/hooks/use_table_listener.py +++ b/plugins/ui/src/deephaven/ui/hooks/use_table_listener.py @@ -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]: From 69a4900765f1711e619f0f6ffcd4750e52c17bea Mon Sep 17 00:00:00 2001 From: Joe Numainville Date: Fri, 23 Feb 2024 12:15:08 -0600 Subject: [PATCH 2/3] wip --- plugins/ui/test/deephaven/ui/test_hooks.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugins/ui/test/deephaven/ui/test_hooks.py b/plugins/ui/test/deephaven/ui/test_hooks.py index 1277e2e70..782155795 100644 --- a/plugins/ui/test/deephaven/ui/test_hooks.py +++ b/plugins/ui/test/deephaven/ui/test_hooks.py @@ -158,6 +158,24 @@ def _test_table_listener(replayed_table_val=table, listener_val=listener): if not event.wait(timeout=1.0): 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) + + render_hook(_test_table_listener) + + if not event.wait(timeout=1.0): + assert False, "listener was not called" + def test_table_listener(self): from deephaven import DynamicTableWriter import deephaven.dtypes as dht @@ -169,6 +187,8 @@ def test_table_listener(self): self.verify_table_updated(table_writer, table, (1, "Testing")) + self.verify_table_replayed(table) + def test_table_data(self): from deephaven.ui.hooks import use_table_data from deephaven import new_table From 072b681c776de624ae5c62a9086245344d320ccd Mon Sep 17 00:00:00 2001 From: Joe Numainville Date: Fri, 23 Feb 2024 12:25:29 -0600 Subject: [PATCH 3/3] test --- plugins/ui/test/deephaven/ui/test_hooks.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/ui/test/deephaven/ui/test_hooks.py b/plugins/ui/test/deephaven/ui/test_hooks.py index ff365b9d1..3fdc94a8c 100644 --- a/plugins/ui/test/deephaven/ui/test_hooks.py +++ b/plugins/ui/test/deephaven/ui/test_hooks.py @@ -171,15 +171,16 @@ def listener(update: TableUpdate, is_replay: bool) -> None: event.set() def _test_table_listener(replay_table=table, listener_val=listener): - use_table_listener(replay_table, listener_val) + use_table_listener(replay_table, listener_val, do_replay=True) render_hook(_test_table_listener) - if not event.wait(timeout=1.0): + 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} @@ -189,7 +190,13 @@ def test_table_listener(self): self.verify_table_updated(table_writer, table, (1, "Testing")) - self.verify_table_replayed(table) + 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