Skip to content

Commit 2eb4e5f

Browse files
committed
Wrote tests for reporting
1 parent 939fa9c commit 2eb4e5f

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""Integration test for results reporting."""
2+
3+
from test_run_experiment import (
4+
_remove_dir,
5+
cached_visualization_file,
6+
experiment_filepath_test,
7+
kernel_id,
8+
mockfiles_path_source,
9+
normal_cachefile_destination,
10+
normal_cachefiles_path,
11+
)
12+
13+
from autotuning_methodology.experiments import get_experiment, get_strategies
14+
from autotuning_methodology.report_experiments import get_strategy_scores
15+
16+
# setup file paths
17+
experiment_title = f"{kernel_id}_on_mock_GPU"
18+
19+
20+
def setup_module():
21+
"""Setup of the test, creates / copies files where necessary."""
22+
assert mockfiles_path_source.exists()
23+
normal_cachefiles_path.mkdir(parents=True, exist_ok=True)
24+
assert normal_cachefiles_path.exists()
25+
normal_cachefile_destination.write_text(mockfiles_path_source.read_text())
26+
assert normal_cachefile_destination.exists()
27+
28+
29+
def teardown_module():
30+
"""Teardown of the tests, removes files where necessary."""
31+
if normal_cachefile_destination.exists():
32+
normal_cachefile_destination.unlink()
33+
_remove_dir(normal_cachefiles_path)
34+
35+
36+
def test_visualize_experiment():
37+
"""Report on a dummy experiment."""
38+
# make sure the paths exists
39+
assert normal_cachefile_destination.exists()
40+
if cached_visualization_file.exists():
41+
cached_visualization_file.unlink()
42+
assert not cached_visualization_file.exists()
43+
44+
# get the experiment details
45+
experiment_filepath = str(experiment_filepath_test)
46+
experiment = get_experiment(experiment_filepath)
47+
strategies = get_strategies(experiment)
48+
49+
# get the scores
50+
strategies_scores = get_strategy_scores(experiment_filepath)
51+
52+
# validate the results
53+
assert len(strategies_scores) == len(strategies)
54+
for strategy in strategies:
55+
assert strategy["name"] in strategies_scores
56+
for strategy, score in strategies_scores.items():
57+
assert isinstance(score, dict)
58+
assert isinstance(strategy, str)
59+
assert "score" in score
60+
assert "error" in score
61+
for value in score.values():
62+
assert isinstance(value, float)

0 commit comments

Comments
 (0)