Do not error if the batch positions list is empty#631
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #631 +/- ##
==========================================
- Coverage 32.95% 32.93% -0.03%
==========================================
Files 90 90
Lines 11118 11125 +7
Branches 1465 1467 +2
==========================================
Hits 3664 3664
- Misses 7324 7331 +7
Partials 130 130 🚀 New features to boost your workflow:
|
| @@ -57,6 +57,9 @@ def post_transfer( | |||
|
|
|||
| windows_path = session_data["TomographySession"]["AtlasId"] | |||
There was a problem hiding this comment.
If we're referencing the keys "TomographySession" and "AtlasId" directly here, do we need logic to ensure KeyError exceptions are handled safely?
The other option is to do windows_path = session_data.get("TomographySession", {}).get("AtlasId", ""), which should exit safely in the if not windows_path: if-block down below.
| batch_positions_list = batch_xml["BatchPositionsList"]["BatchPositions"][ | ||
| "BatchPositionParameters" | ||
| ] | ||
| batch_positions_from_xml = batch_xml["BatchPositionsList"]["BatchPositions"] |
There was a problem hiding this comment.
Same principle here about safely handling KeyError exceptions.
tieneupin
left a comment
There was a problem hiding this comment.
Some suggestions for safely handling potential KeyErrors when calling values fro mthe dictionaries.
Very minor change. Currently the post transfer function gets an error when the batch positions list contains no positions, which this fixes.