From 4ac3c9b51436dfb6de4e96ae6f60d1c2221f72ad Mon Sep 17 00:00:00 2001 From: "Preiss, Sandy" Date: Fri, 26 Apr 2024 09:39:48 -0400 Subject: [PATCH] Make start date a command line argument for clone_failed_jobs.py instead of a constant. Improve docstrings and type hints. --- crcsim/experiment/clone_failed_jobs.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crcsim/experiment/clone_failed_jobs.py b/crcsim/experiment/clone_failed_jobs.py index 9f9ec9a..ae33e87 100644 --- a/crcsim/experiment/clone_failed_jobs.py +++ b/crcsim/experiment/clone_failed_jobs.py @@ -1,17 +1,19 @@ from datetime import datetime +from typing import Dict, List import boto3 from botocore.config import Config +from fire import Fire from crcsim.experiment.simulate import get_seed_list def get_failed_jobs( start_date: str, job_queue: str, batch_client: boto3.client -) -> list: +) -> List[Dict[str, str]]: """ - Returns a list of dicts with the permutation number and table script number for each - failed job in the job queue. + Checks the given AWS Batch job queue for failed jobs created after the given + start date. Returns the senario and iteration for each failed job. """ start_datetime = datetime.strptime(start_date, "%Y-%m-%d") # convert to milliseconds to match the timestamp format returned by list_jobs @@ -31,6 +33,7 @@ def get_failed_jobs( def main( + start_date: str, n_people: int = 100_000, job_queue: str = "crcsim", job_definition: str = "crcsim:3", @@ -38,7 +41,7 @@ def main( my_config = Config(region_name="us-east-2") batch = boto3.client("batch", config=my_config) - failed_job_params = get_failed_jobs("2024-04-19", job_queue, batch) + failed_job_params = get_failed_jobs(start_date, job_queue, batch) seeds = get_seed_list() @@ -67,4 +70,4 @@ def main( if __name__ == "__main__": - main() + Fire(main)