Skip to content

Commit 96ff3d5

Browse files
committed
refactor: [report] remove old report dir versioning
This mechanism for replacing dirs with timestamped dirs at the point when the individual dirs want to be replaced is causing a number of side effects. For example rstmgr_cnsty_chk report is generated in the sub dir of rstmgr. Given the simple logic for backing up previous report generations, depending on the order each flow config is processed the backup logic renames dirs generated in the same run. This commit removes the backup logic altogether with the intention of doing any backup at the root dir instead. This means that in the short term reports will be overwritten, opening the door for incremental builds. Backing up will have to be performed manually and the scratch dir purged before running if a fresh run is required. It's unclear at this stage what an automated backup solution would look like? Ideally changes in the src files would be determined and new incremental build only running the jobs required to generate the changed output artefacts. Signed-off-by: James McCorrie <james.mccorrie@lowrisc.org>
1 parent c9cd75f commit 96ff3d5

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/dvsim/cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import subprocess
2929
import sys
3030
import textwrap
31-
from collections.abc import Sequence
3231
from pathlib import Path
3332

3433
from dvsim.flow.factory import make_cfg

src/dvsim/flow/base.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
import os
88
import pprint
99
import sys
10+
from collections.abc import Mapping
1011
from pathlib import Path
1112

1213
import hjson
1314

1415
from dvsim.flow.hjson import set_target_attribute
16+
from dvsim.job.deploy import Deploy
1517
from dvsim.launcher.factory import get_launcher_cls
1618
from dvsim.logging import log
1719
from dvsim.scheduler import Scheduler
1820
from dvsim.utils import (
19-
clean_odirs,
2021
find_and_substitute_wildcards,
2122
md_results_to_html,
2223
mk_path,
@@ -93,7 +94,7 @@ def __init__(self, flow_cfg_file, hjson_data, args, mk_config) -> None:
9394
self.timestamp = args.timestamp
9495

9596
# Results
96-
self.errors_seen = False
97+
self.errors_seen: bool = False
9798
self.rel_path = ""
9899
self.results_title = ""
99100
self.revision = ""
@@ -401,16 +402,17 @@ def deploy_objects(self):
401402

402403
return Scheduler(deploy, get_launcher_cls(), self.interactive).run()
403404

404-
def _gen_results(self, results) -> None:
405-
"""The function is called after the flow has completed. It collates
406-
the status of all run targets and generates a dict. It parses the log
405+
def _gen_results(self, results: Mapping[Deploy, str]) -> None:
406+
"""Generate results.
407+
408+
The function is called after the flow has completed. It collates the
409+
status of all run targets and generates a dict. It parses the log
407410
to identify the errors, warnings and failures as applicable. It also
408411
prints the full list of failures for debug / triage to the final
409412
report, which is in markdown format.
410413
411414
results should be a dictionary mapping deployed item to result.
412415
"""
413-
return
414416

415417
def gen_results(self, results) -> None:
416418
"""Public facing API for _gen_results().
@@ -435,9 +437,8 @@ def gen_results(self, results) -> None:
435437

436438
def gen_results_summary(self) -> None:
437439
"""Public facing API to generate summary results for each IP/cfg file."""
438-
return
439440

440-
def write_results(self, html_filename, text_md, json_str=None) -> None:
441+
def write_results(self, html_filename: str, text_md: str, json_str: str | None = None) -> None:
441442
"""Write results to files.
442443
443444
This function converts text_md to HTML and writes the result to a file
@@ -446,24 +447,23 @@ def write_results(self, html_filename, text_md, json_str=None) -> None:
446447
file with the same path and base name as the HTML file but with '.json'
447448
as suffix.
448449
"""
449-
# Prepare reports directory, keeping 90 day history.
450-
clean_odirs(odir=self.results_dir, max_odirs=89)
451-
mk_path(self.results_dir)
450+
results_dir = Path(self.results_dir)
451+
mk_path(results_dir)
452452

453453
# Write results to the report area.
454-
with open(self.results_dir / html_filename, "w") as f:
455-
f.write(md_results_to_html(self.results_title, self.css_file, text_md))
454+
(results_dir / html_filename).write_text(
455+
md_results_to_html(self.results_title, self.css_file, text_md)
456+
)
456457

457458
if json_str is not None:
458459
filename = Path(html_filename).with_suffix(".json")
459-
with open(self.results_dir / filename, "w") as f:
460-
f.write(json_str)
460+
(results_dir / filename).write_text(json_str)
461461

462-
def _get_results_page_link(self, relative_to, link_text="") -> str:
462+
def _get_results_page_link(self, relative_to: str, link_text: str = "") -> str:
463463
"""Create a relative markdown link to the results page."""
464464
link_text = link_text if link_text else self.name.upper()
465465
relative_link = os.path.relpath(self.results_page, relative_to)
466466
return f"[{link_text}]({relative_link})"
467467

468-
def has_errors(self):
468+
def has_errors(self) -> bool:
469469
return self.errors_seen

0 commit comments

Comments
 (0)