From 008a33a9b192473cc58e90cd6d98c5bcb5f7b8c0 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Mon, 1 Jul 2024 13:33:55 +0200 Subject: [PATCH] fix(figure): API cleanup --- bec_widgets/cli/client.py | 168 +++++------------- .../jupyter_console/jupyter_console_window.py | 8 +- bec_widgets/utils/bec_connector.py | 20 +-- bec_widgets/widgets/dock/dock.py | 4 +- bec_widgets/widgets/dock/dock_area.py | 4 +- bec_widgets/widgets/figure/figure.py | 9 +- .../widgets/figure/plots/image/image.py | 8 +- .../widgets/figure/plots/image/image_item.py | 4 +- .../figure/plots/motor_map/motor_map.py | 8 +- bec_widgets/widgets/figure/plots/plot_base.py | 2 +- .../widgets/figure/plots/waveform/waveform.py | 7 +- .../figure/plots/waveform/waveform_curve.py | 4 +- bec_widgets/widgets/ring_progress_bar/ring.py | 6 +- .../ring_progress_bar/ring_progress_bar.py | 6 +- tests/end-2-end/test_bec_dock_rpc_e2e.py | 32 ++-- tests/end-2-end/test_bec_figure_rpc_e2e.py | 10 +- tests/end-2-end/test_rpc_register_e2e.py | 14 +- tests/unit_tests/test_bec_motor_map.py | 2 +- 18 files changed, 110 insertions(+), 206 deletions(-) diff --git a/bec_widgets/cli/client.py b/bec_widgets/cli/client.py index 8fbba771..ee06df7d 100644 --- a/bec_widgets/cli/client.py +++ b/bec_widgets/cli/client.py @@ -41,14 +41,14 @@ class BECCurve(RPCBase): @property @rpc_call - def rpc_id(self) -> "str": + def _rpc_id(self) -> "str": """ Get the RPC ID of the widget. """ @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -162,7 +162,7 @@ class BECCurve(RPCBase): class BECDock(RPCBase): @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -172,7 +172,7 @@ class BECDock(RPCBase): @property @rpc_call - def rpc_id(self) -> "str": + def _rpc_id(self) -> "str": """ Get the RPC ID of the widget. """ @@ -290,7 +290,7 @@ class BECDock(RPCBase): class BECDockArea(RPCBase, BECGuiClientMixin): @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -398,7 +398,7 @@ class BECDockArea(RPCBase, BECGuiClientMixin): """ @rpc_call - def get_all_rpc(self) -> "dict": + def _get_all_rpc(self) -> "dict": """ Get all registered RPC objects. """ @@ -417,14 +417,14 @@ class BECDockArea(RPCBase, BECGuiClientMixin): class BECFigure(RPCBase): @property @rpc_call - def rpc_id(self) -> "str": + def _rpc_id(self) -> "str": """ Get the RPC ID of the widget. """ @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -432,6 +432,12 @@ class BECFigure(RPCBase): dict: The configuration of the widget. """ + @rpc_call + def _get_all_rpc(self) -> "dict": + """ + Get all registered RPC objects. + """ + @rpc_call def axes(self, row: "int", col: "int") -> "BECPlotBase": """ @@ -607,12 +613,6 @@ class BECFigure(RPCBase): Clear all widgets from the figure and reset to default state """ - @rpc_call - def get_all_rpc(self) -> "dict": - """ - Get all registered RPC objects. - """ - @property @rpc_call def widget_list(self) -> "list[BECPlotBase]": @@ -626,14 +626,14 @@ class BECFigure(RPCBase): class BECImageItem(RPCBase): @property @rpc_call - def rpc_id(self) -> "str": + def _rpc_id(self) -> "str": """ Get the RPC ID of the widget. """ @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -780,14 +780,14 @@ class BECImageItem(RPCBase): class BECImageShow(RPCBase): @property @rpc_call - def rpc_id(self) -> "str": + def _rpc_id(self) -> "str": """ Get the RPC ID of the widget. """ @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -807,28 +807,6 @@ class BECImageShow(RPCBase): BECImageItem: The image object. """ - @rpc_call - def get_image_config(self, image_id, dict_output: "bool" = True) -> "ImageItemConfig | dict": - """ - Get the configuration of the image. - - Args: - image_id(str): The ID of the image. - dict_output(bool): Whether to return the configuration as a dictionary. Defaults to True. - - Returns: - ImageItemConfig|dict: The configuration of the image. - """ - - @rpc_call - def get_image_dict(self) -> "dict[str, dict[str, BECImageItem]]": - """ - Get all images. - - Returns: - dict[str, dict[str, BECImageItem]]: The dictionary of images. - """ - @rpc_call def add_monitor_image( self, @@ -995,15 +973,6 @@ class BECImageShow(RPCBase): name(str): The name of the image. If None, apply to all images. """ - @rpc_call - def toggle_threading(self, use_threading: "bool"): - """ - Toggle threading for the widgets postprocessing and updating. - - Args: - use_threading(bool): Whether to use threading. - """ - @rpc_call def set(self, **kwargs) -> "None": """ @@ -1135,28 +1104,18 @@ class BECImageShow(RPCBase): list[BECImageItem]: The list of images. """ - @rpc_call - def apply_config(self, config: "dict | SubplotConfig"): - """ - Apply the configuration to the 1D waveform widget. - - Args: - config(dict|SubplotConfig): Configuration settings. - replot_last_scan(bool, optional): If True, replot the last scan. Defaults to False. - """ - class BECMotorMap(RPCBase): @property @rpc_call - def rpc_id(self) -> "str": + def _rpc_id(self) -> "str": """ Get the RPC ID of the widget. """ @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -1243,20 +1202,11 @@ class BECMotorMap(RPCBase): Remove the plot widget from the figure. """ - @rpc_call - def apply_config(self, config: "dict | MotorMapConfig"): - """ - Apply the config to the motor map. - - Args: - config(dict|MotorMapConfig): Config to be applied. - """ - class BECPlotBase(RPCBase): @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -1399,7 +1349,7 @@ class BECPlotBase(RPCBase): class BECQueue(RPCBase): @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -1408,7 +1358,7 @@ class BECQueue(RPCBase): """ @rpc_call - def get_all_rpc(self) -> "dict": + def _get_all_rpc(self) -> "dict": """ Get all registered RPC objects. """ @@ -1417,7 +1367,7 @@ class BECQueue(RPCBase): class BECStatusBox(RPCBase): @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -1426,7 +1376,7 @@ class BECStatusBox(RPCBase): """ @rpc_call - def get_all_rpc(self) -> "dict": + def _get_all_rpc(self) -> "dict": """ Get all registered RPC objects. """ @@ -1435,14 +1385,14 @@ class BECStatusBox(RPCBase): class BECWaveform(RPCBase): @property @rpc_call - def rpc_id(self) -> "str": + def _rpc_id(self) -> "str": """ Get the RPC ID of the widget. """ @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -1567,28 +1517,6 @@ class BECWaveform(RPCBase): BECCurve: The curve object. """ - @rpc_call - def get_curve_config(self, curve_id: "str", dict_output: "bool" = True) -> "CurveConfig | dict": - """ - Get the configuration of a curve by its ID. - - Args: - curve_id(str): ID of the curve. - - Returns: - CurveConfig|dict: Configuration of the curve. - """ - - @rpc_call - def apply_config(self, config: "dict | SubplotConfig", replot_last_scan: "bool" = False): - """ - Apply the configuration to the 1D waveform widget. - - Args: - config(dict|SubplotConfig): Configuration settings. - replot_last_scan(bool, optional): If True, replot the last scan. Defaults to False. - """ - @rpc_call def get_all_data(self, output: "Literal['dict', 'pandas']" = "dict") -> "dict | pd.DataFrame": """ @@ -1732,21 +1660,11 @@ class BECWaveform(RPCBase): size(int): Font size of the legend. """ - @rpc_call - def apply_config(self, config: "dict | SubplotConfig", replot_last_scan: "bool" = False): - """ - Apply the configuration to the 1D waveform widget. - - Args: - config(dict|SubplotConfig): Configuration settings. - replot_last_scan(bool, optional): If True, replot the last scan. Defaults to False. - """ - class DeviceComboBox(RPCBase): @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -1755,7 +1673,7 @@ class DeviceComboBox(RPCBase): """ @rpc_call - def get_all_rpc(self) -> "dict": + def _get_all_rpc(self) -> "dict": """ Get all registered RPC objects. """ @@ -1764,7 +1682,7 @@ class DeviceComboBox(RPCBase): class DeviceInputBase(RPCBase): @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -1773,7 +1691,7 @@ class DeviceInputBase(RPCBase): """ @rpc_call - def get_all_rpc(self) -> "dict": + def _get_all_rpc(self) -> "dict": """ Get all registered RPC objects. """ @@ -1782,7 +1700,7 @@ class DeviceInputBase(RPCBase): class DeviceLineEdit(RPCBase): @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -1791,7 +1709,7 @@ class DeviceLineEdit(RPCBase): """ @rpc_call - def get_all_rpc(self) -> "dict": + def _get_all_rpc(self) -> "dict": """ Get all registered RPC objects. """ @@ -1799,21 +1717,21 @@ class DeviceLineEdit(RPCBase): class Ring(RPCBase): @rpc_call - def get_all_rpc(self) -> "dict": + def _get_all_rpc(self) -> "dict": """ Get all registered RPC objects. """ @property @rpc_call - def rpc_id(self) -> "str": + def _rpc_id(self) -> "str": """ Get the RPC ID of the widget. """ @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -1899,21 +1817,21 @@ class Ring(RPCBase): class RingProgressBar(RPCBase): @rpc_call - def get_all_rpc(self) -> "dict": + def _get_all_rpc(self) -> "dict": """ Get all registered RPC objects. """ @property @rpc_call - def rpc_id(self) -> "str": + def _rpc_id(self) -> "str": """ Get the RPC ID of the widget. """ @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -2079,7 +1997,7 @@ class RingProgressBar(RPCBase): class ScanControl(RPCBase): @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -2088,7 +2006,7 @@ class ScanControl(RPCBase): """ @rpc_call - def get_all_rpc(self) -> "dict": + def _get_all_rpc(self) -> "dict": """ Get all registered RPC objects. """ @@ -2097,7 +2015,7 @@ class ScanControl(RPCBase): class StopButton(RPCBase): @property @rpc_call - def config_dict(self) -> "dict": + def _config_dict(self) -> "dict": """ Get the configuration of the widget. @@ -2106,7 +2024,7 @@ class StopButton(RPCBase): """ @rpc_call - def get_all_rpc(self) -> "dict": + def _get_all_rpc(self) -> "dict": """ Get all registered RPC objects. """ diff --git a/bec_widgets/examples/jupyter_console/jupyter_console_window.py b/bec_widgets/examples/jupyter_console/jupyter_console_window.py index 376ae984..9bac8588 100644 --- a/bec_widgets/examples/jupyter_console/jupyter_console_window.py +++ b/bec_widgets/examples/jupyter_console/jupyter_console_window.py @@ -98,14 +98,14 @@ class JupyterConsoleWindow(QWidget): # pragma: no cover: self.w3.set_y_label("Y") # Configs to try to pass - self.w1_c = self.w1.config_dict - self.w2_c = self.w2.config_dict - self.w3_c = self.w3.config_dict + self.w1_c = self.w1._config_dict + self.w2_c = self.w2._config_dict + self.w3_c = self.w3._config_dict # curves for w1 self.c1 = self.w1.get_config() - self.fig_c = self.figure.config_dict + self.fig_c = self.figure._config_dict def _init_dock(self): diff --git a/bec_widgets/utils/bec_connector.py b/bec_widgets/utils/bec_connector.py index b4b8e1f1..9a1a07c7 100644 --- a/bec_widgets/utils/bec_connector.py +++ b/bec_widgets/utils/bec_connector.py @@ -66,7 +66,7 @@ class Worker(QRunnable): class BECConnector: """Connection mixin class for all BEC widgets, to handle BEC client and device manager""" - USER_ACCESS = ["config_dict", "get_all_rpc"] + USER_ACCESS = ["_config_dict", "_get_all_rpc"] def __init__(self, client=None, config: ConnectionConfig = None, gui_id: str = None): # BEC related connections @@ -130,23 +130,23 @@ class BECConnector: self._thread_pool.start(worker) return worker - def get_all_rpc(self) -> dict: + def _get_all_rpc(self) -> dict: """Get all registered RPC objects.""" all_connections = self.rpc_register.list_all_connections() return dict(all_connections) @property - def rpc_id(self) -> str: + def _rpc_id(self) -> str: """Get the RPC ID of the widget.""" return self.gui_id - @rpc_id.setter - def rpc_id(self, rpc_id: str) -> None: + @_rpc_id.setter + def _rpc_id(self, rpc_id: str) -> None: """Set the RPC ID of the widget.""" self.gui_id = rpc_id @property - def config_dict(self) -> dict: + def _config_dict(self) -> dict: """ Get the configuration of the widget. @@ -155,8 +155,8 @@ class BECConnector: """ return self.config.model_dump() - @config_dict.setter - def config_dict(self, config: BaseModel) -> None: + @_config_dict.setter + def _config_dict(self, config: BaseModel) -> None: """ Get the configuration of the widget. @@ -211,13 +211,13 @@ class BECConnector: gui(bool): If True, use the GUI dialog to save the configuration file. """ if gui is True: - save_yaml_gui(self, self.config_dict) + save_yaml_gui(self, self._config_dict) else: if path is None: path = os.getcwd() file_path = os.path.join(path, f"{self.__class__.__name__}_config.yaml") - save_yaml(file_path, self.config_dict) + save_yaml(file_path, self._config_dict) @pyqtSlot(str) def set_gui_id(self, gui_id: str) -> None: diff --git a/bec_widgets/widgets/dock/dock.py b/bec_widgets/widgets/dock/dock.py index 38520f54..e1028af2 100644 --- a/bec_widgets/widgets/dock/dock.py +++ b/bec_widgets/widgets/dock/dock.py @@ -26,8 +26,8 @@ class DockConfig(ConnectionConfig): class BECDock(BECConnector, Dock): USER_ACCESS = [ - "config_dict", - "rpc_id", + "_config_dict", + "_rpc_id", "widget_list", "show_title_bar", "hide_title_bar", diff --git a/bec_widgets/widgets/dock/dock_area.py b/bec_widgets/widgets/dock/dock_area.py index 8bec8366..8ff00442 100644 --- a/bec_widgets/widgets/dock/dock_area.py +++ b/bec_widgets/widgets/dock/dock_area.py @@ -23,7 +23,7 @@ class DockAreaConfig(ConnectionConfig): class BECDockArea(BECConnector, DockArea): USER_ACCESS = [ - "config_dict", + "_config_dict", "panels", "save_state", "remove_dock", @@ -32,7 +32,7 @@ class BECDockArea(BECConnector, DockArea): "clear_all", "detach_dock", "attach_all", - "get_all_rpc", + "_get_all_rpc", "temp_areas", ] diff --git a/bec_widgets/widgets/figure/figure.py b/bec_widgets/widgets/figure/figure.py index 255d74d4..00eb8baa 100644 --- a/bec_widgets/widgets/figure/figure.py +++ b/bec_widgets/widgets/figure/figure.py @@ -110,8 +110,9 @@ class WidgetHandler: class BECFigure(BECConnector, pg.GraphicsLayoutWidget): USER_ACCESS = [ - "rpc_id", - "config_dict", + "_rpc_id", + "_config_dict", + "_get_all_rpc", "axes", "widgets", "plot", @@ -121,11 +122,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget): "change_layout", "change_theme", "clear_all", - "get_all_rpc", "widget_list", - # "apply_config", - # "save_config", - # "load_config", ] subplot_map = { "PlotBase": BECPlotBase, diff --git a/bec_widgets/widgets/figure/plots/image/image.py b/bec_widgets/widgets/figure/plots/image/image.py index 12c89d19..f9403bb7 100644 --- a/bec_widgets/widgets/figure/plots/image/image.py +++ b/bec_widgets/widgets/figure/plots/image/image.py @@ -29,11 +29,9 @@ class ImageConfig(SubplotConfig): class BECImageShow(BECPlotBase): USER_ACCESS = [ - "rpc_id", - "config_dict", + "_rpc_id", + "_config_dict", "add_image_by_config", - "get_image_config", - "get_image_dict", "add_monitor_image", "add_custom_image", "set_vrange", @@ -47,7 +45,6 @@ class BECImageShow(BECPlotBase): "set_log", "set_rotation", "set_transpose", - "toggle_threading", "set", "set_title", "set_x_label", @@ -60,7 +57,6 @@ class BECImageShow(BECPlotBase): "lock_aspect_ratio", "remove", "images", - "apply_config", ] def __init__( diff --git a/bec_widgets/widgets/figure/plots/image/image_item.py b/bec_widgets/widgets/figure/plots/image/image_item.py index cda55a57..71b5c0a8 100644 --- a/bec_widgets/widgets/figure/plots/image/image_item.py +++ b/bec_widgets/widgets/figure/plots/image/image_item.py @@ -37,8 +37,8 @@ class ImageItemConfig(ConnectionConfig): class BECImageItem(BECConnector, pg.ImageItem): USER_ACCESS = [ - "rpc_id", - "config_dict", + "_rpc_id", + "_config_dict", "set", "set_fft", "set_log", diff --git a/bec_widgets/widgets/figure/plots/motor_map/motor_map.py b/bec_widgets/widgets/figure/plots/motor_map/motor_map.py index f6d12adb..622e476d 100644 --- a/bec_widgets/widgets/figure/plots/motor_map/motor_map.py +++ b/bec_widgets/widgets/figure/plots/motor_map/motor_map.py @@ -38,9 +38,6 @@ class MotorMapConfig(SubplotConfig): _validate_color = field_validator("color")(Colors.validate_color) - # @field_validator("color") - # def convert_to_rgba(cls, value): - @field_validator("background_value") def validate_background_value(cls, value): if not 0 <= value <= 255: @@ -52,8 +49,8 @@ class MotorMapConfig(SubplotConfig): class BECMotorMap(BECPlotBase): USER_ACCESS = [ - "rpc_id", - "config_dict", + "_rpc_id", + "_config_dict", "change_motors", "set_max_points", "set_precision", @@ -62,7 +59,6 @@ class BECMotorMap(BECPlotBase): "set_scatter_size", "get_data", "remove", - "apply_config", ] # QT Signals diff --git a/bec_widgets/widgets/figure/plots/plot_base.py b/bec_widgets/widgets/figure/plots/plot_base.py index abd35787..8c25c2a2 100644 --- a/bec_widgets/widgets/figure/plots/plot_base.py +++ b/bec_widgets/widgets/figure/plots/plot_base.py @@ -46,7 +46,7 @@ class SubplotConfig(ConnectionConfig): class BECPlotBase(BECConnector, pg.GraphicsLayout): USER_ACCESS = [ - "config_dict", + "_config_dict", "set", "set_title", "set_x_label", diff --git a/bec_widgets/widgets/figure/plots/waveform/waveform.py b/bec_widgets/widgets/figure/plots/waveform/waveform.py index 76a430b0..041807e0 100644 --- a/bec_widgets/widgets/figure/plots/waveform/waveform.py +++ b/bec_widgets/widgets/figure/plots/waveform/waveform.py @@ -35,8 +35,8 @@ class Waveform1DConfig(SubplotConfig): class BECWaveform(BECPlotBase): USER_ACCESS = [ - "rpc_id", - "config_dict", + "_rpc_id", + "_config_dict", "plot", "add_dap", "get_dap_params", @@ -44,8 +44,6 @@ class BECWaveform(BECPlotBase): "scan_history", "curves", "get_curve", - "get_curve_config", - "apply_config", "get_all_data", "set", "set_title", @@ -59,7 +57,6 @@ class BECWaveform(BECPlotBase): "lock_aspect_ratio", "remove", "set_legend_label_size", - "apply_config", ] scan_signal_update = pyqtSignal() dap_params_update = pyqtSignal(dict) diff --git a/bec_widgets/widgets/figure/plots/waveform/waveform_curve.py b/bec_widgets/widgets/figure/plots/waveform/waveform_curve.py index 4bf3c1ad..fc2f4962 100644 --- a/bec_widgets/widgets/figure/plots/waveform/waveform_curve.py +++ b/bec_widgets/widgets/figure/plots/waveform/waveform_curve.py @@ -65,8 +65,8 @@ class BECCurve(BECConnector, pg.PlotDataItem): USER_ACCESS = [ "remove", "dap_params", - "rpc_id", - "config_dict", + "_rpc_id", + "_config_dict", "set", "set_data", "set_color", diff --git a/bec_widgets/widgets/ring_progress_bar/ring.py b/bec_widgets/widgets/ring_progress_bar/ring.py index 51ec0e7a..02053212 100644 --- a/bec_widgets/widgets/ring_progress_bar/ring.py +++ b/bec_widgets/widgets/ring_progress_bar/ring.py @@ -79,9 +79,9 @@ class RingConfig(ProgressbarConfig): class Ring(BECConnector): USER_ACCESS = [ - "get_all_rpc", - "rpc_id", - "config_dict", + "_get_all_rpc", + "_rpc_id", + "_config_dict", "set_value", "set_color", "set_background", diff --git a/bec_widgets/widgets/ring_progress_bar/ring_progress_bar.py b/bec_widgets/widgets/ring_progress_bar/ring_progress_bar.py index 3d50f72a..7d93426f 100644 --- a/bec_widgets/widgets/ring_progress_bar/ring_progress_bar.py +++ b/bec_widgets/widgets/ring_progress_bar/ring_progress_bar.py @@ -68,9 +68,9 @@ class RingProgressBarConfig(ConnectionConfig): class RingProgressBar(BECConnector, QWidget): USER_ACCESS = [ - "get_all_rpc", - "rpc_id", - "config_dict", + "_get_all_rpc", + "_rpc_id", + "_config_dict", "rings", "update_config", "add_ring", diff --git a/tests/end-2-end/test_bec_dock_rpc_e2e.py b/tests/end-2-end/test_bec_dock_rpc_e2e.py index c586e8e0..130a8c4a 100644 --- a/tests/end-2-end/test_bec_dock_rpc_e2e.py +++ b/tests/end-2-end/test_bec_dock_rpc_e2e.py @@ -23,14 +23,14 @@ def test_rpc_add_dock_with_figure_e2e(bec_client_lib, rpc_server_dock): d1 = dock.add_dock("dock_1") d2 = dock.add_dock("dock_2") - dock_config = dock.config_dict + dock_config = dock._config_dict assert len(dock_config["docks"]) == 3 # Add 3 figures with some widgets fig0 = d0.add_widget("BECFigure") fig1 = d1.add_widget("BECFigure") fig2 = d2.add_widget("BECFigure") - dock_config = dock.config_dict + dock_config = dock._config_dict assert len(dock_config["docks"]) == 3 assert len(dock_config["docks"]["dock_0"]["widgets"]) == 1 assert len(dock_config["docks"]["dock_1"]["widgets"]) == 1 @@ -52,7 +52,7 @@ def test_rpc_add_dock_with_figure_e2e(bec_client_lib, rpc_server_dock): assert im.__class__.__name__ == "BECImageShow" assert im.__class__ == BECImageShow - assert mm.config_dict["signals"] == { + assert mm._config_dict["signals"] == { "dap": None, "source": "device_readback", "x": { @@ -71,14 +71,14 @@ def test_rpc_add_dock_with_figure_e2e(bec_client_lib, rpc_server_dock): }, "z": None, } - assert plt.config_dict["curves"]["bpm4i-bpm4i"]["signals"] == { + assert plt._config_dict["curves"]["bpm4i-bpm4i"]["signals"] == { "dap": None, "source": "scan_segment", "x": {"name": "samx", "entry": "samx", "unit": None, "modifier": None, "limits": None}, "y": {"name": "bpm4i", "entry": "bpm4i", "unit": None, "modifier": None, "limits": None}, "z": None, } - assert im.config_dict["images"]["eiger"]["monitor"] == "eiger" + assert im._config_dict["images"]["eiger"]["monitor"] == "eiger" # check initial position of motor map initial_pos_x = dev.samx.read()["samx"]["value"] @@ -126,29 +126,29 @@ def test_dock_manipulations_e2e(rpc_server_dock): d0 = dock.add_dock("dock_0") d1 = dock.add_dock("dock_1") d2 = dock.add_dock("dock_2") - dock_config = dock.config_dict + dock_config = dock._config_dict assert len(dock_config["docks"]) == 3 d0.detach() dock.detach_dock("dock_2") - dock_config = dock.config_dict + dock_config = dock._config_dict assert len(dock_config["docks"]) == 3 assert len(dock.temp_areas) == 2 d0.attach() - dock_config = dock.config_dict + dock_config = dock._config_dict assert len(dock_config["docks"]) == 3 assert len(dock.temp_areas) == 1 d2.remove() - dock_config = dock.config_dict + dock_config = dock._config_dict assert len(dock_config["docks"]) == 2 assert ["dock_0", "dock_1"] == list(dock_config["docks"]) dock.clear_all() - dock_config = dock.config_dict + dock_config = dock._config_dict assert len(dock_config["docks"]) == 0 assert len(dock.temp_areas) == 0 @@ -165,11 +165,11 @@ def test_ring_bar(rpc_server_dock): bar.set_colors_from_map("viridis") bar.set_value([10, 20, 30, 40, 50]) - bar_config = bar.config_dict + bar_config = bar._config_dict expected_colors = [list(color) for color in Colors.golden_angle_color("viridis", 5, "RGB")] - bar_colors = [ring.config_dict["color"] for ring in bar.rings] - bar_values = [ring.config_dict["value"] for ring in bar.rings] + bar_colors = [ring._config_dict["color"] for ring in bar.rings] + bar_values = [ring._config_dict["value"] for ring in bar.rings] assert bar_config["num_bars"] == 5 assert bar_values == [10, 20, 30, 40, 50] assert bar_colors == expected_colors @@ -191,7 +191,7 @@ def test_ring_bar_scan_update(bec_client_lib, rpc_server_dock): status = scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.05, relative=False) status.wait() - bar_config = bar.config_dict + bar_config = bar._config_dict assert bar_config["num_bars"] == 1 assert bar_config["rings"][0]["value"] == 10 assert bar_config["rings"][0]["min_value"] == 0 @@ -200,7 +200,7 @@ def test_ring_bar_scan_update(bec_client_lib, rpc_server_dock): status = scans.grid_scan(dev.samx, -5, 5, 4, dev.samy, -10, 10, 4, relative=True, exp_time=0.1) status.wait() - bar_config = bar.config_dict + bar_config = bar._config_dict assert bar_config["num_bars"] == 1 assert bar_config["rings"][0]["value"] == 16 assert bar_config["rings"][0]["min_value"] == 0 @@ -217,7 +217,7 @@ def test_ring_bar_scan_update(bec_client_lib, rpc_server_dock): status = scans.umv(dev.samx, 5, dev.samy, 10, relative=True) status.wait() - bar_config = bar.config_dict + bar_config = bar._config_dict assert bar_config["num_bars"] == 2 assert bar_config["rings"][0]["value"] == final_samx assert bar_config["rings"][1]["value"] == final_samy diff --git a/tests/end-2-end/test_bec_figure_rpc_e2e.py b/tests/end-2-end/test_bec_figure_rpc_e2e.py index 1841ec05..a207851d 100644 --- a/tests/end-2-end/test_bec_figure_rpc_e2e.py +++ b/tests/end-2-end/test_bec_figure_rpc_e2e.py @@ -17,7 +17,7 @@ def test_rpc_waveform1d_custom_curve(rpc_server_figure): curve.set_color("blue") assert len(fig.widgets) == 1 - assert len(fig.widgets[ax.rpc_id].curves) == 1 + assert len(fig.widgets[ax._rpc_id].curves) == 1 def test_rpc_plotting_shortcuts_init_configs(rpc_server_figure, qtbot): @@ -39,7 +39,7 @@ def test_rpc_plotting_shortcuts_init_configs(rpc_server_figure, qtbot): # check if the correct devices are set # plot - assert plt.config_dict["curves"]["bpm4i-bpm4i"]["signals"] == { + assert plt._config_dict["curves"]["bpm4i-bpm4i"]["signals"] == { "dap": None, "source": "scan_segment", "x": {"name": "samx", "entry": "samx", "unit": None, "modifier": None, "limits": None}, @@ -47,9 +47,9 @@ def test_rpc_plotting_shortcuts_init_configs(rpc_server_figure, qtbot): "z": None, } # image - assert im.config_dict["images"]["eiger"]["monitor"] == "eiger" + assert im._config_dict["images"]["eiger"]["monitor"] == "eiger" # motor map - assert motor_map.config_dict["signals"] == { + assert motor_map._config_dict["signals"] == { "dap": None, "source": "device_readback", "x": { @@ -69,7 +69,7 @@ def test_rpc_plotting_shortcuts_init_configs(rpc_server_figure, qtbot): "z": None, } # plot with z scatter - assert plt_z.config_dict["curves"]["bpm4i-bpm4i"]["signals"] == { + assert plt_z._config_dict["curves"]["bpm4i-bpm4i"]["signals"] == { "dap": None, "source": "scan_segment", "x": {"name": "samx", "entry": "samx", "unit": None, "modifier": None, "limits": None}, diff --git a/tests/end-2-end/test_rpc_register_e2e.py b/tests/end-2-end/test_rpc_register_e2e.py index 2a2e532d..35509a02 100644 --- a/tests/end-2-end/test_rpc_register_e2e.py +++ b/tests/end-2-end/test_rpc_register_e2e.py @@ -13,20 +13,20 @@ def test_rpc_register_list_connections(rpc_server_figure): # keep only class names from objects, since objects on server and client are different # so the best we can do is to compare types (rpc register is unit-tested elsewhere) - all_connections = {obj_id: type(obj).__name__ for obj_id, obj in fig.get_all_rpc().items()} + all_connections = {obj_id: type(obj).__name__ for obj_id, obj in fig._get_all_rpc().items()} all_subwidgets_expected = {wid: type(widget).__name__ for wid, widget in fig.widgets.items()} - curve_1D = fig.widgets[plt.rpc_id] - curve_2D = fig.widgets[plt_z.rpc_id] + curve_1D = fig.widgets[plt._rpc_id] + curve_2D = fig.widgets[plt_z._rpc_id] curves_expected = { - curve_1D.rpc_id: type(curve_1D).__name__, - curve_2D.rpc_id: type(curve_2D).__name__, + curve_1D._rpc_id: type(curve_1D).__name__, + curve_2D._rpc_id: type(curve_2D).__name__, } curves_expected.update({curve._gui_id: type(curve).__name__ for curve in curve_1D.curves}) curves_expected.update({curve._gui_id: type(curve).__name__ for curve in curve_2D.curves}) - fig_expected = {fig.rpc_id: type(fig).__name__} + fig_expected = {fig._rpc_id: type(fig).__name__} image_item_expected = { - fig.widgets[im.rpc_id].images[0].rpc_id: type(fig.widgets[im.rpc_id].images[0]).__name__ + fig.widgets[im._rpc_id].images[0]._rpc_id: type(fig.widgets[im._rpc_id].images[0]).__name__ } all_connections_expected = { diff --git a/tests/unit_tests/test_bec_motor_map.py b/tests/unit_tests/test_bec_motor_map.py index 52d8e1bc..ec8c033c 100644 --- a/tests/unit_tests/test_bec_motor_map.py +++ b/tests/unit_tests/test_bec_motor_map.py @@ -192,7 +192,7 @@ def test_motor_map_init_from_config(bec_figure): mm = bec_figure.motor_map(config=config) config["gui_id"] = mm.gui_id - assert mm.config_dict == config + assert mm._config_dict == config def test_motor_map_set_scatter_size(bec_figure, qtbot):