Skip to content
Merged
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
38 changes: 0 additions & 38 deletions src/murfey/server/api/spa.py

This file was deleted.

9 changes: 6 additions & 3 deletions src/murfey/server/api/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import murfey.server.prometheus as prom
from murfey.server import _transport_object
from murfey.server.api.auth import MurfeySessionID, validate_token
from murfey.server.api.spa import _cryolo_model_path
from murfey.server.feedback import (
_murfey_id,
check_tilt_series_mc,
Expand Down Expand Up @@ -58,7 +57,11 @@
TiltSeries,
)
from murfey.util.models import ProcessingParametersSPA, ProcessingParametersTomo
from murfey.util.processing_params import default_spa_parameters, motion_corrected_mrc
from murfey.util.processing_params import (
cryolo_model_path,
default_spa_parameters,
motion_corrected_mrc,
)
from murfey.util.tomo import midpoint

logger = getLogger("murfey.server.api.workflow")
Expand Down Expand Up @@ -457,7 +460,7 @@ async def request_spa_preprocessing(
),
"do_icebreaker_jobs": default_spa_parameters.do_icebreaker_jobs,
"cryolo_model_weights": str(
_cryolo_model_path(visit_name, instrument_name)
cryolo_model_path(visit_name, instrument_name)
),
},
}
Expand Down
2 changes: 0 additions & 2 deletions src/murfey/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import murfey.server.api.prometheus
import murfey.server.api.session_control
import murfey.server.api.session_info
import murfey.server.api.spa
import murfey.server.api.websocket
import murfey.server.api.workflow
from murfey.server import template_files
Expand Down Expand Up @@ -90,7 +89,6 @@ class Settings(BaseSettings):
app.include_router(murfey.server.api.workflow.correlative_router)
app.include_router(murfey.server.api.workflow.spa_router)
app.include_router(murfey.server.api.workflow.tomo_router)
app.include_router(murfey.server.api.spa.router)
app.include_router(murfey.server.api.clem.router)

app.include_router(murfey.server.api.prometheus.router)
Expand Down
21 changes: 20 additions & 1 deletion src/murfey/util/processing_params.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from datetime import datetime
from functools import lru_cache
from pathlib import Path
from typing import Literal, Optional

from pydantic import BaseModel
from werkzeug.utils import secure_filename

from murfey.util.config import MachineConfig
from murfey.util.config import MachineConfig, get_machine_config


def motion_corrected_mrc(
Expand Down Expand Up @@ -33,6 +35,23 @@
return Path("/".join(secure_filename(p) for p in mrc_out.parts))


@lru_cache(maxsize=5)
def cryolo_model_path(visit: str, instrument_name: str) -> Path:
machine_config = get_machine_config(instrument_name=instrument_name)[

Check warning on line 40 in src/murfey/util/processing_params.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/util/processing_params.py#L40

Added line #L40 was not covered by tests
instrument_name
]
if machine_config.model_search_directory:
visit_directory = (

Check warning on line 44 in src/murfey/util/processing_params.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/util/processing_params.py#L44

Added line #L44 was not covered by tests
machine_config.rsync_basepath / str(datetime.now().year) / visit
)
possible_models = list(

Check warning on line 47 in src/murfey/util/processing_params.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/util/processing_params.py#L47

Added line #L47 was not covered by tests
(visit_directory / machine_config.model_search_directory).glob("*.h5")
)
if possible_models:
return sorted(possible_models, key=lambda x: x.stat().st_ctime)[-1]
return machine_config.default_model

Check warning on line 52 in src/murfey/util/processing_params.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/util/processing_params.py#L51-L52

Added lines #L51 - L52 were not covered by tests


class CLEMAlignAndMergeParameters(BaseModel):
crop_to_n_frames: Optional[int] = 50
align_self: Literal["enabled", ""] = "enabled"
Expand Down
8 changes: 0 additions & 8 deletions src/murfey/util/route_manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -980,14 +980,6 @@ murfey.server.api.session_info.tomo_router:
type: str
methods:
- GET
murfey.server.api.spa.router:
- path: /sessions/{session_id}/cryolo_model
function: get_cryolo_model_path
path_params:
- name: session_id
type: int
methods:
- GET
murfey.server.api.websocket.ws:
- path: /ws/test/{client_id}
function: websocket_endpoint
Expand Down
22 changes: 12 additions & 10 deletions src/murfey/workflows/spa/flush_spa_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from murfey.util.db import Session as MurfeySession
from murfey.util.db import SPAFeedbackParameters, SPARelionParameters
from murfey.util.models import FoilHoleParameters, GridSquareParameters
from murfey.util.processing_params import default_spa_parameters
from murfey.util.processing_params import cryolo_model_path, default_spa_parameters
from murfey.util.spa_metadata import (
GridSquareInfo,
foil_hole_data,
Expand Down Expand Up @@ -314,15 +314,12 @@
).all()
if not stashed_files:
return True
instrument_name = (
murfey_db.exec(
select(MurfeySession).where(MurfeySession.id == message["session_id"])
)
.one()
.instrument_name
)
machine_config = get_machine_config(instrument_name=instrument_name)[
instrument_name

murfey_session = murfey_db.exec(

Check warning on line 318 in src/murfey/workflows/spa/flush_spa_preprocess.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/workflows/spa/flush_spa_preprocess.py#L318

Added line #L318 was not covered by tests
select(MurfeySession).where(MurfeySession.id == message["session_id"])
).one()
machine_config = get_machine_config(instrument_name=murfey_session.instrument_name)[

Check warning on line 321 in src/murfey/workflows/spa/flush_spa_preprocess.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/workflows/spa/flush_spa_preprocess.py#L321

Added line #L321 was not covered by tests
murfey_session.instrument_name
]
recipe_name = machine_config.recipes.get("em-spa-preprocess", "em-spa-preprocess")
collected_ids = murfey_db.exec(
Expand Down Expand Up @@ -424,6 +421,11 @@
else f.eer_fractionation_file
),
"do_icebreaker_jobs": default_spa_parameters.do_icebreaker_jobs,
"cryolo_model_weights": str(
cryolo_model_path(
murfey_session.visit, murfey_session.instrument_name
)
),
"foil_hole_id": foil_hole_id,
},
}
Expand Down