Skip to content

Commit f2c09d7

Browse files
authored
only return a message if reconstruction successful (#531)
* only return a message if reconstruction successful * remove unnecessary return
1 parent 41e0331 commit f2c09d7

File tree

1 file changed

+2
-11
lines changed
  • operators/quantem-direct-ptycho

1 file changed

+2
-11
lines changed

operators/quantem-direct-ptycho/run.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,12 @@ def quantem_direct_ptycho(
259259
'rotation_angle': direct_ptycho.rotation_angle,
260260
},
261261
}
262+
header = MessageHeader(subject=MessageSubject.BYTES, meta=output_meta)
263+
return BytesMessage(header=header, data=output_bytes)
262264
except Exception as e:
263-
zeros_out = np.zeros(accumulator.scan_shape, dtype=np.uint8)
264265
logger.exception(
265266
f"Direct ptychography reconstruction failed for scan {scan_number}: {e}"
266267
)
267-
output_bytes = zeros_out.tobytes()
268-
output_meta = {
269-
"scan_number": scan_number,
270-
"accumulated_messages": accumulator.num_batches_added,
271-
"shape": zeros_out.shape,
272-
"dtype": str(zeros_out.dtype),
273-
"source_operator": "quantem-direct-ptycho-failed",
274-
}
275268
finally:
276269
if QUANTEM_DEVICE == "gpu":
277270
try:
@@ -281,5 +274,3 @@ def quantem_direct_ptycho(
281274
gc.collect()
282275
except Exception:
283276
logger.exception("Failed to clean up DirectPtychography resources.")
284-
header = MessageHeader(subject=MessageSubject.BYTES, meta=output_meta)
285-
return BytesMessage(header=header, data=output_bytes)

0 commit comments

Comments
 (0)