Skip to content

Commit 005f2c6

Browse files
committed
Merged recent changes from 'main' branch
2 parents 97fef8d + 443fec9 commit 005f2c6

File tree

14 files changed

+668
-57
lines changed

14 files changed

+668
-57
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ GitHub = "https://github.com/DiamondLightSource/python-murfey"
110110
"data_collection_group" = "murfey.workflows.register_data_collection_group:run"
111111
"pato" = "murfey.workflows.notifications:notification_setup"
112112
"picked_particles" = "murfey.workflows.spa.picking:particles_picked"
113+
"picked_tomogram" = "murfey.workflows.tomo.picking:picked_tomogram"
113114
"spa.flush_spa_preprocess" = "murfey.workflows.spa.flush_spa_preprocess:flush_spa_preprocess"
114115

115116
[tool.setuptools]

src/murfey/cli/inject_spa_processing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
from murfey.util.config import get_machine_config, get_microscope, get_security_config
1414
from murfey.util.db import (
1515
AutoProcProgram,
16+
ClassificationFeedbackParameters,
1617
ClientEnvironment,
1718
DataCollection,
1819
DataCollectionGroup,
1920
Movie,
2021
ProcessingJob,
21-
SPAFeedbackParameters,
2222
SPARelionParameters,
2323
)
2424
from murfey.util.processing_params import default_spa_parameters
@@ -137,9 +137,9 @@ def run():
137137
.where(ProcessingJob.recipe == "em-spa-preprocess")
138138
).one()
139139
params = murfey_db.exec(
140-
select(SPARelionParameters, SPAFeedbackParameters)
140+
select(SPARelionParameters, ClassificationFeedbackParameters)
141141
.where(SPARelionParameters.pj_id == collected_ids[2].id)
142-
.where(SPAFeedbackParameters.pj_id == SPARelionParameters.pj_id)
142+
.where(ClassificationFeedbackParameters.pj_id == SPARelionParameters.pj_id)
143143
).one()
144144
proc_params: dict | None = dict(params[0])
145145
feedback_params = params[1]

src/murfey/cli/spa_ispyb_messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def run():
363363
small_boxsize=metadata["small_boxsize"],
364364
mask_diameter=metadata["mask_diameter"],
365365
)
366-
feedback_params = db.SPAFeedbackParameters(
366+
feedback_params = db.ClassificationFeedbackParameters(
367367
pj_id=collected_ids[2].id,
368368
estimate_particle_diameter=not bool(metadata["particle_diameter"]),
369369
hold_class2d=False,

src/murfey/client/contexts/tomo.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,13 @@ def register_tomography_data_collections(
161161
data=dc_data,
162162
)
163163

164-
for recipe in ("em-tomo-preprocess", "em-tomo-align"):
164+
recipes_to_assign_pjids = [
165+
"em-tomo-preprocess",
166+
"em-tomo-align",
167+
]
168+
if not self._tilt_series_with_pjids:
169+
recipes_to_assign_pjids.append("em-tomo-class2d")
170+
for recipe in recipes_to_assign_pjids:
165171
capture_post(
166172
base_url=str(environment.url.geturl()),
167173
router_name="workflow.router",

src/murfey/server/api/session_info.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from murfey.util import sanitise
3535
from murfey.util.config import MachineConfig
3636
from murfey.util.db import (
37+
ClassificationFeedbackParameters,
3738
ClientEnvironment,
3839
DataCollection,
3940
DataCollectionGroup,
@@ -44,7 +45,6 @@
4445
RsyncInstance,
4546
Session,
4647
SessionProcessingParameters,
47-
SPAFeedbackParameters,
4848
SPARelionParameters,
4949
Tilt,
5050
TiltSeries,
@@ -283,7 +283,7 @@ class ProcessingDetails(BaseModel):
283283
data_collections: List[DataCollection]
284284
processing_jobs: List[ProcessingJob]
285285
relion_params: SPARelionParameters
286-
feedback_params: SPAFeedbackParameters
286+
feedback_params: ClassificationFeedbackParameters
287287

288288

289289
@spa_router.get("/sessions/{session_id}/spa_processing_parameters")
@@ -296,13 +296,13 @@ def get_spa_proc_param_details(
296296
DataCollection,
297297
ProcessingJob,
298298
SPARelionParameters,
299-
SPAFeedbackParameters,
299+
ClassificationFeedbackParameters,
300300
)
301301
.where(DataCollectionGroup.session_id == session_id)
302302
.where(DataCollectionGroup.id == DataCollection.dcg_id)
303303
.where(DataCollection.id == ProcessingJob.dc_id)
304304
.where(SPARelionParameters.pj_id == ProcessingJob.id)
305-
.where(SPAFeedbackParameters.pj_id == ProcessingJob.id)
305+
.where(ClassificationFeedbackParameters.pj_id == ProcessingJob.id)
306306
).all()
307307
if not params:
308308
return None

src/murfey/server/api/workflow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from murfey.util.config import get_machine_config
4545
from murfey.util.db import (
4646
AutoProcProgram,
47+
ClassificationFeedbackParameters,
4748
DataCollection,
4849
DataCollectionGroup,
4950
FoilHole,
@@ -54,7 +55,6 @@
5455
SearchMap,
5556
Session,
5657
SessionProcessingParameters,
57-
SPAFeedbackParameters,
5858
SPARelionParameters,
5959
Tilt,
6060
TiltSeries,
@@ -409,9 +409,9 @@ async def request_spa_preprocessing(
409409
.where(ProcessingJob.recipe == "em-spa-preprocess")
410410
).one()
411411
params = db.exec(
412-
select(SPARelionParameters, SPAFeedbackParameters)
412+
select(SPARelionParameters, ClassificationFeedbackParameters)
413413
.where(SPARelionParameters.pj_id == collected_ids[2].id)
414-
.where(SPAFeedbackParameters.pj_id == SPARelionParameters.pj_id)
414+
.where(ClassificationFeedbackParameters.pj_id == SPARelionParameters.pj_id)
415415
).one()
416416
proc_params: Optional[dict] = dict(params[0])
417417
feedback_params = params[1]

src/murfey/server/demo_api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
)
5050
from murfey.util.db import (
5151
AutoProcProgram,
52+
ClassificationFeedbackParameters,
5253
ClientEnvironment,
5354
DataCollection,
5455
DataCollectionGroup,
@@ -60,7 +61,6 @@
6061
ProcessingJob,
6162
RsyncInstance,
6263
Session,
63-
SPAFeedbackParameters,
6464
SPARelionParameters,
6565
Tilt,
6666
TiltSeries,
@@ -244,7 +244,7 @@ class ProcessingDetails(BaseModel):
244244
data_collections: List[DataCollection]
245245
processing_jobs: List[ProcessingJob]
246246
relion_params: SPARelionParameters
247-
feedback_params: SPAFeedbackParameters
247+
feedback_params: ClassificationFeedbackParameters
248248

249249

250250
@router.get("/sessions/{session_id}/spa_processing_parameters")
@@ -257,13 +257,13 @@ def get_spa_proc_param_details(
257257
DataCollection,
258258
ProcessingJob,
259259
SPARelionParameters,
260-
SPAFeedbackParameters,
260+
ClassificationFeedbackParameters,
261261
)
262262
.where(DataCollectionGroup.session_id == session_id)
263263
.where(DataCollectionGroup.id == DataCollection.dcg_id)
264264
.where(DataCollection.id == ProcessingJob.dc_id)
265265
.where(SPARelionParameters.pj_id == ProcessingJob.id)
266-
.where(SPAFeedbackParameters.pj_id == ProcessingJob.id)
266+
.where(ClassificationFeedbackParameters.pj_id == ProcessingJob.id)
267267
).all()
268268
if not params:
269269
return None
@@ -560,9 +560,9 @@ def flush_spa_processing(
560560
.where(ProcessingJob.recipe == "em-spa-preprocess")
561561
).one()
562562
params = db.exec(
563-
select(SPARelionParameters, SPAFeedbackParameters)
563+
select(SPARelionParameters, ClassificationFeedbackParameters)
564564
.where(SPARelionParameters.pj_id == collected_ids[2].id)
565-
.where(SPAFeedbackParameters.pj_id == SPARelionParameters.pj_id)
565+
.where(ClassificationFeedbackParameters.pj_id == SPARelionParameters.pj_id)
566566
).one()
567567
proc_params = dict(params[0])
568568
feedback_params = params[1]

src/murfey/server/feedback.py

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,15 @@ def _pj_id(app_id: int, _db, recipe: str = "") -> int:
316316

317317
def _get_spa_params(
318318
app_id: int, _db
319-
) -> Tuple[db.SPARelionParameters, db.SPAFeedbackParameters]:
319+
) -> Tuple[db.SPARelionParameters, db.ClassificationFeedbackParameters]:
320320
pj_id = _pj_id(app_id, _db, recipe="em-spa-preprocess")
321321
relion_params = _db.exec(
322322
select(db.SPARelionParameters).where(db.SPARelionParameters.pj_id == pj_id)
323323
).one()
324324
feedback_params = _db.exec(
325-
select(db.SPAFeedbackParameters).where(db.SPAFeedbackParameters.pj_id == pj_id)
325+
select(db.ClassificationFeedbackParameters).where(
326+
db.ClassificationFeedbackParameters.pj_id == pj_id
327+
)
326328
).one()
327329
_db.expunge(relion_params)
328330
_db.expunge(feedback_params)
@@ -415,8 +417,8 @@ def _release_3d_hold(message: dict, _db):
415417
)
416418
).one()
417419
feedback_params = _db.exec(
418-
select(db.SPAFeedbackParameters).where(
419-
db.SPAFeedbackParameters.pj_id == pj_id_params
420+
select(db.ClassificationFeedbackParameters).where(
421+
db.ClassificationFeedbackParameters.pj_id == pj_id_params
420422
)
421423
).one()
422424
class3d_params = _db.exec(
@@ -493,8 +495,8 @@ def _release_refine_hold(message: dict, _db):
493495
)
494496
).one()
495497
feedback_params = _db.exec(
496-
select(db.SPAFeedbackParameters).where(
497-
db.SPAFeedbackParameters.pj_id == pj_id_params
498+
select(db.ClassificationFeedbackParameters).where(
499+
db.ClassificationFeedbackParameters.pj_id == pj_id_params
498500
)
499501
).one()
500502
refine_params = _db.exec(
@@ -585,8 +587,8 @@ def _register_incomplete_2d_batch(message: dict, _db, demo: bool = False):
585587
)
586588
).one()
587589
feedback_params = _db.exec(
588-
select(db.SPAFeedbackParameters).where(
589-
db.SPAFeedbackParameters.pj_id == pj_id_params
590+
select(db.ClassificationFeedbackParameters).where(
591+
db.ClassificationFeedbackParameters.pj_id == pj_id_params
590592
)
591593
).one()
592594
if feedback_params.hold_class2d:
@@ -711,8 +713,8 @@ def _register_complete_2d_batch(message: dict, _db, demo: bool = False):
711713
)
712714
).one()
713715
feedback_params = _db.exec(
714-
select(db.SPAFeedbackParameters).where(
715-
db.SPAFeedbackParameters.pj_id == pj_id_params
716+
select(db.ClassificationFeedbackParameters).where(
717+
db.ClassificationFeedbackParameters.pj_id == pj_id_params
716718
)
717719
).one()
718720
_db.expunge(relion_params)
@@ -932,7 +934,7 @@ def _flush_class2d(
932934
app_id: int,
933935
_db,
934936
relion_params: db.SPARelionParameters | None = None,
935-
feedback_params: db.SPAFeedbackParameters | None = None,
937+
feedback_params: db.ClassificationFeedbackParameters | None = None,
936938
):
937939
instrument_name = (
938940
_db.exec(select(db.Session).where(db.Session.id == session_id))
@@ -953,8 +955,8 @@ def _flush_class2d(
953955
_db.expunge(relion_params)
954956
if not feedback_params:
955957
feedback_params = _db.exec(
956-
select(db.SPAFeedbackParameters).where(
957-
db.SPAFeedbackParameters.pj_id == pj_id_params
958+
select(db.ClassificationFeedbackParameters).where(
959+
db.ClassificationFeedbackParameters.pj_id == pj_id_params
958960
)
959961
).one()
960962
_db.expunge(feedback_params)
@@ -1031,8 +1033,8 @@ def _register_class_selection(message: dict, _db, demo: bool = False):
10311033
).all()
10321034
# Add the class selection score to the database
10331035
feedback_params = _db.exec(
1034-
select(db.SPAFeedbackParameters).where(
1035-
db.SPAFeedbackParameters.pj_id == pj_id_params
1036+
select(db.ClassificationFeedbackParameters).where(
1037+
db.ClassificationFeedbackParameters.pj_id == pj_id_params
10361038
)
10371039
).one()
10381040
_db.expunge(feedback_params)
@@ -1252,8 +1254,8 @@ def _register_3d_batch(message: dict, _db, demo: bool = False):
12521254
).one()
12531255
relion_options = dict(relion_params)
12541256
feedback_params = _db.exec(
1255-
select(db.SPAFeedbackParameters).where(
1256-
db.SPAFeedbackParameters.pj_id == pj_id_params
1257+
select(db.ClassificationFeedbackParameters).where(
1258+
db.ClassificationFeedbackParameters.pj_id == pj_id_params
12571259
)
12581260
).one()
12591261
other_options = dict(feedback_params)
@@ -1430,8 +1432,8 @@ def _register_initial_model(message: dict, _db, demo: bool = False):
14301432
pj_id_params = _pj_id(message["program_id"], _db, recipe="em-spa-preprocess")
14311433
# Add the initial model file to the database
14321434
feedback_params = _db.exec(
1433-
select(db.SPAFeedbackParameters).where(
1434-
db.SPAFeedbackParameters.pj_id == pj_id_params
1435+
select(db.ClassificationFeedbackParameters).where(
1436+
db.ClassificationFeedbackParameters.pj_id == pj_id_params
14351437
)
14361438
).one()
14371439
feedback_params.initial_model = message.get("initial_model")
@@ -1597,8 +1599,8 @@ def _register_refinement(message: dict, _db, demo: bool = False):
15971599
).one()
15981600
relion_options = dict(relion_params)
15991601
feedback_params = _db.exec(
1600-
select(db.SPAFeedbackParameters).where(
1601-
db.SPAFeedbackParameters.pj_id == pj_id_params
1602+
select(db.ClassificationFeedbackParameters).where(
1603+
db.ClassificationFeedbackParameters.pj_id == pj_id_params
16021604
)
16031605
).one()
16041606
other_options = dict(feedback_params)
@@ -1745,8 +1747,8 @@ def _register_bfactors(message: dict, _db, demo: bool = False):
17451747
).one()
17461748
relion_options = dict(relion_params)
17471749
feedback_params = _db.exec(
1748-
select(db.SPAFeedbackParameters).where(
1749-
db.SPAFeedbackParameters.pj_id == pj_id_params
1750+
select(db.ClassificationFeedbackParameters).where(
1751+
db.ClassificationFeedbackParameters.pj_id == pj_id_params
17501752
)
17511753
).one()
17521754

@@ -2155,7 +2157,7 @@ def feedback_callback(header: dict, message: dict, _db=murfey_db) -> None:
21552157
eer_fractionation_file=message["eer_fractionation_file"],
21562158
symmetry=message["symmetry"],
21572159
)
2158-
feedback_params = db.SPAFeedbackParameters(
2160+
feedback_params = db.ClassificationFeedbackParameters(
21592161
pj_id=collected_ids[2].id,
21602162
estimate_particle_diameter=True,
21612163
hold_class2d=False,
@@ -2212,7 +2214,18 @@ def feedback_callback(header: dict, message: dict, _db=murfey_db) -> None:
22122214
gain_ref=message["gain_ref"],
22132215
eer_fractionation_file=message["eer_fractionation_file"],
22142216
)
2217+
feedback_params = db.ClassificationFeedbackParameters(
2218+
pj_id=collected_ids[2].id,
2219+
estimate_particle_diameter=True,
2220+
hold_class2d=False,
2221+
hold_class3d=False,
2222+
class_selection_score=0,
2223+
star_combination_job=0,
2224+
initial_model="",
2225+
next_job=0,
2226+
)
22152227
_db.add(params)
2228+
_db.add(feedback_params)
22162229
_db.commit()
22172230
_db.close()
22182231
if murfey.server._transport_object:

0 commit comments

Comments
 (0)