diff --git a/.git_hooks/post-commit b/.git_hooks/post-commit new file mode 100644 index 0000000..3fe80fe --- /dev/null +++ b/.git_hooks/post-commit @@ -0,0 +1,3 @@ +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +semantic-release changelog -D version_variable=$SCRIPT_DIR/../../semantic_release/__init__.py:__version__ +semantic-release version -D version_variable=$SCRIPT_DIR/../../semantic_release/__init__.py:__version__ \ No newline at end of file diff --git a/.git_hooks/pre-commit b/.git_hooks/pre-commit new file mode 100644 index 0000000..392493b --- /dev/null +++ b/.git_hooks/pre-commit @@ -0,0 +1,3 @@ +black --line-length=100 $(git diff --cached --name-only --diff-filter=ACM -- '*.py') +isort --line-length=100 --profile=black --multi-line=3 --trailing-comma $(git diff --cached --name-only --diff-filter=ACM -- '*.py') +git add $(git diff --cached --name-only --diff-filter=ACM -- '*.py') diff --git a/.gitignore b/.gitignore index 74235c6..f4c73aa 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ **/.pytest_cache **/*.egg* +# recovery_config files +recovery_config_* + # file writer data **.h5 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..f79caf0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,6 @@ +include: +- file: /templates/plugin-repo-template.yml + inputs: + name: xtreme_bec + target: xtreme_bec + project: bec/awi_utils diff --git a/bec_plugins/__init__.py b/bec_plugins/__init__.py deleted file mode 100644 index c8ba5d1..0000000 --- a/bec_plugins/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .bec_client import * diff --git a/bec_plugins/bec_client/__init__.py b/bec_plugins/bec_client/__init__.py deleted file mode 100644 index ba24808..0000000 --- a/bec_plugins/bec_client/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .plugins import * diff --git a/bec_plugins/bec_client/hli/spec_hli.py b/bec_plugins/bec_client/hli/spec_hli.py deleted file mode 100644 index 79700b2..0000000 --- a/bec_plugins/bec_client/hli/spec_hli.py +++ /dev/null @@ -1,245 +0,0 @@ -from bec_lib.devicemanager import Device -from bec_lib.scan_report import ScanReport - -# pylint:disable=undefined-variable -# pylint: disable=too-many-arguments - - -def dscan( - motor1: Device, m1_from: float, m1_to: float, steps: int, exp_time: float, **kwargs -) -> ScanReport: - """Relative line scan with one device. - - Args: - motor1 (Device): Device that should be scanned. - m1_from (float): Start position relative to the current position. - m1_to (float): End position relative to the current position. - steps (int): Number of steps. - exp_time (float): Exposure time. - - Returns: - ScanReport: Status object. - - Examples: - >>> dscan(dev.motor1, -5, 5, 10, 0.1) - """ - return scans.line_scan( - motor1, m1_from, m1_to, steps=steps, exp_time=exp_time, relative=True, **kwargs - ) - - -def d2scan( - motor1: Device, - m1_from: float, - m1_to: float, - motor2: Device, - m2_from: float, - m2_to: float, - steps: int, - exp_time: float, - **kwargs -) -> ScanReport: - """Relative line scan with two devices. - - Args: - motor1 (Device): First device that should be scanned. - m1_from (float): Start position of the first device relative to its current position. - m1_to (float): End position of the first device relative to its current position. - motor2 (Device): Second device that should be scanned. - m2_from (float): Start position of the second device relative to its current position. - m2_to (float): End position of the second device relative to its current position. - steps (int): Number of steps. - exp_time (float): Exposure time - - Returns: - ScanReport: Status object. - - Examples: - >>> d2scan(dev.motor1, -5, 5, dev.motor2, -8, 8, 10, 0.1) - """ - return scans.line_scan( - motor1, - m1_from, - m1_to, - motor2, - m2_from, - m2_to, - steps=steps, - exp_time=exp_time, - relative=True, - **kwargs - ) - - -def ascan(motor1, m1_from, m1_to, steps, exp_time, **kwargs): - """Absolute line scan with one device. - - Args: - motor1 (Device): Device that should be scanned. - m1_from (float): Start position. - m1_to (float): End position. - steps (int): Number of steps. - exp_time (float): Exposure time. - - Returns: - ScanReport: Status object. - - Examples: - >>> ascan(dev.motor1, -5, 5, 10, 0.1) - """ - return scans.line_scan( - motor1, m1_from, m1_to, steps=steps, exp_time=exp_time, relative=False, **kwargs - ) - - -def a2scan(motor1, m1_from, m1_to, motor2, m2_from, m2_to, steps, exp_time, **kwargs): - """Absolute line scan with two devices. - - Args: - motor1 (Device): First device that should be scanned. - m1_from (float): Start position of the first device. - m1_to (float): End position of the first device. - motor2 (Device): Second device that should be scanned. - m2_from (float): Start position of the second device. - m2_to (float): End position of the second device. - steps (int): Number of steps. - exp_time (float): Exposure time - - Returns: - ScanReport: Status object. - - Examples: - >>> a2scan(dev.motor1, -5, 5, dev.motor2, -8, 8, 10, 0.1) - """ - return scans.line_scan( - motor1, - m1_from, - m1_to, - motor2, - m2_from, - m2_to, - steps=steps, - exp_time=exp_time, - relative=False, - **kwargs - ) - - -def dmesh(motor1, m1_from, m1_to, m1_steps, motor2, m2_from, m2_to, m2_steps, exp_time, **kwargs): - """Relative mesh scan (grid scan) with two devices. - - Args: - motor1 (Device): First device that should be scanned. - m1_from (float): Start position of the first device relative to its current position. - m1_to (float): End position of the first device relative to its current position. - m1_steps (int): Number of steps for motor1. - motor2 (Device): Second device that should be scanned. - m2_from (float): Start position of the second device relative to its current position. - m2_to (float): End position of the second device relative to its current position. - m2_steps (int): Number of steps for motor2. - exp_time (float): Exposure time - - Returns: - ScanReport: Status object. - - Examples: - >>> dmesh(dev.motor1, -5, 5, 10, dev.motor2, -8, 8, 10, 0.1) - """ - return scans.grid_scan( - motor1, - m1_from, - m1_to, - m1_steps, - motor2, - m2_from, - m2_to, - m2_steps, - exp_time=exp_time, - relative=True, - ) - - -def amesh(motor1, m1_from, m1_to, m1_steps, motor2, m2_from, m2_to, m2_steps, exp_time, **kwargs): - """Absolute mesh scan (grid scan) with two devices. - - Args: - motor1 (Device): First device that should be scanned. - m1_from (float): Start position of the first device. - m1_to (float): End position of the first device. - m1_steps (int): Number of steps for motor1. - motor2 (Device): Second device that should be scanned. - m2_from (float): Start position of the second device. - m2_to (float): End position of the second device. - m2_steps (int): Number of steps for motor2. - exp_time (float): Exposure time - - Returns: - ScanReport: Status object. - - Examples: - >>> amesh(dev.motor1, -5, 5, 10, dev.motor2, -8, 8, 10, 0.1) - """ - return scans.grid_scan( - motor1, - m1_from, - m1_to, - m1_steps, - motor2, - m2_from, - m2_to, - m2_steps, - exp_time=exp_time, - relative=False, - ) - - -def umv(*args) -> ScanReport: - """Updated absolute move (i.e. blocking) for one or more devices. - - Returns: - ScanReport: Status object. - - Examples: - >>> umv(dev.samx, 1) - >>> umv(dev.samx, 1, dev.samy, 2) - """ - return scans.umv(*args, relative=False) - - -def umvr(*args) -> ScanReport: - """Updated relative move (i.e. blocking) for one or more devices. - - Returns: - ScanReport: Status object. - - Examples: - >>> umvr(dev.samx, 1) - >>> umvr(dev.samx, 1, dev.samy, 2) - """ - return scans.umv(*args, relative=True) - - -def mv(*args) -> ScanReport: - """Absolute move for one or more devices. - - Returns: - ScanReport: Status object. - - Examples: - >>> mv(dev.samx, 1) - >>> mv(dev.samx, 1, dev.samy, 2) - """ - return scans.mv(*args, relative=False) - - -def mvr(*args) -> ScanReport: - """Relative move for one or more devices. - - Returns: - ScanReport: Status object. - - Examples: - >>> mvr(dev.samx, 1) - >>> mvr(dev.samx, 1, dev.samy, 2) - """ - return scans.mv(*args, relative=True) diff --git a/bec_plugins/bec_client/startup/post_startup.py b/bec_plugins/bec_client/startup/post_startup.py deleted file mode 100644 index c7778dd..0000000 --- a/bec_plugins/bec_client/startup/post_startup.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -Post startup script for the BEC client. This script is executed after the -IPython shell is started. It is used to load the beamline specific -information and to setup the prompts. - -The script is executed in the global namespace of the IPython shell. This -means that all variables defined here are available in the shell. - -If needed, bec command-line arguments can be parsed here. For example, to -parse the --session argument, add the following lines to the script: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("--session", help="Session name", type=str, default="my_default_session") - args = parser.parse_args() - - if args.session == "my_session": - print("Loading my_session session") - from bec_plugins.bec_client.plugins.my_session import * - else: - print("Loading default session") - from bec_plugins.bec_client.plugins.default_session import * -""" - -# pylint: disable=invalid-name, unused-import, import-error, undefined-variable, unused-variable, unused-argument, no-name-in-module - -from bec_lib import bec_logger - -logger = bec_logger.logger - -logger.info("Using the XTreme startup script.") - - -# SETUP BEAMLINE INFO -from bec_client.plugins.SLS.sls_info import OperatorInfo, SLSInfo - -bec._beamline_mixin._bl_info_register(SLSInfo) -bec._beamline_mixin._bl_info_register(OperatorInfo) - -# SETUP PROMPTS -bec._ip.prompts.username = "XTreme" -bec._ip.prompts.status = 1 diff --git a/bec_plugins/bec_client/startup/pre_startup.py b/bec_plugins/bec_client/startup/pre_startup.py deleted file mode 100644 index 48d274d..0000000 --- a/bec_plugins/bec_client/startup/pre_startup.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -Pre-startup script for BEC client. This script is executed before the BEC client -is started. It can be used to set up the BEC client configuration. The script is -executed in the global namespace of the BEC client. This means that all -variables defined here are available in the BEC client. - -To set up the BEC client configuration, use the ServiceConfig class. For example, -to set the configuration file path, add the following lines to the script: - - import pathlib - from bec_lib import ServiceConfig - - current_path = pathlib.Path(__file__).parent.resolve() - CONFIG_PATH = f"{current_path}/" - - config = ServiceConfig(CONFIG_PATH) - -If this startup script defined a ServiceConfig object, the BEC client will use -it to configure itself. Otherwise, the BEC client will use the default config. -""" -from bec_lib import ServiceConfig - -CONFIG_PATH = "/sls/X07MA/data/x07maop/SW/bec/bec/bec_client_config.yaml" -config = ServiceConfig(CONFIG_PATH) diff --git a/bec_plugins/scan_server/scan_plugins/otf_scan.py b/bec_plugins/scan_server/scan_plugins/otf_scan.py deleted file mode 100644 index 38c1ed6..0000000 --- a/bec_plugins/scan_server/scan_plugins/otf_scan.py +++ /dev/null @@ -1,175 +0,0 @@ -import time - -import numpy as np -from bec_lib import bec_logger -from scan_server.scans import FlyScanBase, ScanArgType, ScanBase - -logger = bec_logger.logger - - -class OTFScan(FlyScanBase): - scan_name = "otf_scan" - scan_report_hint = "table" - required_kwargs = ["e1", "e2", "time"] - arg_input = [] - arg_bundle_size = len(arg_input) - - def __init__(self, *args, parameter=None, **kwargs): - """Scans the energy from e1 to e2 in