Skip to content

Commit

Permalink
do not bother checking if stop time > start time
Browse files Browse the repository at this point in the history
  • Loading branch information
jtherrmann committed Nov 12, 2024
1 parent ebe243a commit 7c0ef7f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
7 changes: 1 addition & 6 deletions apps/check-processing-time/src/check_processing_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ def get_time_from_result(result: Union[list, dict]) -> Union[list, float]:
if isinstance(result, list):
return [get_time_from_result(item) for item in result]

processing_time = (result['StoppedAt'] - result['StartedAt']) / 1000

if processing_time <= 0.0:
raise ValueError(f'{processing_time} <= 0.0')

return processing_time
return (result['StoppedAt'] - result['StartedAt']) / 1000


def lambda_handler(event, _) -> list[Union[list, float]]:
Expand Down
45 changes: 0 additions & 45 deletions tests/test_check_processing_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,48 +27,3 @@ def test_lambda_handler():
}
}
assert check_processing_time.lambda_handler(event, None) == [5.7, 6.4, [5.9, 0.2]]


def test_lambda_handler_invalid_result():
event = {
'processing_results': {
'step_0': {
'StartedAt': 1000,
'StoppedAt': 1000,
}
}
}
with pytest.raises(ValueError, match=r'^0.0 <= 0.0$'):
check_processing_time.lambda_handler(event, None)

event = {
'processing_results': {
'step_0': {
'StartedAt': 2000,
'StoppedAt': 1000,
}
}
}
with pytest.raises(ValueError, match=r'^-1.0 <= 0.0$'):
check_processing_time.lambda_handler(event, None)

event = {
'processing_results': {
'step_0': {
'StartedAt': 3000,
'StoppedAt': 8700,
},
'step_1': [
{
'StartedAt': 3000,
'StoppedAt': 8900,
},
{
'StartedAt': 4200,
'StoppedAt': 4000,
},
]
}
}
with pytest.raises(ValueError, match=r'^-0.2 <= 0.0$'):
check_processing_time.lambda_handler(event, None)

0 comments on commit 7c0ef7f

Please sign in to comment.