Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/murfey/cli/repost_failed_calls.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
22 changes: 10 additions & 12 deletions src/murfey/server/api/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
)
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions src/murfey/util/processing_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading