From 332536822b19af9411bae9ad699f8fd020c233c5 Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Fri, 21 Aug 2026 15:58:41 +0100 Subject: [PATCH] Problems introduced by doppio branch --- src/murfey/cli/repost_failed_calls.py | 14 ++++++++++---- src/murfey/server/api/workflow.py | 22 ++++++++++------------ src/murfey/util/processing_params.py | 5 +++-- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/murfey/cli/repost_failed_calls.py b/src/murfey/cli/repost_failed_calls.py index e7f0c7f32..859547b59 100644 --- a/src/murfey/cli/repost_failed_calls.py +++ b/src/murfey/cli/repost_failed_calls.py @@ -1,6 +1,7 @@ import argparse import asyncio import json +import os from datetime import datetime from functools import partial from inspect import getfullargspec, iscoroutinefunction @@ -10,10 +11,6 @@ from sqlmodel import Session, create_engine from workflows.transport.pika_transport import PikaTransport -from murfey.server.murfey_db import url -from murfey.server.run import _set_up_transport -from murfey.util.config import security_from_file - def dlq_purge( dlq_dump_path: Path, queue: str, rabbitmq_credentials: Path @@ -191,10 +188,17 @@ def run(): args = parser.parse_args() # Read the security config file + os.environ["MURFEY_SECURITY_CONFIGURATION"] = args.config + + from murfey.util.config import security_from_file + security_config = security_from_file(args.config) # Configure the transport PikaTransport().load_configuration_file(security_config.rabbitmq_credentials) + + from murfey.server.run import _set_up_transport + _set_up_transport("PikaTransport") # Now import transport object which was set up in the above step @@ -212,6 +216,8 @@ def run(): ) # Set up database and retry api calls + from murfey.server.murfey_db import url + _url = url(security_config) engine = create_engine(_url) with Session(engine) as murfey_db: diff --git a/src/murfey/server/api/workflow.py b/src/murfey/server/api/workflow.py index a235a113c..1d5e7b4d3 100644 --- a/src/murfey/server/api/workflow.py +++ b/src/murfey/server/api/workflow.py @@ -34,15 +34,15 @@ from murfey.util.config import get_security_config - keycloak_client = KeycloakClient( - load_keycloak_config( - Path( - os.getenv("SMARTEM_KEYCLOAK_CONFIGURATION") - or get_security_config().smartem_keycloak_config - ) - ) - ) - SMARTEM_ACTIVE = True + if keycloak_config := ( + os.getenv("SMARTEM_KEYCLOAK_CONFIGURATION") + or get_security_config().smartem_keycloak_config + ): + keycloak_client = KeycloakClient(load_keycloak_config(Path(keycloak_config))) + SMARTEM_ACTIVE = True + else: + keycloak_client = None + SMARTEM_ACTIVE = False except ImportError: keycloak_client = None SMARTEM_ACTIVE = False @@ -695,8 +695,6 @@ async def request_spa_preprocessing( "Failed to register micrograph with smartem", exc_info=True ) - db.close() - recipe_name = machine_config.recipes.get( "em-spa-preprocess", "em-spa-preprocess" ) @@ -741,7 +739,7 @@ async def request_spa_preprocessing( f"Pre-processing was requested for {sanitise(Path(proc_file.path).name)} " "but no Zocalo transport object was found" ) - return proc_file + db.close() else: for_stash = PreprocessStash( diff --git a/src/murfey/util/processing_params.py b/src/murfey/util/processing_params.py index 6cf1fbc46..918106775 100644 --- a/src/murfey/util/processing_params.py +++ b/src/murfey/util/processing_params.py @@ -79,8 +79,9 @@ def motion_corrected_mrc( else: parts = [secure_filename(p) for p in input_movie.parts] visit_idx = parts.index(visit_name) - core = Path(*parts[: visit_idx + 1]) - ppath = Path(*parts) + # Include leading slash which is removed in the secure parts above + core = Path("/") / Path(*parts[: visit_idx + 1]) + ppath = Path("/") / Path(*parts) if machine_config.process_multiple_datasets: sub_dataset = ppath.relative_to(core).parts[0] else: