From 8c7cf164f1bb5ea1787d64977292221dca0cd428 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sun, 25 Feb 2024 11:37:30 -0600 Subject: [PATCH 1/5] MNT #250 enable options as configuration items --- bluesky/instrument/framework/initialize.py | 25 +++++++++++----------- bluesky/instrument/iconfig.yml | 8 +++++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/bluesky/instrument/framework/initialize.py b/bluesky/instrument/framework/initialize.py index 2b92c672..2ddf95cb 100644 --- a/bluesky/instrument/framework/initialize.py +++ b/bluesky/instrument/framework/initialize.py @@ -1,5 +1,5 @@ """ -initialize the bluesky framework +Initialize the bluesky framework. """ __all__ = """ @@ -7,8 +7,8 @@ bp bps bpp summarize_plan np - registry - """.split() + oregistry +""".split() import logging @@ -96,18 +96,19 @@ def get_md_path(): # At the end of every run, verify that files were saved and # print a confirmation message. -# from bluesky.callbacks.broker import verify_files_saved -# RE.subscribe(post_run(verify_files_saved), 'stop') +if iconfig.get("VERIFY_FILES_SAVED", False): + from bluesky.callbacks.broker import post_run + from bluesky.callbacks.broker import verify_files_saved -# Uncomment the following lines to turn on -# verbose messages for debugging. -# ophyd.logger.setLevel(logging.DEBUG) + RE.subscribe(post_run(verify_files_saved), "stop") +ophyd.logger.setLevel(iconfig.get("LOGGING", {})("OPHYD_LOGGER_LEVEL", "WARNING")) ophyd.set_cl(iconfig.get("OPHYD_CONTROL_LAYER", "PyEpics").lower()) logger.info(f"using ophyd control layer: {ophyd.cl.name}") -# diagnostics -# RE.msg_hook = ts_msg_hook +if iconfig.get("ADD_DIAGNOSTIC_MESSAGES", False): + # Log bluesky Message objects in RunEngine (follow plan's progress). + RE.msg_hook = ts_msg_hook # set default timeout for all EpicsSignal connections & communications TIMEOUT = 60 @@ -119,8 +120,8 @@ def get_md_path(): connection_timeout=iconfig.get("PV_CONNECTION_TIMEOUT", TIMEOUT), ) -# Create a registry of ophyd devices -registry = Registry(auto_register=True) +# Create a registry of ophyd devices. +oregistry = Registry(auto_register=True) _pv = iconfig.get("RUN_ENGINE_SCAN_ID_PV") if _pv is None: diff --git a/bluesky/instrument/iconfig.yml b/bluesky/instrument/iconfig.yml index 32b0988f..959e951b 100644 --- a/bluesky/instrument/iconfig.yml +++ b/bluesky/instrument/iconfig.yml @@ -28,6 +28,7 @@ AD_MOUNT_PATH: /tmp BLUESKY_MOUNT_PATH: /tmp/docker_ioc/iocad/tmp # permissions +ADD_DIAGNOSTIC_MESSAGES: false ALLOW_AREA_DETECTOR_WARMUP: true ENABLE_AREA_DETECTOR_IMAGE_PLUGIN: true ENABLE_CALCS: true @@ -35,6 +36,7 @@ USE_PROGRESS_BAR: false WRITE_NEXUS_DATA_FILES: true NEXUS_WARN_MISSING_CONTENT: false NEXUS_FILE_EXTENSION: hdf +VERIFY_FILES_SAVED: False WRITE_SPEC_DATA_FILES: true # ---------------------------------- @@ -52,9 +54,11 @@ WRITE_SPEC_DATA_FILES: true LOGGING: # MAX_BYTES: 1000000 NUMBER_OF_PREVIOUS_BACKUPS: 9 - # LOG_PATH: /tmp # If LOG_PATH undefined, this session will log into PWD/logs/ - # where PWD is present working directory when session is started + # where PWD is present working directory when session is started. + # LOG_PATH: /tmp + # Use "DEBUG" to turn on verbose messages for debugging. + OPHYD_LOGGER_LEVEL: WARNING # default timeouts (seconds) PV_READ_TIMEOUT: &TIMEOUT 15 From b145e4eb052caa200cf2db4df7c3f0980c22f8c7 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sun, 25 Feb 2024 11:37:41 -0600 Subject: [PATCH 2/5] DOC #250 --- CHANGES.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index a9577bbb..06934381 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -34,6 +34,11 @@ release expected by 2024-03-01 New Features ------------ +* Add options to instrument configuration (iconfig.yml): + + * After every run, verify that files were saved, print a confirmation message. + * Debugging and message options. + * Add package(s) to environment: * ophyd-registry From d261aa831b98f8f731d581927e6791fa12b16f65 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Sun, 25 Feb 2024 12:09:00 -0600 Subject: [PATCH 3/5] MNT #250 omission --- bluesky/instrument/framework/initialize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bluesky/instrument/framework/initialize.py b/bluesky/instrument/framework/initialize.py index 2ddf95cb..fb521acb 100644 --- a/bluesky/instrument/framework/initialize.py +++ b/bluesky/instrument/framework/initialize.py @@ -102,7 +102,7 @@ def get_md_path(): RE.subscribe(post_run(verify_files_saved), "stop") -ophyd.logger.setLevel(iconfig.get("LOGGING", {})("OPHYD_LOGGER_LEVEL", "WARNING")) +ophyd.logger.setLevel(iconfig.get("LOGGING", {}).get("OPHYD_LOGGER_LEVEL", "WARNING")) ophyd.set_cl(iconfig.get("OPHYD_CONTROL_LAYER", "PyEpics").lower()) logger.info(f"using ophyd control layer: {ophyd.cl.name}") From 4bb1759692d25b409b2756313b1e8709a7a0b585 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Mon, 26 Feb 2024 12:31:35 -0600 Subject: [PATCH 4/5] MNT #250 new name --- bluesky/instrument/framework/initialize.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bluesky/instrument/framework/initialize.py b/bluesky/instrument/framework/initialize.py index 9e8e1ebe..caff6a4b 100644 --- a/bluesky/instrument/framework/initialize.py +++ b/bluesky/instrument/framework/initialize.py @@ -31,7 +31,6 @@ from bluesky.utils import ProgressBarManager from bluesky.utils import ts_msg_hook from IPython import get_ipython -from ophyd.signal import EpicsSignalBase from ophydregistry import Registry import databroker import ophyd @@ -120,4 +119,4 @@ def get_md_path(): RE.md["scan_id"] = scan_id_epics.get() # Create a registry of ophyd devices -registry = Registry(auto_register=True) +oregistry = Registry(auto_register=True) From d3d1e84a7d2626b9b7d6a29095c3c94ebfddbcc0 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Mon, 26 Feb 2024 12:44:16 -0600 Subject: [PATCH 5/5] DOC #250 update release notes --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index eca3e369..fde197bc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -43,7 +43,7 @@ New Features * ophyd-registry -* Build ``registry`` of all ophyd objects. +* Build ``oregistry`` of all ophyd objects. Maintenance ------------