Skip to content

Commit b45ec53

Browse files
committed
Wrong id probably being returned
1 parent 76f7136 commit b45ec53

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/murfey/workflows/spa/flush_spa_preprocess.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def register_foil_hole(
110110
gs_name: int,
111111
foil_hole_params: FoilHoleParameters,
112112
murfey_db: Session,
113-
) -> bool:
113+
) -> Optional[int]:
114114
try:
115115
gs = murfey_db.exec(
116116
select(GridSquare)
@@ -123,7 +123,7 @@ def register_foil_hole(
123123
logger.warning(
124124
f"Foil hole {sanitise(str(foil_hole_params.name))} could not be registered as grid square {sanitise(str(gs_name))} was not found"
125125
)
126-
return False
126+
return None
127127
secured_foil_hole_image_path = secure_filename(foil_hole_params.image)
128128
if foil_hole_params.image and Path(secured_foil_hole_image_path).is_file():
129129
jpeg_size = Image.open(secured_foil_hole_image_path).size
@@ -193,7 +193,7 @@ def register_foil_hole(
193193
murfey_db.add(foil_hole)
194194
murfey_db.commit()
195195
murfey_db.close()
196-
return True
196+
return foil_hole.id
197197

198198

199199
def _grid_square_metadata_file(f: Path, grid_square: int) -> Optional[Path]:
@@ -288,10 +288,7 @@ def _flush_position_analysis(
288288
name=foil_hole,
289289
)
290290
# Insert or update this foil hole in the database
291-
registered_hole = register_foil_hole(
292-
session_id, gs.id, foil_hole_parameters, murfey_db
293-
)
294-
return foil_hole if registered_hole else None
291+
return register_foil_hole(session_id, gs.id, foil_hole_parameters, murfey_db)
295292

296293

297294
def flush_spa_preprocess(message: dict, murfey_db: Session, demo: bool = False) -> bool:

0 commit comments

Comments
 (0)