mirror of
https://github.com/ivan-usov-org/bec.git
synced 2025-04-22 02:20:02 +02:00
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.
This commit is contained in:
parent
ededa6b290
commit
e51a2fbe1c
@ -9,6 +9,7 @@ import builtins
|
|||||||
import getpass
|
import getpass
|
||||||
import importlib
|
import importlib
|
||||||
import inspect
|
import inspect
|
||||||
|
from types import SimpleNamespace
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import redis
|
import redis
|
||||||
@ -120,6 +121,7 @@ class BECClient(BECService, UserScriptsMixin):
|
|||||||
self.dap = None
|
self.dap = None
|
||||||
self.device_monitor = None
|
self.device_monitor = None
|
||||||
self.bl_checks = None
|
self.bl_checks = None
|
||||||
|
self.scans_namespace = SimpleNamespace()
|
||||||
self._hli_funcs = {}
|
self._hli_funcs = {}
|
||||||
self.metadata = {}
|
self.metadata = {}
|
||||||
self.system_config = SystemConfig()
|
self.system_config = SystemConfig()
|
||||||
@ -169,7 +171,7 @@ class BECClient(BECService, UserScriptsMixin):
|
|||||||
)
|
)
|
||||||
builtins.bec = self._parent
|
builtins.bec = self._parent
|
||||||
self._start_services()
|
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(
|
self.callbacks.run(
|
||||||
EventType.NAMESPACE_UPDATE, action="add", ns_objects=default_namespace
|
EventType.NAMESPACE_UPDATE, action="add", ns_objects=default_namespace
|
||||||
)
|
)
|
||||||
@ -225,6 +227,9 @@ class BECClient(BECService, UserScriptsMixin):
|
|||||||
def _load_scans(self):
|
def _load_scans(self):
|
||||||
self.scans = Scans(self._parent)
|
self.scans = Scans(self._parent)
|
||||||
builtins.__dict__["scans"] = self.scans
|
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:
|
def load_high_level_interface(self, module_name: str) -> None:
|
||||||
"""Load a high level interface module.
|
"""Load a high level interface module.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user