Skip to content

Commit bcb4936

Browse files
committed
Improved test battery to use pre-cached datasets
1 parent 9b0800f commit bcb4936

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

.github/workflows/pre-commit.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,22 @@ jobs:
6868
# if: ${{ matrix.python-version == '3.6' }}
6969
# with:
7070
# extra_args: --all -c .pre-commit-config-gh-${{ matrix.python-version }}.yaml
71+
- name: CPU database cache
72+
id: cache-cpu-databases
73+
uses: actions/cache@v5
74+
with:
75+
path: |
76+
cpumark_table.csv
77+
cpu-spec-dataset
78+
key: cpu_databases
79+
- name: CPU database population
80+
if: steps.cache-cpu-databases.outputs.cache-hit != 'true'
81+
run: |
82+
python -m treecript.tdp_sources cpumark_table.tsv
83+
git clone https://github.com/JosuaCarl/cpu-spec-dataset
7184
- name: 'pytest + coverage (${{ matrix.python-version }})'
7285
run: |
73-
pytest --cov=treecript
86+
CACHED_CPU_SPEC_DATASET=${PWD}/cpu-spec-dataset CACHED_CPUMARK_DATASET=${PWD}/cpumark_table.tsv pytest --cov=treecript
7487
- name: Get transitive dependencies licences
7588
id: license_check_print_report
7689
# continue-on-error: true

tests/core/test_collector.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020

2121
import pytest
2222
import inspect
23+
import os
2324
import pathlib
2425
import shutil
2526
import subprocess
2627

2728
from treecript.collector import execution_metrics_collector
2829
from treecript.tdp_finder import tdp_finder_from_series
30+
from treecript import tdp_sources
2931

3032
from typing import (
3133
TYPE_CHECKING,
@@ -96,6 +98,12 @@ def test_tdp_finder_from_series(
9698
metrics_path = test_collector(tmpdir, command_line, should_fail)
9799

98100
spec_path = pathlib.Path(tmpdir) / "cpu_spec_dataset"
101+
# Try materialising from cached contents
102+
if not spec_path.exists():
103+
source_spec_path = os.environ.get("CACHED_CPU_SPEC_DATASET")
104+
if source_spec_path is not None and os.path.exists(source_spec_path):
105+
shutil.copytree(source_spec_path, spec_path)
106+
99107
if not spec_path.exists():
100108
git_path = shutil.which("git")
101109
assert git_path is not None, "git not found"
@@ -109,6 +117,20 @@ def test_tdp_finder_from_series(
109117

110118
assert len(processors_files) > 0
111119

120+
# Try materialising from cached contents
121+
cpumark_path = pathlib.Path(tmpdir) / "cpumark_table.csv"
122+
if not cpumark_path.exists():
123+
source_cpumark_path = os.environ.get("CACHED_CPUMARK_DATASET")
124+
if source_cpumark_path is not None and os.path.exists(source_cpumark_path):
125+
shutil.copy2(source_cpumark_path, cpumark_path, follow_symlinks=False)
126+
127+
if not cpumark_path.exists():
128+
tdp_sources.scrape_tdp_table_cpubenchmark(cpumark_path)
129+
130+
assert cpumark_path.is_file()
131+
132+
processors_files.append(cpumark_path)
133+
112134
try:
113135
tdp_finder_from_series(metrics_path, processors_files)
114136
except BaseException:

0 commit comments

Comments
 (0)