Skip to content

Commit

Permalink
Add option to wait until jobs finish before exiting
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Wilk <colin.wilk@tum.de>
  • Loading branch information
kliwniloc committed Jul 13, 2024
1 parent 2cddfe8 commit 693b35f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/benchmarking_tool/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ def __schedule_every_2_hours(self) -> None:
def __init__(self) -> None:
pass

def trigger_benchmark(self) -> None:
def trigger_benchmark(self) -> list:
trigger_time: datetime.datetime = datetime.datetime.now()
wave_id: str = str(uuid.uuid4())
l.info("Triggering Benchmark")
all_results: list = []
for filename in self.filenames:
groups: list = []
for worker_group in self.worker_groups:
Expand All @@ -106,7 +107,9 @@ def trigger_benchmark(self) -> None:
groups.append(grouped_tasks)

chained_tasks = chain(*groups)
chained_tasks.apply_async()
result = chained_tasks.apply_async()
all_results.append(result)
return all_results

def run(self) -> NoReturn:
self.__schedule_every_2_hours()
Expand Down
11 changes: 10 additions & 1 deletion src/benchmarking_tool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@
help="Trigger a Job immediately and then exit. Useful for testing",
action="store_true",
)
parser_coordinator.add_argument(
"-w",
"--wait",
help="Wait for all Jobs to finish before exiting.",
action="store_true",
)

if __name__ == "__main__":
args = parser.parse_args()
Expand All @@ -179,6 +185,9 @@
Coordinator().set_worker_groups(args.groups).set_filenames(args.filenames)
)
if args.trigger:
coordinator.trigger_benchmark()
all_results: list = coordinator.trigger_benchmark()
if args.wait:
for result in all_results:
result.get()
else:
coordinator.run()

0 comments on commit 693b35f

Please sign in to comment.