Skip to content

Commit f3e1b83

Browse files
Raise an exception if no 2D murfey ids present (#683)
We keep hitting a case where no ids get sent to 2D classification. It's not clear why this happens, but if we don't have ids to send it would be better to just raise an exception in murfey. Also I've changed the fixed number of 50 ids to the value in the default parameters (which is also 50 currently).
1 parent d9c3e64 commit f3e1b83

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/murfey/server/feedback.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ def _2d_class_murfey_ids(particles_file: str, app_id: int, _db) -> Dict[str, int
241241
db.Class2D.particles_file == particles_file and db.Class2D.pj_id == pj_id
242242
)
243243
).all()
244+
if not classes:
245+
raise ValueError(f"No 2D classification IDs found for {particles_file}")
244246
return {str(cl.class_number): cl.murfey_id for cl in classes}
245247

246248

@@ -256,6 +258,8 @@ def _3d_class_murfey_ids(particles_file: str, app_id: int, _db) -> Dict[str, int
256258
and db.Class3D.pj_id == pj_id
257259
)
258260
).all()
261+
if not classes:
262+
raise ValueError(f"No 3D classification IDs found for {particles_file}")
259263
return {str(cl.class_number): cl.murfey_id for cl in classes}
260264

261265

@@ -623,7 +627,9 @@ def _register_incomplete_2d_batch(message: dict, _db, demo: bool = False):
623627
)
624628
_db.add(class2d_params)
625629
_db.commit()
626-
murfey_ids = _murfey_id(message["program_id"], _db, number=50)
630+
murfey_ids = _murfey_id(
631+
message["program_id"], _db, number=default_spa_parameters.nr_classes_2d
632+
)
627633
_murfey_class2ds(
628634
murfey_ids, class2d_message["particles_file"], message["program_id"], _db
629635
)
@@ -747,7 +753,9 @@ def _register_complete_2d_batch(message: dict, _db, demo: bool = False):
747753
_db.add(class2d_params)
748754
_db.commit()
749755
_db.close()
750-
murfey_ids = _murfey_id(_app_id(pj_id, _db), _db, number=50)
756+
murfey_ids = _murfey_id(
757+
_app_id(pj_id, _db), _db, number=default_spa_parameters.nr_classes_2d
758+
)
751759
_murfey_class2ds(
752760
murfey_ids, class2d_message["particles_file"], _app_id(pj_id, _db), _db
753761
)
@@ -796,7 +804,13 @@ def _register_complete_2d_batch(message: dict, _db, demo: bool = False):
796804
else:
797805
class_uuids = {
798806
str(i + 1): m
799-
for i, m in enumerate(_murfey_id(_app_id(pj_id, _db), _db, number=50))
807+
for i, m in enumerate(
808+
_murfey_id(
809+
_app_id(pj_id, _db),
810+
_db,
811+
number=default_spa_parameters.nr_classes_2d,
812+
)
813+
)
800814
}
801815
class2d_grp_uuid = _murfey_id(_app_id(pj_id, _db), _db)[0]
802816
zocalo_message: dict = {
@@ -865,7 +879,13 @@ def _register_complete_2d_batch(message: dict, _db, demo: bool = False):
865879
else:
866880
class_uuids = {
867881
str(i + 1): m
868-
for i, m in enumerate(_murfey_id(_app_id(pj_id, _db), _db, number=50))
882+
for i, m in enumerate(
883+
_murfey_id(
884+
_app_id(pj_id, _db),
885+
_db,
886+
number=default_spa_parameters.nr_classes_2d,
887+
)
888+
)
869889
}
870890
class2d_grp_uuid = _murfey_id(_app_id(pj_id, _db), _db)[0]
871891
zocalo_message = {

0 commit comments

Comments
 (0)