|
3 | 3 |
|
4 | 4 | from pydantic import BaseModel |
5 | 5 | from sqlmodel import select |
| 6 | +from sqlmodel.orm.session import Session as SQLModelSession |
6 | 7 | from werkzeug.utils import secure_filename |
7 | 8 |
|
8 | 9 | from murfey.server import _transport_object |
@@ -35,7 +36,7 @@ def process_sxt_tilt_series( |
35 | 36 | visit_name: str, |
36 | 37 | session_id: MurfeySessionID, |
37 | 38 | tilt_series_info: SXTTiltSeriesInfo, |
38 | | - murfey_db: Session, |
| 39 | + murfey_db: SQLModelSession, |
39 | 40 | ) -> dict[str, bool]: |
40 | 41 | tilt_series_query = murfey_db.exec( |
41 | 42 | select(TiltSeries) |
@@ -82,30 +83,22 @@ def process_sxt_tilt_series( |
82 | 83 | instrument_name |
83 | 84 | ] |
84 | 85 |
|
| 86 | + # Find the visit folder and any subfolders needed |
85 | 87 | parts = [secure_filename(p) for p in Path(tilt_series_info.txrm).parts] |
86 | 88 | visit_idx = parts.index(visit_name) |
87 | 89 | core = Path(*Path(tilt_series_info.txrm).parts[: visit_idx + 1]) |
88 | 90 | ppath = Path( |
89 | 91 | "/".join(secure_filename(p) for p in Path(tilt_series_info.txrm).parts) |
90 | 92 | ) |
91 | | - sub_dataset = "/".join(ppath.relative_to(core).parts[:-1]) |
92 | | - extra_path = machine_config.processed_extra_directory |
93 | | - stack_file = ( |
94 | | - core |
95 | | - / machine_config.processed_directory_name |
96 | | - / sub_dataset |
97 | | - / extra_path |
98 | | - / "Tomograms" |
99 | | - / f"{tilt_series.tag}_stack.mrc" |
100 | | - ) |
101 | | - stack_file.parent.mkdir(parents=True, exist_ok=True) |
| 93 | + sub_dataset = "/".join(ppath.relative_to(core).parts[1:-1]) |
102 | 94 |
|
103 | 95 | # Loop over all processing jobs, and send the alignment recipe for it |
104 | 96 | for recipe_ids in collected_ids: |
105 | | - # Stack file path needs to contain both recipe name and tilt series anem |
| 97 | + # Stack file path needs to contain both recipe name and tilt series name |
106 | 98 | stack_file = ( |
107 | 99 | core |
108 | 100 | / machine_config.processed_directory_name |
| 101 | + / sub_dataset |
109 | 102 | / tilt_series.tag |
110 | 103 | / recipe_ids[2].recipe |
111 | 104 | / "Tomograms" |
@@ -143,3 +136,12 @@ def process_sxt_tilt_series( |
143 | 136 | murfey_db.add(tilt_series) |
144 | 137 | murfey_db.commit() |
145 | 138 | return {"success": True} |
| 139 | + |
| 140 | + |
| 141 | +def run(message: dict, murfey_db: SQLModelSession) -> dict[str, bool]: |
| 142 | + return process_sxt_tilt_series( |
| 143 | + message["visit_name"], |
| 144 | + message["session_id"], |
| 145 | + SXTTiltSeriesInfo(**message["tilt_series_info"]), |
| 146 | + murfey_db, |
| 147 | + ) |
0 commit comments