From e51a2fbe1c956405b1e8dc0f66e3e76bf346af70 Mon Sep 17 00:00:00 2001 From: Mathias Guijarro Date: Tue, 10 Sep 2024 17:54:41 +0200 Subject: [PATCH] fix: ensure 'bec.scans' (default namespace) points to a clean namespace BECClient.scans is the same as before ; BECClient.scans_namespace is a SimpleNamespace with only functions to run scans. BECClient's default namespace points to the latter. As a consequence, IPython client "bec.scans" == BECClient.scans_namespace , users can only see scan run functions. --- bec_lib/bec_lib/client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bec_lib/bec_lib/client.py b/bec_lib/bec_lib/client.py index 3f21263d..cc6561bf 100644 --- a/bec_lib/bec_lib/client.py +++ b/bec_lib/bec_lib/client.py @@ -9,6 +9,7 @@ import builtins import getpass import importlib import inspect +from types import SimpleNamespace from typing import TYPE_CHECKING import redis @@ -120,6 +121,7 @@ class BECClient(BECService, UserScriptsMixin): self.dap = None self.device_monitor = None self.bl_checks = None + self.scans_namespace = SimpleNamespace() self._hli_funcs = {} self.metadata = {} self.system_config = SystemConfig() @@ -169,7 +171,7 @@ class BECClient(BECService, UserScriptsMixin): ) builtins.bec = self._parent self._start_services() - default_namespace = {"dev": self.device_manager.devices, "scans": self.scans} + default_namespace = {"dev": self.device_manager.devices, "scans": self.scans_namespace} self.callbacks.run( EventType.NAMESPACE_UPDATE, action="add", ns_objects=default_namespace ) @@ -225,6 +227,9 @@ class BECClient(BECService, UserScriptsMixin): def _load_scans(self): self.scans = Scans(self._parent) builtins.__dict__["scans"] = self.scans + self.scans_namespace = SimpleNamespace( + **{scan_name: scan.run for scan_name, scan in self.scans._available_scans.items()} + ) def load_high_level_interface(self, module_name: str) -> None: """Load a high level interface module.