Skip to content

Commit 44fe021

Browse files
committed
Move cryolo model function to util
1 parent 32205ba commit 44fe021

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/murfey/util/processing_params.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1+
from datetime import datetime
2+
from functools import lru_cache
3+
from pathlib import Path
14
from typing import Literal, Optional
25

36
from pydantic import BaseModel
47

8+
from murfey.util.config import get_machine_config
9+
10+
11+
@lru_cache(maxsize=5)
12+
def _cryolo_model_path(visit: str, instrument_name: str) -> Path:
13+
machine_config = get_machine_config(instrument_name=instrument_name)[
14+
instrument_name
15+
]
16+
if machine_config.model_search_directory:
17+
visit_directory = (
18+
machine_config.rsync_basepath / str(datetime.now().year) / visit
19+
)
20+
possible_models = list(
21+
(visit_directory / machine_config.model_search_directory).glob("*.h5")
22+
)
23+
if possible_models:
24+
return sorted(possible_models, key=lambda x: x.stat().st_ctime)[-1]
25+
return machine_config.default_model
26+
527

628
class CLEMAlignAndMergeParameters(BaseModel):
729
crop_to_n_frames: Optional[int] = 50

0 commit comments

Comments
 (0)