From 68359cfd13fa1f590249ccf2c36a060239f683b1 Mon Sep 17 00:00:00 2001 From: appel_c Date: Mon, 14 Apr 2025 14:01:23 +0200 Subject: [PATCH] wip add debug loggin in async waveform test --- bec_widgets/widgets/plots/waveform/waveform.py | 13 +++++++------ tests/end-2-end/test_plotting_framework_e2e.py | 11 +++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bec_widgets/widgets/plots/waveform/waveform.py b/bec_widgets/widgets/plots/waveform/waveform.py index 65928963..fc379377 100644 --- a/bec_widgets/widgets/plots/waveform/waveform.py +++ b/bec_widgets/widgets/plots/waveform/waveform.py @@ -1224,14 +1224,15 @@ class Waveform(PlotBase): data_plot_y = data_plot_y[-1, :] else: x_data, y_data = curve.get_data() - logger.warning( - f"Async data for curve {curve.name()}, shape: ({x_data.shape}, {y_data.shape}) (x,y)" - ) + if y_data is not None: + logger.warning( + f"Async data for curve {curve.name()}, shape: ({x_data.shape}, {y_data.shape}) (x,y)" + ) data_plot_y = np.hstack((y_data, data_plot_y)) - logger.warning( - f"Async data for curve {curve.name()}, shape: {data_plot_y.shape} (y)" - ) + logger.warning( + f"Async data for curve {curve.name()}, shape: {data_plot_y.shape} (y)" + ) # Add slice if instruction == "add_slice": current_slice_id = metadata.get("async_update", {}).get("index") diff --git a/tests/end-2-end/test_plotting_framework_e2e.py b/tests/end-2-end/test_plotting_framework_e2e.py index f9dd7f2e..aecf87fa 100644 --- a/tests/end-2-end/test_plotting_framework_e2e.py +++ b/tests/end-2-end/test_plotting_framework_e2e.py @@ -139,6 +139,17 @@ def test_async_plotting(qtbot, bec_client_lib, connected_client_gui_obj): qtbot.waitUntil(_wait_for_scan_in_history, timeout=7000) # Get all data waveform_data = client.history[-1].devices.waveform.waveform_waveform.read()["value"] + + # Wait for data to be plotted, qtloop could lag behind the server + def _wait_for_plot(): + _, y_data = curve.get_data() + if y_data is None: + return False + # Check if the data is not empty + return len(y_data) == len(waveform_data) + + qtbot.waitUntil(_wait_for_plot, timeout=7000) + # check plotted data x_data, y_data = curve.get_data() assert np.array_equal(x_data, np.linspace(0, len(y_data) - 1, len(y_data)))