Skip to content

Commit

Permalink
Merge branch 'vara-dev' into f-DuneExamples
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Abelt committed Oct 4, 2023
2 parents a62b68e + db6a69b commit a0e2b1f
Show file tree
Hide file tree
Showing 30 changed files with 953 additions and 91 deletions.
4 changes: 4 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
# modules that require this module before setting the type checking flag.
import scipy.stats # isort:skip

# Matplotlib >=3.8 has a type-checking-flag-guarded import of a symbol that does
# not exist in the shipped version.
import matplotlib.pyplot # isort:skip

# The autodocs typehints plugin does not resolve circular imports caused by type
# annotations, so we have to manually break the circles.
import rich.console # isort:skip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ One just needs to extend the case-study file of a project with a yaml document t
.. code-block:: yaml
---
config_type: PlainCommandlineConfiguration
0: '["--foo", "--bar"]'
1: '["--foo"]'
...
Expand Down
1 change: 1 addition & 0 deletions docs/source/vara-ts-api/tools/vara-cs-gui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The gui is started by::

The gui provides 3 Strategies to generate case studies:
- Manual revision selection: Select revision from the revision history of a project. Multiple revisions can be selected by holding `ctrl` and ranges by holding `shift`. Revisions which are blocked because of bugs in the compilation of the project are marked blue.

.. figure:: vara-cs-gui-manual.png

- Random Sampling: Sample a number of revisions using a random a Normal or HalfNormal Distribution.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
DocType: CaseStudy
Version: 1
...
---
project_name: SynthIPTemplate
stages:
- revisions:
- commit_hash: 793035062810ea3a2d9a10f831cd199fbbb82090
commit_id: 64
config_ids:
- 0
- 1
- 2
- 3
- 4
version: 0
...
---
config_type: PatchConfiguration
0: '["Decompress"]'
1: '["Compress"]'
2: '["Compress", "fastmode", "no_smallmode"]'
3: '["Compress", "no_fastmode", "smallmode"]'
4: '["Compress", "fastmode", "smallmode"]'
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ stages:
version: 0
...
---
config_type: PlainCommandlineConfiguration
0: '["--compress", "--mem", "10", "8"]'
1: '["--compress", "--mem", "300", "8"]'
...
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ stages:
config_ids: [1]
version: 0
---
config_type: PlainCommandlineConfiguration
0: '["--foo", "--bar"]'
1: '["--foo"]'
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/data/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ def test_get_uuid(self):
self.assertEqual(self.report_filename.uuid, self.correct_UUID)
self.assertRaises(ValueError, lambda: self.broken_report_filename.uuid)

def test_experiment_shorthand_parsing_with_path_in_name(self) -> None:
"""Checks that we correctly parse the experiment shorthand also in cases
where we have a path as part of the filename."""
prefixed = ReportFilename(
"/tmp/foobar/" + self.report_filename.filename
)
self.assertEqual(prefixed.experiment_shorthand, "CRE")


class TestConfigReportFilename(unittest.TestCase):
"""Test configuration specific ReportFilename functionality."""
Expand Down
51 changes: 51 additions & 0 deletions tests/experiment/test_workload_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
from benchbuild.source.base import Revision, Variant

import varats.experiment.workload_util as wu
from tests.helper_utils import run_in_test_environment, UnitTestFixtures
from varats.paper.paper_config import load_paper_config
from varats.projects.c_projects.xz import Xz
from varats.projects.perf_tests.feature_perf_cs_collection import (
SynthIPTemplate,
)
from varats.utils.git_util import ShortCommitHash
from varats.utils.settings import vara_cfg

TT = PathToken.make_token(RootRenderer())

Expand Down Expand Up @@ -52,6 +58,51 @@ def test_workload_commands_tags_selected(self) -> None:
)
self.assertEqual(len(commands), 1)

def test_workload_commands_requires(self) -> None:
revision = Revision(Xz, Variant(Xz.SOURCE[0], "c5c7ceb08a"))
project = Xz(revision=revision)
binary = Xz.binaries_for_revision(ShortCommitHash("c5c7ceb08a"))[0]

commands = wu.workload_commands(
project, binary, [wu.WorkloadCategory.EXAMPLE]
)
self.assertEqual(len(commands), 1)
commands = wu.workload_commands(
project, binary, [wu.WorkloadCategory.MEDIUM]
)
self.assertEqual(len(commands), 1)

@run_in_test_environment(UnitTestFixtures.PAPER_CONFIGS)
def test_workload_commands_requires_patch(self) -> None:
vara_cfg()['paper_config']['current_config'] = "test_config_ids"
load_paper_config()

revision = Revision(
SynthIPTemplate, Variant(SynthIPTemplate.SOURCE[0], "7930350628"),
Variant(SynthIPTemplate.SOURCE[1], "1")
)
project = SynthIPTemplate(revision=revision)
binary = SynthIPTemplate.binaries_for_revision(
ShortCommitHash("7930350628")
)[0]
workloads = wu.workload_commands(project, binary, [])
self.assertEqual(len(workloads), 2)

@run_in_test_environment(UnitTestFixtures.PAPER_CONFIGS)
def test_workload_commands_requires_patch2(self) -> None:
vara_cfg()['paper_config']['current_config'] = "test_config_ids"
load_paper_config()

revision = Revision(
SynthIPTemplate, Variant(SynthIPTemplate.SOURCE[0], "7930350628"),
Variant(SynthIPTemplate.SOURCE[1], "0")
)
project = SynthIPTemplate(revision=revision)
binary = SynthIPTemplate \
.binaries_for_revision(ShortCommitHash("7930350628"))[0]
workloads = wu.workload_commands(project, binary, [])
self.assertEqual(len(workloads), 0)


class TestWorkloadFilenames(unittest.TestCase):

Expand Down
1 change: 1 addition & 0 deletions tests/paper/test_case_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
commit_id: 494
...
---
config_type: ConfigurationImpl
0: '{"foo": true, "bar": false, "bazz": "bazz-value", "buzz": "None"}'
1: '{}'
2: '{}'
Expand Down
54 changes: 52 additions & 2 deletions tests/paper_mgmt/test_case_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ def test_get_newest_result_files_for_case_study_with_empty_res_dir(
UnitTestFixtures.PAPER_CONFIGS, UnitTestFixtures.RESULT_FILES
)
def test_get_newest_result_files_for_case_study_with_config(self) -> None:
"""Check that when we have two files, the newes one get's selected."""
"""Check that when we have two files that differ in their config id,
both get selected."""
vara_cfg()['paper_config']['current_config'] = "test_config_ids"
load_paper_config()

Expand Down Expand Up @@ -273,7 +274,56 @@ def test_get_newest_result_files_for_case_study_with_config(self) -> None:

self.assertEqual(newest_res_filenames[0].config_id, 0)
self.assertEqual(newest_res_filenames[1].config_id, 1)
self.assertEqual(len(newest_res_filenames), 2)
self.assertEqual(newest_res_filenames[2].config_id, 0)
self.assertEqual(newest_res_filenames[3].config_id, 1)
self.assertEqual(len(newest_res_filenames), 4)

@run_in_test_environment(
UnitTestFixtures.PAPER_CONFIGS, UnitTestFixtures.RESULT_FILES
)
def test_get_newest_result_files_for_case_study_with_diff_exp(self) -> None:
"""Check that when we have two files that differ in their experiment
shorthand, both get selected."""
vara_cfg()['paper_config']['current_config'] = "test_config_ids"
load_paper_config()

config_0_file = ReportFilename(
"BBBase-CR-SynthSAContextSensitivity-ContextSense-06eac0edb6/"
"b24ee2c1-fc85-47ba-abbd-90c98e88a37c_config-0_success.zip"
)
config_1_file = ReportFilename(
"BBBaseO-CR-SynthSAContextSensitivity-ContextSense-06eac0edb6/"
"b24ee2c1-fc85-47ba-abbd-90c98e88a37c_config-0_success.zip"
)

now = datetime.now().timestamp()
file_path_0 = Path(
str(vara_cfg()['result_dir'])
) / 'SynthSAContextSensitivity' / config_0_file.filename
os.utime(file_path_0, (now, now))

file_path_1 = Path(
str(vara_cfg()['result_dir'])
) / 'SynthSAContextSensitivity' / config_1_file.filename
os.utime(file_path_1, (now, now))

newest_res_files = MCS.get_newest_result_files_for_case_study(
get_paper_config().get_case_studies('SynthSAContextSensitivity')[0],
Path(vara_cfg()['result_dir'].value), CR
)

newest_res_files.sort(reverse=True)
newest_res_filenames = [ReportFilename(x) for x in newest_res_files]

self.assertEqual(
newest_res_filenames[0].experiment_shorthand, "BBBaseO"
)
self.assertEqual(
newest_res_filenames[1].experiment_shorthand, "BBBaseO"
)
self.assertEqual(newest_res_filenames[2].experiment_shorthand, "BBBase")
self.assertEqual(newest_res_filenames[3].experiment_shorthand, "BBBase")
self.assertEqual(len(newest_res_filenames), 4)

def test_get_case_study_file_name_filter_empty(self) -> None:
"""Check that we correctly handle case study filter generation even if
Expand Down
Loading

0 comments on commit a0e2b1f

Please sign in to comment.