-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1172 from ASFHyP3/append-processing-results
Compute processing time for each Batch job
- Loading branch information
Showing
7 changed files
with
134 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
import json | ||
|
||
|
||
def get_time_from_attempts(attempts): | ||
def get_time_from_attempts(attempts: list[dict]) -> float: | ||
if len(attempts) == 0: | ||
raise ValueError('no Batch job attempts') | ||
return 0 | ||
attempts.sort(key=lambda attempt: attempt['StoppedAt']) | ||
final_attempt = attempts[-1] | ||
return (final_attempt['StoppedAt'] - final_attempt['StartedAt']) / 1000 | ||
|
||
|
||
def lambda_handler(event, context): | ||
results = event['processing_results'] | ||
if 'Attempts' in results: | ||
attempts = results['Attempts'] | ||
def get_time_from_result(result: dict) -> float: | ||
if 'Attempts' in result: | ||
attempts = result['Attempts'] | ||
else: | ||
attempts = json.loads(results['Cause'])['Attempts'] | ||
attempts = json.loads(result['Cause'])['Attempts'] | ||
return get_time_from_attempts(attempts) | ||
|
||
|
||
def lambda_handler(event, context) -> list[float]: | ||
results_dict = event['processing_results'] | ||
results = [results_dict[key] for key in sorted(results_dict.keys())] | ||
return list(map(get_time_from_result, results)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.