From 8e7f0d31c683ad3ee44a6d3ef0058144f5efe5e1 Mon Sep 17 00:00:00 2001 From: Karel Srot Date: Fri, 1 Nov 2024 12:32:02 +0100 Subject: [PATCH] Extend TF request id with global counter --- newa/__init__.py | 15 +++++++++++++-- newa/cli.py | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/newa/__init__.py b/newa/__init__.py index 43be6ea..96834db 100644 --- a/newa/__init__.py +++ b/newa/__init__.py @@ -122,6 +122,16 @@ def render_template( raise Exception("Could not render template.") from exc +def global_request_counter() -> Iterator[int]: + i = 1 + while True: + yield i + i += 1 + + +gen_global_request_counter = global_request_counter() + + @define class Settings: """ Class storing newa settings """ @@ -790,8 +800,9 @@ def merge_combination_data( # now build Request instances total = len(filtered_combinations) for combination in filtered_combinations: - yield Request(id=f'REQ-{next(recipe_id_gen)}.{total}', - **combination) + yield Request( + id=f'REQ-{next(recipe_id_gen)}.{total}.{next(gen_global_request_counter)}', + **combination) @define diff --git a/newa/cli.py b/newa/cli.py index 55754fa..0fcaf7d 100644 --- a/newa/cli.py +++ b/newa/cli.py @@ -1068,7 +1068,7 @@ def cmd_report(ctx: CLIContext) -> None: launch_description += f'{jira_id}: ' launch_description += f'{len(jira_execute_job_mapping[jira_id])} request(s) in total:' jira_description = launch_description.replace('
', '\n') - for req in sorted(results.keys()): + for req in sorted(results.keys(), key=lambda x: int(x.split('.')[-1])): # it would be nice to use hyperlinks in launch description however we # would hit description length limit. Therefore using plain text launch_description += "
{id}: {state}, {result}".format(**results[req])