From aeb6cd4fd76bc93196343d4d9bf3e5bec0738477 Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Fri, 27 Mar 2026 12:23:09 +0000 Subject: [PATCH 1/3] Make the murfey client config file optional --- src/murfey/client/context.py | 1 + src/murfey/client/contexts/atlas.py | 3 + src/murfey/client/contexts/clem.py | 2 + src/murfey/client/contexts/fib.py | 1 + src/murfey/client/contexts/spa.py | 5 ++ src/murfey/client/contexts/spa_metadata.py | 3 + src/murfey/client/contexts/sxt.py | 3 + src/murfey/client/contexts/tomo.py | 9 +++ src/murfey/client/contexts/tomo_metadata.py | 5 ++ src/murfey/client/destinations.py | 1 + src/murfey/client/multigrid_control.py | 16 +++++ src/murfey/instrument_server/__init__.py | 79 +++++++++++++-------- src/murfey/instrument_server/api.py | 6 +- src/murfey/server/api/prometheus.py | 4 ++ src/murfey/util/client.py | 4 +- 15 files changed, 108 insertions(+), 34 deletions(-) diff --git a/src/murfey/client/context.py b/src/murfey/client/context.py index 1aa4653ae..c64f713c8 100644 --- a/src/murfey/client/context.py +++ b/src/murfey/client/context.py @@ -201,6 +201,7 @@ def ensure_dcg_exists( router_name="workflow.router", function_name="register_dc_group", token=token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data=dcg_data, diff --git a/src/murfey/client/contexts/atlas.py b/src/murfey/client/contexts/atlas.py index f4a8f5149..52c00a0c8 100644 --- a/src/murfey/client/contexts/atlas.py +++ b/src/murfey/client/contexts/atlas.py @@ -55,6 +55,7 @@ def post_transfer_serialem( router_name="session_control.spa_router", function_name="register_atlas", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, data={ "name": transferred_file.stem, @@ -85,6 +86,7 @@ def post_transfer_epu( router_name="session_control.spa_router", function_name="make_atlas_jpg", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, data={"path": str(transferred_atlas_name).replace("//", "/")}, ) @@ -138,6 +140,7 @@ def post_transfer_epu( router_name="workflow.router", function_name="register_dc_group", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data=dcg_data, diff --git a/src/murfey/client/contexts/clem.py b/src/murfey/client/contexts/clem.py index ebb6df6d3..e3827c422 100644 --- a/src/murfey/client/contexts/clem.py +++ b/src/murfey/client/contexts/clem.py @@ -329,6 +329,7 @@ def process_lif_file( router_name="clem.router", function_name="process_raw_lifs", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, data={"lif_file": str(lif_file)}, ) @@ -353,6 +354,7 @@ def process_tiff_series( router_name="clem.router", function_name="process_raw_tiffs", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, data=tiff_dataset, ) diff --git a/src/murfey/client/contexts/fib.py b/src/murfey/client/contexts/fib.py index 453ceaece..8ae9b34f6 100644 --- a/src/murfey/client/contexts/fib.py +++ b/src/murfey/client/contexts/fib.py @@ -237,6 +237,7 @@ def post_transfer( router_name="workflow.correlative_router", function_name="make_gif", token=self._token, + instrument_name=environment.instrument_name, year=datetime.now().year, visit_name=environment.visit, session_id=environment.murfey_session, diff --git a/src/murfey/client/contexts/spa.py b/src/murfey/client/contexts/spa.py index f37a366ac..9bff4f19f 100644 --- a/src/murfey/client/contexts/spa.py +++ b/src/murfey/client/contexts/spa.py @@ -326,6 +326,7 @@ def _position_analysis( router_name="session_control.spa_router", function_name="register_grid_square", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, gsid=grid_square, data={ @@ -378,6 +379,7 @@ def _position_analysis( router_name="session_control.spa_router", function_name="register_foil_hole", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, gs_name=grid_square, data={ @@ -402,6 +404,7 @@ def _position_analysis( router_name="session_control.spa_router", function_name="register_foil_hole", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, gs_name=grid_square, data={ @@ -476,6 +479,7 @@ def post_transfer( router_name="file_io_instrument.router", function_name="write_eer_fractionation_file", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data={ @@ -539,6 +543,7 @@ def post_transfer( router_name="workflow.spa_router", function_name="request_spa_preprocessing", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data={ diff --git a/src/murfey/client/contexts/spa_metadata.py b/src/murfey/client/contexts/spa_metadata.py index 68d72889e..887d977bc 100644 --- a/src/murfey/client/contexts/spa_metadata.py +++ b/src/murfey/client/contexts/spa_metadata.py @@ -138,6 +138,7 @@ def post_transfer( router_name="session_control.spa_router", function_name="register_grid_square", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, gsid=int(gs), data={ @@ -213,6 +214,7 @@ def post_transfer( router_name="session_control.spa_router", function_name="register_grid_square", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, gsid=gs_name, data={ @@ -232,6 +234,7 @@ def post_transfer( router_name="session_control.spa_router", function_name="register_foil_hole", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, gs_name=gs_name, data={ diff --git a/src/murfey/client/contexts/sxt.py b/src/murfey/client/contexts/sxt.py index 2bbb4370d..8a3a4b43a 100644 --- a/src/murfey/client/contexts/sxt.py +++ b/src/murfey/client/contexts/sxt.py @@ -78,6 +78,7 @@ def register_sxt_data_collection( router_name="workflow.router", function_name="start_dc", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data=dc_data, @@ -92,6 +93,7 @@ def register_sxt_data_collection( router_name="workflow.router", function_name="register_proc", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data={ @@ -221,6 +223,7 @@ def post_transfer( router_name="workflow.sxt_router", function_name="process_sxt_tilt_series", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data={ diff --git a/src/murfey/client/contexts/tomo.py b/src/murfey/client/contexts/tomo.py index 130f1f00f..5dba3cbba 100644 --- a/src/murfey/client/contexts/tomo.py +++ b/src/murfey/client/contexts/tomo.py @@ -157,6 +157,7 @@ def register_tomography_data_collections( router_name="workflow.router", function_name="start_dc", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data=dc_data, @@ -174,6 +175,7 @@ def register_tomography_data_collections( router_name="workflow.router", function_name="register_proc", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data={ @@ -290,6 +292,7 @@ def _add_tilt( router_name="workflow.tomo_router", function_name="register_tilt_series_for_rerun", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, data=rerun_data, ) @@ -310,6 +313,7 @@ def _add_tilt( router_name="workflow.tomo_router", function_name="register_tilt_series", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, data=ts_data, ) @@ -345,6 +349,7 @@ def _add_tilt( router_name="workflow.tomo_router", function_name="register_tilt", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data=tilt_data, @@ -357,6 +362,7 @@ def _add_tilt( router_name="file_io_instrument.router", function_name="write_eer_fractionation_file", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data={ @@ -393,6 +399,7 @@ def _add_tilt( router_name="workflow.tomo_router", function_name="request_tomography_preprocessing", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data=preproc_data, @@ -498,6 +505,7 @@ def post_transfer( router_name="workflow.tomo_router", function_name="register_tilt_series_length", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, data={ "tags": [tilt_series], @@ -518,6 +526,7 @@ def post_transfer( router_name="workflow.tomo_router", function_name="register_completed_tilt_series", token=self._token, + instrument_name=environment.instrument_name, visit_name=environment.visit, session_id=environment.murfey_session, data={ diff --git a/src/murfey/client/contexts/tomo_metadata.py b/src/murfey/client/contexts/tomo_metadata.py index bd70d6724..0f67089e2 100644 --- a/src/murfey/client/contexts/tomo_metadata.py +++ b/src/murfey/client/contexts/tomo_metadata.py @@ -155,6 +155,7 @@ def post_transfer( router_name="session_control.tomo_router", function_name="register_search_map", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, sm_name=transferred_file.parent.name, data={ @@ -213,6 +214,7 @@ def post_transfer( router_name="session_control.tomo_router", function_name="register_search_map", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, sm_name=transferred_file.parent.name, data={ @@ -266,6 +268,7 @@ def post_transfer( router_name="session_control.tomo_router", function_name="register_search_map", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, sm_name=search_map_name, data={ @@ -279,6 +282,7 @@ def post_transfer( router_name="session_control.tomo_router", function_name="register_batch_position", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, batch_name=batch_name, data={ @@ -309,6 +313,7 @@ def post_transfer( router_name="session_control.tomo_router", function_name="register_batch_position", token=self._token, + instrument_name=environment.instrument_name, session_id=environment.murfey_session, batch_name=beamshift_name, data={ diff --git a/src/murfey/client/destinations.py b/src/murfey/client/destinations.py index 338d38207..ac6ec614b 100644 --- a/src/murfey/client/destinations.py +++ b/src/murfey/client/destinations.py @@ -78,6 +78,7 @@ def determine_default_destination( router_name="file_io_instrument.router", function_name="suggest_path", token=token, + instrument_name=environment.instrument_name, visit_name=visit, session_id=environment.murfey_session, data={ diff --git a/src/murfey/client/multigrid_control.py b/src/murfey/client/multigrid_control.py index 21ce2039a..de47ddeea 100644 --- a/src/murfey/client/multigrid_control.py +++ b/src/murfey/client/multigrid_control.py @@ -284,6 +284,7 @@ def _rsyncer_stopped(self, source: Path, explicit_stop: bool = False): router_name="session_control.router", function_name="register_stopped_rsyncer", token=self.token, + instrument_name=self._environment.instrument_name, session_id=self.session_id, data={"path": str(source)}, ) @@ -310,6 +311,7 @@ def _restart_rsyncer(self, source: Path): router_name="session_control.router", function_name="register_restarted_rsyncer", token=self.token, + instrument_name=self._environment.instrument_name, session_id=self.session_id, data={"path": str(source)}, ) @@ -338,6 +340,7 @@ def _start_rsyncer( router_name="file_io_instrument.router", function_name="make_rsyncer_destination", token=self.token, + instrument_name=self._environment.instrument_name, session_id=self.session_id, data={"destination": destination}, ) @@ -417,6 +420,7 @@ def rsync_result(update: RSyncerUpdate): router_name="session_control.router", function_name="register_restarted_rsyncer", token=self.token, + instrument_name=self._environment.instrument_name, session_id=self.session_id, data={"path": str(source)}, ) @@ -433,6 +437,7 @@ def rsync_result(update: RSyncerUpdate): router_name="session_control.router", function_name="register_rsyncer", token=self.token, + instrument_name=self._environment.instrument_name, session_id=self._environment.murfey_session, data=rsyncer_data, ) @@ -528,6 +533,7 @@ def _start_dc(self, metadata_json): router_name="file_io_instrument.router", function_name="write_eer_fractionation_file", token=self.token, + instrument_name=self._environment.instrument_name, visit_name=self._environment.visit, session_id=self._environment.murfey_session, data={ @@ -546,6 +552,7 @@ def _start_dc(self, metadata_json): router_name="workflow.tomo_router", function_name="register_tomo_proc_params", token=self.token, + instrument_name=self._environment.instrument_name, session_id=self._environment.murfey_session, data=metadata_json, ) @@ -554,6 +561,7 @@ def _start_dc(self, metadata_json): router_name="workflow.tomo_router", function_name="flush_tomography_processing", token=self.token, + instrument_name=self._environment.instrument_name, visit_name=self._environment.visit, session_id=self._environment.murfey_session, data={"rsync_source": str(source)}, @@ -603,6 +611,7 @@ def _start_dc(self, metadata_json): router_name="workflow.router", function_name="start_dc", token=self.token, + instrument_name=self._environment.instrument_name, visit_name=self._environment.visit, session_id=self.session_id, data=data, @@ -619,6 +628,7 @@ def _start_dc(self, metadata_json): router_name="workflow.router", function_name="register_proc", token=self.token, + instrument_name=self._environment.instrument_name, visit_name=self._environment.visit, session_id=self.session_id, data={ @@ -633,6 +643,7 @@ def _start_dc(self, metadata_json): router_name="workflow.spa_router", function_name="register_spa_proc_params", token=self.token, + instrument_name=self._environment.instrument_name, session_id=self.session_id, data={ **{k: None if v == "None" else v for k, v in metadata_json.items()}, @@ -646,6 +657,7 @@ def _start_dc(self, metadata_json): router_name="workflow.spa_router", function_name="flush_spa_processing", token=self.token, + instrument_name=self._environment.instrument_name, visit_name=self._environment.visit, session_id=self.session_id, data={"tag": str(source)}, @@ -674,6 +686,7 @@ def _increment_file_count( router_name="prometheus.router", function_name="increment_rsync_file_count", token=self.token, + instrument_name=self._environment.instrument_name, visit_name=self._environment.visit, data=data, ) @@ -707,6 +720,7 @@ def _increment_transferred_files_prometheus( router_name="prometheus.router", function_name="increment_rsync_transferred_files_prometheus", token=self.token, + instrument_name=self._environment.instrument_name, visit_name=self._environment.visit, data=data, ) @@ -723,6 +737,7 @@ def _increment_transferred_files( router_name="prometheus.router", function_name="increment_rsync_skipped_files_prometheus", token=self.token, + instrument_name=self._environment.instrument_name, visit_name=self._environment.visit, data={ "source": source, @@ -758,6 +773,7 @@ def _increment_transferred_files( router_name="prometheus.router", function_name="increment_rsync_transferred_files", token=self.token, + instrument_name=self._environment.instrument_name, visit_name=self._environment.visit, data=data, ) diff --git a/src/murfey/instrument_server/__init__.py b/src/murfey/instrument_server/__init__.py index f3c0e01d0..6a9a5299e 100644 --- a/src/murfey/instrument_server/__init__.py +++ b/src/murfey/instrument_server/__init__.py @@ -1,48 +1,35 @@ +import argparse import logging from urllib.parse import urlparse -from murfey.util.client import read_config - logger = logging.getLogger("murfey.instrument_server") +class MurfeyServerUrl: + url = "" + + +murfey_server_url = MurfeyServerUrl() + + def check_for_updates(): import murfey.client.update - murfey_url = urlparse( - read_config().get("Murfey", "server", fallback=""), allow_fragments=False - ) + murfey_url = urlparse(murfey_server_url.url, allow_fragments=False) try: murfey.client.update.check(murfey_url) except Exception as e: print(f"Murfey update check failed with {e}") -def start_instrument_server(): - import argparse - +def start_instrument_server(host: str, port: int): import uvicorn from rich.logging import RichHandler import murfey from murfey.util.api import url_path_for - from murfey.util.client import read_config from murfey.util.logging import HTTPSHandler, LogFilter - parser = argparse.ArgumentParser(description="Start the Murfey server") - parser.add_argument( - "--host", - help="Listen for incoming connections on a specific interface (IP address or hostname; default: all)", - default="0.0.0.0", - ) - parser.add_argument( - "--port", - help="Listen for incoming TCP connections on this port (default: 8001)", - type=int, - default=8001, - ) - args = parser.parse_args() - LogFilter.install() # Log everything from Murfey by default @@ -56,10 +43,8 @@ def start_instrument_server(): logging.getLogger("uvicorn").addHandler(rich_handler) # Construct URL for the HTTPS log handler - client_config = dict(read_config()["Murfey"]) - murfey_server_url = client_config["server"].rstrip("/") logger_url = ( - f"{murfey_server_url}{url_path_for('api.logging.router', 'forward_logs')}" + f"{murfey_server_url.url}{url_path_for('api.logging.router', 'forward_logs')}" ) # Forward DEBUG levels logs and above from Murfey to the backend @@ -74,13 +59,12 @@ def start_instrument_server(): logging.getLogger("uvicorn").addHandler(other_https_handler) logger.info( - f"Starting Murfey server version {murfey.__version__}, listening on {args.host}:{args.port}" + f"Starting Murfey server version {murfey.__version__}, listening on {host}:{port}" ) - global _running_server config = uvicorn.Config( "murfey.instrument_server.main:app", - host=args.host, - port=args.port, + host=host, + port=port, log_config=None, ws_ping_interval=300, ws_ping_timeout=300, @@ -93,5 +77,38 @@ def start_instrument_server(): def run(): + parser = argparse.ArgumentParser(description="Start the Murfey server") + parser.add_argument( + "--host", + help="Listen for incoming connections on a specific interface (IP address or hostname)", + type=str, + default="0.0.0.0", + ) + parser.add_argument( + "--port", + help="Listen for incoming TCP connections on this port (default: 8001)", + type=int, + default=8001, + ) + parser.add_argument( + "--server", + help="URL path to backend murfey server", + type=str, + default="", + ) + parser.add_argument( + "--instrument", + help="Name of this instrument in the murfey configuration", + type=str, + ) + args = parser.parse_args() + + if not args.server: + from murfey.util.client import read_config + + client_config = dict(read_config()["Murfey"]) + murfey_server_url.url = client_config["server"].rstrip("/") + else: + murfey_server_url.url = args.server check_for_updates() - start_instrument_server() + start_instrument_server(args.host, args.port) diff --git a/src/murfey/instrument_server/api.py b/src/murfey/instrument_server/api.py index 552a1c9a1..f26ba7a2d 100644 --- a/src/murfey/instrument_server/api.py +++ b/src/murfey/instrument_server/api.py @@ -21,6 +21,7 @@ from murfey.client.multigrid_control import MultigridController from murfey.client.rsync import RSyncer from murfey.client.watchdir_multigrid import MultigridDirWatcher +from murfey.instrument_server import murfey_server_url from murfey.util import posix_path, sanitise, sanitise_nonpath, secure_path from murfey.util.api import url_path_for from murfey.util.client import read_config @@ -84,7 +85,10 @@ def health(): def _get_murfey_url() -> str: - known_server = config["Murfey"].get("server") + if murfey_server_url.url: + known_server = murfey_server_url.url + else: + known_server = config["Murfey"].get("server") if not known_server: exit("Murfey server not set") if not known_server.startswith(("http://", "https://")): diff --git a/src/murfey/server/api/prometheus.py b/src/murfey/server/api/prometheus.py index 90a54db16..a30029215 100644 --- a/src/murfey/server/api/prometheus.py +++ b/src/murfey/server/api/prometheus.py @@ -105,6 +105,10 @@ def change_monitoring_status(visit_name: str, on: int): prom.monitoring_switch.labels(visit=visit_name).set(on) +def change_monitoring_end_time(timestamp): + prom.monitoring_end_time + + @router.get("/metrics/{metric_name}") def inspect_prometheus_metrics( metric_name: str, diff --git a/src/murfey/util/client.py b/src/murfey/util/client.py index f289caf23..4c92d645d 100644 --- a/src/murfey/util/client.py +++ b/src/murfey/util/client.py @@ -70,6 +70,7 @@ def capture_post( router_name: str, function_name: str, token: str, + instrument_name: str, data: Optional[dict] = None, **kwargs, ) -> requests.Response: @@ -86,11 +87,10 @@ def capture_post( f"Response to post to {url} with data {data} had status code " f"{response.status_code}. The reason given was {response.reason}" ) - client_config = read_config() failure_address = url_path_for( "session_control.router", "failed_client_post", - instrument_name=client_config["Murfey"]["instrument_name"], + instrument_name=instrument_name, ) failure_url = f"{base_url}{failure_address}" try: From 43a36be2fdce3b0285a0017dea37e8359509e2af Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Fri, 27 Mar 2026 12:35:45 +0000 Subject: [PATCH 2/3] Update tests --- tests/client/contexts/test_atlas.py | 6 ++++-- tests/client/test_context.py | 9 ++++++--- tests/client/test_destinations.py | 2 ++ tests/instrument_server/test_init.py | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/client/contexts/test_atlas.py b/tests/client/contexts/test_atlas.py index 08c1d9d41..7ab0081dc 100644 --- a/tests/client/contexts/test_atlas.py +++ b/tests/client/contexts/test_atlas.py @@ -23,7 +23,7 @@ def test_atlas_context_mrc(mock_capture_post, tmp_path): default_destinations={ tmp_path / "cm12345-6": f"{tmp_path}/destination/cm12345-6" }, - instrument_name="", + instrument_name="m01", visit="cm12345-6", murfey_session=1, ) @@ -42,6 +42,7 @@ def test_atlas_context_mrc(mock_capture_post, tmp_path): router_name="session_control.spa_router", function_name="make_atlas_jpg", token="token", + instrument_name="m01", session_id=1, data={"path": f"{tmp_path}/destination/{atlas_mrc.relative_to(tmp_path)}"}, ) @@ -56,7 +57,7 @@ def test_atlas_context_xml(mock_capture_post, tmp_path): default_destinations={ tmp_path / "cm12345-6": f"{tmp_path}/destination/cm12345-6" }, - instrument_name="", + instrument_name="m01", visit="cm12345-6", murfey_session=1, ) @@ -87,6 +88,7 @@ def test_atlas_context_xml(mock_capture_post, tmp_path): router_name="workflow.router", function_name="register_dc_group", token="token", + instrument_name="m01", visit_name="cm12345-6", session_id=1, data=dcg_data, diff --git a/tests/client/test_context.py b/tests/client/test_context.py index 1620e563a..860669551 100644 --- a/tests/client/test_context.py +++ b/tests/client/test_context.py @@ -15,7 +15,7 @@ def test_ensure_dcg_exists_tomo(mock_capture_post, tmp_path): tmp_path / "cm12345-6/metadata_folder": f"{tmp_path}/destination/cm12345-6/raw" }, - instrument_name="", + instrument_name="m01", visit="cm12345-6", murfey_session=1, ) @@ -57,6 +57,7 @@ def test_ensure_dcg_exists_tomo(mock_capture_post, tmp_path): router_name="workflow.router", function_name="register_dc_group", token="token", + instrument_name="m01", visit_name="cm12345-6", session_id=1, data=dcg_data, @@ -73,7 +74,7 @@ def test_ensure_dcg_exists_spa(mock_capture_post, tmp_path): tmp_path / "cm12345-6/metadata_folder": f"{tmp_path}/destination/cm12345-6/raw", }, - instrument_name="", + instrument_name="m01", visit="cm12345-6", murfey_session=1, ) @@ -118,6 +119,7 @@ def test_ensure_dcg_exists_spa(mock_capture_post, tmp_path): router_name="workflow.router", function_name="register_dc_group", token="token", + instrument_name="m01", visit_name="cm12345-6", session_id=1, data=dcg_data, @@ -131,7 +133,7 @@ def test_ensure_dcg_exists_spa_missing_xml(mock_capture_post, tmp_path): client_id=0, sources=[tmp_path], default_destinations={tmp_path: str(tmp_path)}, - instrument_name="", + instrument_name="m01", visit="cm12345-6", murfey_session=1, ) @@ -154,6 +156,7 @@ def test_ensure_dcg_exists_spa_missing_xml(mock_capture_post, tmp_path): router_name="workflow.router", function_name="register_dc_group", token="token", + instrument_name="m01", visit_name="cm12345-6", session_id=1, data=dcg_data, diff --git a/tests/client/test_destinations.py b/tests/client/test_destinations.py index 55375a865..a7ba14dbd 100644 --- a/tests/client/test_destinations.py +++ b/tests/client/test_destinations.py @@ -112,6 +112,7 @@ def test_determine_default_destinations_suggested_path(mock_post, mock_get, sour router_name="file_io_instrument.router", function_name="suggest_path", token="token", + instrument_name="m01", visit_name="cm12345-6", session_id=2, data={ @@ -162,6 +163,7 @@ def test_determine_default_destinations_short_path(mock_post, mock_get): router_name="file_io_instrument.router", function_name="suggest_path", token="token", + instrument_name="m01", visit_name="cm12345-6", session_id=2, data={ diff --git a/tests/instrument_server/test_init.py b/tests/instrument_server/test_init.py index 50015bae5..8d2c99831 100644 --- a/tests/instrument_server/test_init.py +++ b/tests/instrument_server/test_init.py @@ -13,7 +13,7 @@ import murfey from murfey.client.update import UPDATE_SUCCESS -from murfey.instrument_server import check_for_updates, start_instrument_server +from murfey.instrument_server import check_for_updates, run from murfey.server.api.bootstrap import pypi as pypi_router, version as version_router from murfey.util.api import url_path_for from murfey.util.logging import HTTPSHandler @@ -186,7 +186,7 @@ def test_start_instrument_server( sys.argv.extend(["--port", str(port)]) # Run the function - start_instrument_server() + run() # Check that the server was called with the correct arguments args, kwargs = mock_server.call_args From 5d116b6ed054ab7c448ce14f57ebcf19da7e249e Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Fri, 27 Mar 2026 15:48:23 +0000 Subject: [PATCH 3/3] Add example of server url --- src/murfey/instrument_server/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/murfey/instrument_server/__init__.py b/src/murfey/instrument_server/__init__.py index 6a9a5299e..28385cd1a 100644 --- a/src/murfey/instrument_server/__init__.py +++ b/src/murfey/instrument_server/__init__.py @@ -92,7 +92,7 @@ def run(): ) parser.add_argument( "--server", - help="URL path to backend murfey server", + help="URL path to backend murfey server e.g. http://murfey-server:8000", type=str, default="", )