diff --git a/plugins/plotly-express/src/deephaven/plot/express/deephaven_figure/DeephavenFigure.py b/plugins/plotly-express/src/deephaven/plot/express/deephaven_figure/DeephavenFigure.py index d70828519..1922f141a 100644 --- a/plugins/plotly-express/src/deephaven/plot/express/deephaven_figure/DeephavenFigure.py +++ b/plugins/plotly-express/src/deephaven/plot/express/deephaven_figure/DeephavenFigure.py @@ -560,7 +560,12 @@ def add_figure_to_graph( func: The function to call """ - self._liveness_scope.manage(table) + if isinstance(table, Table) and not table.is_refreshing: + # static tables should not be managed + # check because it doesn't throw an error on first manage attempt, but leads to errors later + pass + else: + self._liveness_scope.manage(table) node = DeephavenFigureNode(self._head_node, exec_ctx, args, table, func) diff --git a/plugins/plotly-express/test/deephaven/plot/express/deephaven_figure/__init__.py b/plugins/plotly-express/test/deephaven/plot/express/deephaven_figure/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/plotly-express/test/deephaven/plot/express/deephaven_figure/test_DeephavenFigure.py b/plugins/plotly-express/test/deephaven/plot/express/deephaven_figure/test_DeephavenFigure.py new file mode 100644 index 000000000..e25f8ba56 --- /dev/null +++ b/plugins/plotly-express/test/deephaven/plot/express/deephaven_figure/test_DeephavenFigure.py @@ -0,0 +1,29 @@ +import unittest + +from ..BaseTest import BaseTestCase + + +class DeephavenFigureTestCase(BaseTestCase): + def test_adding_table(self): + from deephaven import new_table + from deephaven.column import int_col + import src.deephaven.plot.express as dx + from deephaven.execution_context import get_exec_ctx + from deephaven.liveness_scope import liveness_scope + + static_source = new_table([int_col("X", [1, 2, 3])]) + + for _ in range(2): + with liveness_scope(): + filtered = static_source.where("X = 1") + figure = dx.DeephavenFigure() + # if the static memoized table `filtered` is added to the figure's liveness scope + # when it shouldn't be, this will raise an exception on second iteration + figure.add_figure_to_graph( + get_exec_ctx(), {}, filtered, None, lambda: None + ) + del figure + + +if __name__ == "__main__": + unittest.main()