Skip to content

Commit ed3ca0f

Browse files
Always update the tilt series length in the database after an mdoc (#307)
1 parent e34fa88 commit ed3ca0f

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

src/murfey/client/contexts/tomo.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,21 @@ def post_transfer(
835835
),
836836
environment=environment,
837837
)
838+
839+
# Always update the tilt series length in the database after an mdoc
840+
if environment.murfey_session is not None:
841+
length_url = f"{str(environment.url.geturl())}/sessions/{environment.murfey_session}/tilt_series_length"
842+
capture_post(
843+
length_url,
844+
json={
845+
"tags": [tilt_series],
846+
"source": str(transferred_file.parent),
847+
"tilt_series_lengths": [
848+
self._tilt_series_sizes[tilt_series]
849+
],
850+
},
851+
)
852+
838853
if completed_tilts and environment:
839854
logger.info(
840855
f"The following tilt series are considered complete: {completed_tilts} "

src/murfey/server/__init__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,20 @@ def feedback_callback(header: dict, message: dict) -> None:
22102210
.where(db.AutoProcProgram.id == message["program_id"])
22112211
).one()
22122212
session_id = collected_ids[0].session_id
2213+
2214+
# Find the autoprocprogram id for the alignment recipe
2215+
alignment_ids = murfey_db.exec(
2216+
select(
2217+
db.DataCollection,
2218+
db.ProcessingJob,
2219+
db.AutoProcProgram,
2220+
)
2221+
.where(db.ProcessingJob.dc_id == db.DataCollection.id)
2222+
.where(db.AutoProcProgram.pj_id == db.ProcessingJob.id)
2223+
.where(db.DataCollection.id == collected_ids[1].id)
2224+
.where(db.ProcessingJob.recipe == message["em-tomo-align"])
2225+
).one()
2226+
22132227
relevant_tilt_and_series = murfey_db.exec(
22142228
select(db.Tilt, db.TiltSeries)
22152229
.where(db.Tilt.movie_path == message.get("movie"))
@@ -2230,7 +2244,7 @@ def feedback_callback(header: dict, message: dict) -> None:
22302244

22312245
machine_config = get_machine_config()
22322246
tilts = get_all_tilts(relevant_tilt_series.id)
2233-
ids = get_job_ids(relevant_tilt_series.id, message["program_id"])
2247+
ids = get_job_ids(relevant_tilt_series.id, alignment_ids[2].id)
22342248
preproc_params = get_tomo_preproc_params(ids.dcgid)
22352249
stack_file = (
22362250
Path(message["mrc_out"]).parents[1]

src/murfey/server/api.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,25 @@ def register_tilt_series(
574574
db.commit()
575575

576576

577+
@router.post("/sessions/{session_id}/tilt_series_length")
578+
def register_tilt_series_length(
579+
session_id: int,
580+
tilt_series_group: TiltSeriesGroupInfo,
581+
db=murfey_db,
582+
):
583+
tilt_series_db = db.exec(
584+
select(TiltSeries)
585+
.where(col(TiltSeries.tag).in_(tilt_series_group.tags))
586+
.where(TiltSeries.session_id == session_id)
587+
.where(TiltSeries.rsync_source == tilt_series_group.source)
588+
).all()
589+
for ts in tilt_series_db:
590+
ts_index = tilt_series_group.tags.index(ts.tag)
591+
ts.tilt_series_length = tilt_series_group.tilt_series_lengths[ts_index]
592+
db.add(ts)
593+
db.commit()
594+
595+
577596
@router.post("/visits/{visit_name}/{client_id}/completed_tilt_series")
578597
def register_completed_tilt_series(
579598
visit_name: str,
@@ -609,6 +628,7 @@ def register_completed_tilt_series(
609628
DataCollectionGroup, DataCollection, ProcessingJob, AutoProcProgram
610629
)
611630
.where(DataCollectionGroup.session_id == session_id)
631+
.where(DataCollectionGroup.tag == tilt_series_group.source)
612632
.where(DataCollection.tag == ts.tag)
613633
.where(DataCollection.dcg_id == DataCollectionGroup.id)
614634
.where(ProcessingJob.dc_id == DataCollection.id)

0 commit comments

Comments
 (0)