Skip to content

Commit

Permalink
Extend TF request id with global counter
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaarreell committed Nov 5, 2024
1 parent 29c21ae commit 8e7f0d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions newa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 """
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion newa/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<br>', '\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 += "<br>{id}: {state}, {result}".format(**results[req])
Expand Down

0 comments on commit 8e7f0d3

Please sign in to comment.