From 2fe109ac59431ce6d367b402694586e55f520040 Mon Sep 17 00:00:00 2001 From: Max Rakitin Date: Tue, 14 May 2024 11:24:52 -0400 Subject: [PATCH] Better compatibility with qserver (fixing docstings format) --- startup/1001-remoteplan.py | 48 ++++++++++++--------- startup/42-energy-calib.py | 8 ++-- startup/85-robot.py | 13 ++++-- startup/90-plans.py | 4 +- startup/91-plans-ecal.py | 4 -- startup/970-load.py | 28 ++++--------- startup/972-acq-plans.py | 22 +++++----- startup/973-gas-plan.py | 6 ++- startup/existing_plans_and_devices.yaml | 55 +++++++++++++++++++++++-- 9 files changed, 120 insertions(+), 68 deletions(-) diff --git a/startup/1001-remoteplan.py b/startup/1001-remoteplan.py index e345c39..36a80e8 100644 --- a/startup/1001-remoteplan.py +++ b/startup/1001-remoteplan.py @@ -162,18 +162,23 @@ def xpd_mscan_flt(sample_list, pos_list, ht_list, scanplan, motor=sample_x, dela # -----start temperature scan plans ------------------ def xpd_temp_list(smpl, Temp_list, exp_time, delay=1, dets=[]): - ''' - example - xpd_temp_list(1, [300, 350, 400], 5, delay=1) - sample 1, at temperature 300, 350 and 400, exposure time 5sec, wait 1 second after each temperature. + '''The plan to perform a scan over temperature list. + + Parameters + ---------- + + smpl: sample index ID in sample list + Temp_list: temperature list + exp_time : total exposure time for each sample, in seconds + delay: sleep time after each temperature changes, for temperature controller to stable + dets: list of motors, temperatures controllers, which will be recorded in table. + + Examples + -------- - parameters: - smpl: sample index ID in sample list - Temp_list: temperature list - exp_time : total exposure time for each sample, in seconds - delay: sleep time after each temperature changes, for temperature controller to stable - dets: list of motors, temperatures controllers, which will be recorded in table. + >>> xpd_temp_list(1, [300, 350, 400], 5, delay=1) + sample 1, at temperature 300, 350 and 400, exposure time 5sec, wait 1 second after each temperature. ''' #RE(_configure_area_det(exp_time)) T_controller = xpd_configuration["temp_controller"] @@ -193,16 +198,19 @@ def xpd_temp_list(smpl, Temp_list, exp_time, delay=1, dets=[]): def xpd_temp_ramp(smpl, Tstart, Tstop, Tstep, exp_time, delay = 1, dets=[]): ''' - example: - xpd_temp_ramp(1, 300, 400, 10, 5, delay=1) - sample 1, from 300K to 400K, 10K steps, exposure time 5sec, wait 1 second after each temperature. - - parameters: - smpl: sample index ID in sample list - Tstart, Tstop, Tstep: temperature range(Tstart, Tend), step size: Tstep - scanplan : scanplan index ID in scanplan list - delay: sleep time after each temperature changes, for temperature controller to stable - dets: list of motors, temperatures controllers, which will be recorded in table. + Parameters + ---------- + smpl: sample index ID in sample list + Tstart, Tstop, Tstep: temperature range(Tstart, Tend), step size: Tstep + scanplan : scanplan index ID in scanplan list + delay: sleep time after each temperature changes, for temperature controller to stable + dets: list of motors, temperatures controllers, which will be recorded in table. + + Examples + -------- + >>> xpd_temp_ramp(1, 300, 400, 10, 5, delay=1) + + sample 1, from 300K to 400K, 10K steps, exposure time 5sec, wait 1 second after each temperature. ''' #RE(_configure_area_det(exp_time)) T_controller = xpd_configuration["temp_controller"] diff --git a/startup/42-energy-calib.py b/startup/42-energy-calib.py index 29bce30..207593c 100644 --- a/startup/42-energy-calib.py +++ b/startup/42-energy-calib.py @@ -102,9 +102,11 @@ def get_wavelength_from_std_tth(x, y, d_spacings, ns, plot=False): class ComputeWavelength(CollectThenCompute): - """ - Example - ------- + """The class to compute the length. + + Examples + -------- + >>> cw = ComputeWavelgnth('tth_cal', 'some_detector', d_spacings, ns) >>> RE(scan(...), cw) """ diff --git a/startup/85-robot.py b/startup/85-robot.py index 9626972..7ed2b4c 100644 --- a/startup/85-robot.py +++ b/startup/85-robot.py @@ -158,8 +158,9 @@ def robot_wrapper(plan, sample): sample : dict must contain 'position'; optionally also 'geometry' - Example - ------- + Examples + -------- + >>> plan = count([pe1c]) >>> new_plan = robot_wrapper(plan, {'position': 1}) """ @@ -219,8 +220,12 @@ def example(): def excel_example(filename, geometry=None): - """ - Example: RE(excel_example('/XF28IDC/XF28ID2/pe2_data/xpdUser/Import/example-with-dan.xlsx')) + """Excel example plan. + + Examples + -------- + + >>> RE(excel_example('/XF28IDC/XF28ID2/pe2_data/xpdUser/Import/example-with-dan.xlsx')) """ import pandas as pd f = pd.ExcelFile(filename) diff --git a/startup/90-plans.py b/startup/90-plans.py index 67c13f2..402a676 100644 --- a/startup/90-plans.py +++ b/startup/90-plans.py @@ -21,8 +21,8 @@ def MED(init_gas, other_gas, minT, maxT, num_steps, num_steady, num_trans, num_l 5. Switch the gas to `other_gas` and take `num_trans` acquisitions. 6. Switch it back and take another `num_trans` acquisitions. - Example - ------- + Examples + -------- Set the gasses. They can be in any other, nothing to do with the order they are used in the plan. >>> gas.gas_list = ['O2', 'CO2'] diff --git a/startup/91-plans-ecal.py b/startup/91-plans-ecal.py index 02f4e7b..88dc362 100644 --- a/startup/91-plans-ecal.py +++ b/startup/91-plans-ecal.py @@ -175,10 +175,6 @@ def Ecal(wguess, detectors=None, motor=None, coarse_step=.0012, coarse_nsteps=12 the coarse scan motor_type : str, optional the type of motor used, ether "th" (theta) or "tth"(two-theta) - - Example - ------- - ''' if detectors is None: detectors = [sc] diff --git a/startup/970-load.py b/startup/970-load.py index 00c58b6..070f531 100644 --- a/startup/970-load.py +++ b/startup/970-load.py @@ -48,8 +48,6 @@ # import necessary modules from xpdacq.xpdacq import * from xpdacq.beamtime import * -del Tlist -del Tramp from xpdacq.utils import import_sample_info # instantiate xrun without beamtime, like bluesky setup @@ -58,14 +56,15 @@ xrun.md['group'] = glbl['group'] xrun.md['facility'] = glbl['facility'] -# TODO: fix for queueserver - need to exclude interaction: -# /opt/bluesky/queueserver/queueserver-config.yml - check for existence of this file and load silently... - - print("loading beamline config") -# removing human input for automating queueserver setup by setting test=True -beamline_config = _load_beamline_config(glbl['blconfig_path'], test=True) +if is_re_worker_active(): # running in queueserver + del Tlist + del Tramp + # removing human input for automating queueserver setup by setting test=True + beamline_config = _load_beamline_config(glbl['blconfig_path'], test=True) +else: + beamline_config = _load_beamline_config(glbl['blconfig_path']) print("loaded beamline config") @@ -100,12 +99,6 @@ print('OK, ready to go. To continue, follow the steps in the xpdAcq') print('documentation at http://xpdacq.github.io/xpdacq\n') -''' -bt = start_xpdacq() -if bt is not None: - print("INFO: Reload beamtime objects:\n{}\n".format(bt)) -if reload_glbl_dict is not None: - _set_glbl(glbl, reload_glbl_dict) class MoreCustomizedRunEngine(CustomizedRunEngine): @@ -116,7 +109,7 @@ def __call__(self, plan, *args, **kwargs): from nslsii import configure_kafka_publisher from bluesky.utils import ts_msg_hook -RE = MoreCustomizedRunEngine(None) +RE = MoreCustomizedRunEngine(None) # This object is like 'xrun', but with the RE API. # RE.msg_hook = ts_msg_hook configure_kafka_publisher(RE, beamline_name='xpd') @@ -126,8 +119,3 @@ def __call__(self, plan, *args, **kwargs): RE.subscribe(db.insert, "all") RE.beamtime = bt RE.clear_suspenders() - - - -''' - diff --git a/startup/972-acq-plans.py b/startup/972-acq-plans.py index b7c901c..8554830 100644 --- a/startup/972-acq-plans.py +++ b/startup/972-acq-plans.py @@ -20,11 +20,7 @@ def gas_plan(gas_in, rga_masses=['mass1', 'mass2', 'mass3', 'mass4', 'mass5', 'mass6']): - """ - Example: - - >>> RE(gas_plan(gas_in='He', masses_to_plot=['mass4', 'mass6'])) - ---------- + """The plan to switch gases. Parameters ---------- @@ -33,6 +29,11 @@ def gas_plan(gas_in, rga_masses=['mass1', 'mass2', 'mass3', 'mass4', 'mass5', 'm These gas must be in `gas.gas_list` but they may be in any order. rga_masses: list, optional a list of rga masses appearing in a live table + + Examples + -------- + + >>> RE(gas_plan(gas_in='He', rga_masses=['mass4', 'mass6'])) """ print('Warning: check the gas list!') @@ -50,11 +51,7 @@ def gas_plan(gas_in, rga_masses=['mass1', 'mass2', 'mass3', 'mass4', 'mass5', 'm def gas_plan_with_detector(gas_in, rga_masses=['mass1', 'mass2', 'mass3', 'mass4', 'mass5', 'mass6'], det=None, exp_time=5, num_exp=1, delay=1): - """ - Example: - - >>> RE(gas_plan(gas_in='He', masses_to_plot=['mass4', 'mass6'])) - ---------- + """The plan to switch gases with a detector. Parameters ---------- @@ -71,6 +68,11 @@ def gas_plan_with_detector(gas_in, rga_masses=['mass1', 'mass2', 'mass3', 'mass4 number of exposures delay : float, optional delay between exposures in seconds + + Examples + -------- + + >>> RE(gas_plan_with_detector(gas_in='He', rga_masses=['mass4', 'mass6'])) """ if det is None: det = pe1c diff --git a/startup/973-gas-plan.py b/startup/973-gas-plan.py index b64739c..a897747 100644 --- a/startup/973-gas-plan.py +++ b/startup/973-gas-plan.py @@ -54,7 +54,7 @@ def Tramp_gas_plan(detectors, gas_in, exp_time, Tstart, Tstop, Tstep, rga_masses: list, optional a list of rga masses will be appearing in a live table - Example: + Examples -------- >>> plan = Tramp_gas_plan([pe1c, rga], 'He', 5, 300, 350, 5) >>> xrun(, plan) @@ -108,7 +108,9 @@ def tseries_gas_plan(detectors, gas_in, exp_time, delay=1, num_exp=1, rga_masses: list, optional a list of rga masses appearing in a live table - Example: + Examples + -------- + >>> plan = tseries_gas_plan([pe1c, rga], 'He', 5, 10, 2) >>> xrun(, plan) """ diff --git a/startup/existing_plans_and_devices.yaml b/startup/existing_plans_and_devices.yaml index 922f1e9..3833f16 100644 --- a/startup/existing_plans_and_devices.yaml +++ b/startup/existing_plans_and_devices.yaml @@ -5408,6 +5408,49 @@ existing_devices: is_movable: true is_readable: true module: ophyd.mixins + setread: + classname: EpicsSignalPositioner + is_flyable: false + is_movable: true + is_readable: true + module: ophyd.mixins + temperature: + classname: EpicsSignalPositioner + is_flyable: false + is_movable: true + is_readable: true + module: ophyd.mixins + is_flyable: false + is_movable: false + is_readable: true + module: __main__ + eurotherm2: + classname: Eurotherm + components: + mode: + classname: EpicsSignal + is_flyable: false + is_movable: true + is_readable: true + module: ophyd.signal + power: + classname: EpicsSignalPositioner + is_flyable: false + is_movable: true + is_readable: true + module: ophyd.mixins + ramprate: + classname: EpicsSignalPositioner + is_flyable: false + is_movable: true + is_readable: true + module: ophyd.mixins + setread: + classname: EpicsSignalPositioner + is_flyable: false + is_movable: true + is_readable: true + module: ophyd.mixins temperature: classname: EpicsSignalPositioner is_flyable: false @@ -6246,6 +6289,12 @@ existing_devices: is_movable: true is_readable: true module: ophyd.mixins + setread: + classname: EpicsSignalPositioner + is_flyable: false + is_movable: true + is_readable: true + module: ophyd.mixins temperature: classname: EpicsSignalPositioner is_flyable: false @@ -14987,7 +15036,7 @@ existing_plans: properties: is_generator: true excel_example: - description: 'Example: RE(excel_example(''/XF28IDC/XF28ID2/pe2_data/xpdUser/Import/example-with-dan.xlsx''))' + description: Excel example plan. module: __main__ name: excel_example parameters: @@ -15285,7 +15334,7 @@ existing_plans: properties: is_generator: true gas_plan: - description: 'Example:' + description: The plan to switch gases. module: __main__ name: gas_plan parameters: @@ -15305,7 +15354,7 @@ existing_plans: properties: is_generator: true gas_plan_with_detector: - description: 'Example:' + description: The plan to switch gases with a detector. module: __main__ name: gas_plan_with_detector parameters: