Include test name in TSV log filenames
Concept spec calls for `<testname>.tsv`. Filename is now `<testname>-<station>-<ts>.tsv` so reruns of the same test name don't clobber prior runs and multiple stations stay distinguishable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d7b35b2f5c
commit
c3bffec4ff
3 changed files with 21 additions and 3 deletions
|
|
@ -11,9 +11,10 @@ class TsvLogger:
|
|||
received: <ts> received <packet_id> <text>
|
||||
"""
|
||||
|
||||
def __init__(self, station: str, log_dir: str | Path = "."):
|
||||
def __init__(self, station: str, log_dir: str | Path = ".", test_name: str | None = None):
|
||||
Path(log_dir).mkdir(parents=True, exist_ok=True)
|
||||
path = Path(log_dir) / f"{station}-{int(time())}.tsv"
|
||||
prefix = f"{test_name}-{station}" if test_name else station
|
||||
path = Path(log_dir) / f"{prefix}-{int(time())}.tsv"
|
||||
self._fh: IO = open(path, "a", buffering=1) # line-buffered
|
||||
self.path = path
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,11 @@ class TestStation:
|
|||
cues = cuesheet.build(cue_params)
|
||||
print(f"[run] {len(cues)} cases, ~{(cues[-1].done_at - base_t) / 3600:.2f}h, base_t={base_t}")
|
||||
|
||||
self._logger = TsvLogger(self.cfg.this_station_name, self.cfg.log_dir)
|
||||
self._logger = TsvLogger(
|
||||
self.cfg.this_station_name,
|
||||
self.cfg.log_dir,
|
||||
test_name=params["name"],
|
||||
)
|
||||
|
||||
try:
|
||||
for cue in cues:
|
||||
|
|
|
|||
|
|
@ -35,3 +35,16 @@ def test_tsv_logger_creates_log_dir(tmp_path):
|
|||
logger.close()
|
||||
assert sub.is_dir()
|
||||
assert logger.path.exists()
|
||||
|
||||
|
||||
def test_tsv_logger_filename_includes_test_name(tmp_path):
|
||||
logger = TsvLogger("A", tmp_path, test_name="run42")
|
||||
logger.close()
|
||||
assert logger.path.name.startswith("run42-A-")
|
||||
assert logger.path.name.endswith(".tsv")
|
||||
|
||||
|
||||
def test_tsv_logger_filename_without_test_name(tmp_path):
|
||||
logger = TsvLogger("A", tmp_path)
|
||||
logger.close()
|
||||
assert logger.path.name.startswith("A-")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue