Skip to content

Commit

Permalink
explicitly set processing times to null for failed jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
jtherrmann committed Nov 11, 2024
1 parent fe4da80 commit 862ebd6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions apps/check-processing-time/src/check_processing_time.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Union, Optional


def get_time_from_result(result: Union[list, dict]) -> Union[list, float]:
Expand All @@ -13,9 +13,9 @@ def get_time_from_result(result: Union[list, dict]) -> Union[list, float]:
return processing_time


def lambda_handler(event, _) -> list[Union[list, float]]:
def lambda_handler(event, _) -> Optional[list[Union[list, float]]]:
if event['processing_failed']:
raise ValueError('refusing to calculate processing times for failed job')
return None

processing_results = event['processing_results']
result_list = [processing_results[key] for key in sorted(processing_results.keys())]
Expand Down
3 changes: 1 addition & 2 deletions tests/test_check_processing_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,4 @@ def test_lambda_handler_failed_job():
},
}
}
with pytest.raises(ValueError, match=r'^refusing to calculate processing times for failed job$'):
check_processing_time.lambda_handler(event, None)
assert check_processing_time.lambda_handler(event, None) is None

0 comments on commit 862ebd6

Please sign in to comment.