Skip to content

Commit

Permalink
ci: print results in job logs (#2561)
Browse files Browse the repository at this point in the history
This modification allows:
- printing the results in the terminal
- running the script from the terminal (without the environment variables from CI)
The yaml report is only built in CI, but the results are always printed.
  • Loading branch information
cathales authored Oct 22, 2024
1 parent 67a6ae9 commit c1c2f9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
8 changes: 0 additions & 8 deletions .gitlab-ci/scripts/report_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,5 @@
report.add_metric(score_metric)
report.dump()

filename = re.sub(r"[^\w\.\\\/]", "_", os.environ["CI_JOB_NAME"])
path = "artifacts/reports/" + filename + ".yml"
with open(path, "r") as f:
log = [l.strip() for l in f.readlines()]
for index, line in enumerate(log):
if "MHz" in line or "cycles" in line:
print(log[index + 1], log[index])

if report.failed:
sys.exit(1)
17 changes: 12 additions & 5 deletions .gitlab-ci/scripts/report_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,19 @@ def to_doc(self):

def dump(self, path=None):
"""
Create report file
Print results and create report file
By default the output path is build from $CI_JOB_NAME
"""
for metric in self.metrics:
print(metric.values)

if path is None:
filename = re.sub(r'[^\w\.\\\/]', '_', os.environ["CI_JOB_NAME"])
path = 'artifacts/reports/'+filename+'.yml'
with open(path, 'w') as f:
yaml.dump(self.to_doc(), f)
ci_job_name = os.environ.get("CI_JOB_NAME")
if ci_job_name is not None:
filename = re.sub(r'[^\w\.\\\/]', '_', ci_job_name)
path = 'artifacts/reports/'+filename+'.yml'

if path is not None:
with open(path, 'w') as f:
yaml.dump(self.to_doc(), f)

0 comments on commit c1c2f9d

Please sign in to comment.