Skip to content

Do not error if the batch positions list is empty#631

Merged
stephen-riggs merged 3 commits intomainfrom
tomo-metadat-fix
Jul 15, 2025
Merged

Do not error if the batch positions list is empty#631
stephen-riggs merged 3 commits intomainfrom
tomo-metadat-fix

Conversation

@stephen-riggs
Copy link
Contributor

Very minor change. Currently the post transfer function gets an error when the batch positions list contains no positions, which this fixes.

@stephen-riggs stephen-riggs requested a review from d-j-hatton July 14, 2025 14:06
@codecov
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

Attention: Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Project coverage is 32.93%. Comparing base (d7ed7cb) to head (39a58d6).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -57,6 +57,9 @@ def post_transfer(

windows_path = session_data["TomographySession"]["AtlasId"]
Copy link
Contributor

@tieneupin tieneupin Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same principle here about safely handling KeyError exceptions.

Copy link
Contributor

@tieneupin tieneupin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions for safely handling potential KeyErrors when calling values fro mthe dictionaries.

@stephen-riggs stephen-riggs merged commit 7a14ecc into main Jul 15, 2025
17 checks passed
@stephen-riggs stephen-riggs deleted the tomo-metadat-fix branch July 15, 2025 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants