Skip to content

Commit b7545b3

Browse files
elelayshAlex-Welsh
andauthored
multinode periodic: show inputs in summary (#2038)
* Multinode periodic: show chosen inputs in summary * multinode-inputs.py: better help text Co-authored-by: Alex Welsh <112560678+Alex-Welsh@users.noreply.github.com> --------- Co-authored-by: Alex Welsh <112560678+Alex-Welsh@users.noreply.github.com>
1 parent 7fa6ac4 commit b7545b3

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

.github/workflows/multinode-inputs.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# The test scenario is randomly selected.
33
# The inputs are printed to stdout in GitHub step output key=value format.
44

5+
import argparse
56
from dataclasses import dataclass
67
import random
78
import typing as t
@@ -43,6 +44,16 @@ class Scenario:
4344

4445

4546
def main() -> None:
47+
48+
parser = argparse.ArgumentParser(
49+
description='Randomly picks a multinode scenario to execute')
50+
parser.add_argument(
51+
'--output-summary', '-s',
52+
type=argparse.FileType('w', encoding='UTF-8'),
53+
default=None,
54+
help="Write a markdown summary table of selected inputs to a file (use '-' to write to stdout)")
55+
args = parser.parse_args()
56+
4657
scenario = random_scenario()
4758
inputs = {
4859
"os_distribution": scenario.os_release.distribution,
@@ -57,6 +68,8 @@ def main() -> None:
5768
}
5869
for name, value in inputs.items():
5970
write_output(name, value)
71+
if args.output_summary:
72+
write_summary(inputs, args.output_summary)
6073

6174

6275
def random_scenario() -> Scenario:
@@ -84,5 +97,13 @@ def write_output(name: str, value: str) -> None:
8497
print(f"{name}={value}")
8598

8699

100+
def write_summary(inputs: dict, output: t.TextIO):
101+
print(
102+
'| Input | Value |\n'
103+
'| -----: | :---- |', file=output)
104+
for key, value in inputs.items():
105+
print(f'| **{key}** | `{value}` |', file=output)
106+
107+
87108
if __name__ == "__main__":
88109
main()

.github/workflows/stackhpc-multinode-periodic.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828
- name: Generate inputs for multinode workflow
2929
id: generate-inputs
3030
run: |
31-
python3 .github/workflows/multinode-inputs.py >> $GITHUB_OUTPUT
31+
python3 .github/workflows/multinode-inputs.py -s "$GITHUB_STEP_SUMMARY" \
32+
| tee -a "$GITHUB_OUTPUT"
3233
3334
- name: Display generated inputs
3435
run: |

0 commit comments

Comments
 (0)