Skip to content

Commit 6554f4e

Browse files
committed
Handle missing primary stream in amptek export
When a scan is stopped or aborted prematurely there is no primary stream, causing has_amptek_keys to raise an error and flagging the workflow as failed. Check for the primary stream and return False so the workflow completes successfully instead of erroring.
1 parent 92b70d9 commit 6554f4e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

export.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
@task
1111
def has_amptek_keys(uid, api_key=None):
1212
run = get_run(uid, api_key=api_key)
13+
if "primary" not in run:
14+
logger = get_run_logger()
15+
logger.info(
16+
f"No primary stream found for {uid} (scan may have been stopped or "
17+
"aborted prematurely); skipping amptek export."
18+
)
19+
return False
1320
return all(k in run.primary.data for k in ("amptek_energy_channels", "amptek_mca_spectrum"))
1421

1522

0 commit comments

Comments
 (0)