-
Notifications
You must be signed in to change notification settings - Fork 2
RPOPC-1317: Extract STREAMS benchmark version from CSV metadata #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
aecae16
test: add failing tests for STREAMS version extraction
2a64221
test + feat(streams): extract benchmark version from CSV metadata
10ae8d3
test: add regression test for processor state leakage
6d78954
test + fix(streams): reset benchmark version state per parse
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| """ | ||
| STREAMS processor: benchmark version extraction from CSV metadata comments. | ||
| """ | ||
|
|
||
| import pytest | ||
| from pathlib import Path | ||
|
|
||
| from chronicler.processors.streams_processor import StreamsProcessor | ||
|
|
||
| pytestmark = pytest.mark.unit | ||
| from conftest import run_processor_parse | ||
|
|
||
| FILE_KEY = "results_streams_csv" | ||
| FILENAME = "results_streams.csv" | ||
|
|
||
|
|
||
| def _write_csv(result_dir: Path, content: str) -> Path: | ||
| path = result_dir / FILENAME | ||
| path.write_text(content.strip()) | ||
| return path | ||
|
|
||
|
|
||
| def test_streams_extracts_version_from_csv_comment(result_dir): | ||
| """Extract benchmark version from '# streams_version_# 5.10' comment.""" | ||
| csv = """# streams_version_# 5.10 | ||
| # Optimization level: O2 | ||
| Array sizes,16384k,32768k,Start_Date,End_Date | ||
| Copy,1.0,2.0,2026-02-04T00:19:56Z,2026-02-04T00:20:00Z""" | ||
| path = _write_csv(result_dir, csv) | ||
|
|
||
| processor = StreamsProcessor(str(result_dir)) | ||
| processor.parse_runs({"files": {FILE_KEY: str(path)}}) | ||
| test_info = processor.build_test_info() | ||
|
|
||
| assert test_info.version == "5.10", "Should extract benchmark version from CSV comment" | ||
| assert test_info.wrapper_version is not None, "Should preserve wrapper version" | ||
|
|
||
|
|
||
| def test_streams_version_with_whitespace_variations(result_dir): | ||
| """Handle various whitespace around version number.""" | ||
| csv = """#streams_version_# 5.10 | ||
| # Optimization level: O2 | ||
| Array sizes,16384k,Start_Date,End_Date | ||
| Copy,1.0,2026-02-04T00:19:56Z,2026-02-04T00:20:00Z""" | ||
| path = _write_csv(result_dir, csv) | ||
|
|
||
| processor = StreamsProcessor(str(result_dir)) | ||
| processor.parse_runs({"files": {FILE_KEY: str(path)}}) | ||
| test_info = processor.build_test_info() | ||
|
|
||
| assert test_info.version == "5.10" | ||
|
|
||
|
|
||
| def test_streams_version_missing_fallback_to_wrapper(result_dir): | ||
| """When no benchmark version comment, fall back to wrapper version.""" | ||
| csv = """# Optimization level: O2 | ||
| Array sizes,16384k,Start_Date,End_Date | ||
| Copy,1.0,2026-02-04T00:19:56Z,2026-02-04T00:20:00Z""" | ||
| path = _write_csv(result_dir, csv) | ||
|
|
||
| # Create test_info file with wrapper version | ||
| test_info_file = result_dir / "test_info" | ||
| test_info_file.write_text('{"streams": {"test_name": "streams", "repo_file": "v2.8.tar.gz"}}') | ||
|
|
||
| processor = StreamsProcessor(str(result_dir)) | ||
| processor.parse_runs({"files": {FILE_KEY: str(path)}}) | ||
| test_info = processor.build_test_info() | ||
|
|
||
| assert test_info.version == "v2.8", "Should fall back to wrapper version when no benchmark version" | ||
| assert test_info.wrapper_version == "v2.8" | ||
|
|
||
|
|
||
| def test_streams_version_only_uses_first_occurrence(result_dir): | ||
| """If multiple version comments, use first one.""" | ||
| csv = """# streams_version_# 5.10 | ||
| # Optimization level: O2 | ||
| # streams_version_# 6.0 | ||
| Array sizes,16384k,Start_Date,End_Date | ||
| Copy,1.0,2026-02-04T00:19:56Z,2026-02-04T00:20:00Z""" | ||
| path = _write_csv(result_dir, csv) | ||
|
|
||
| processor = StreamsProcessor(str(result_dir)) | ||
| processor.parse_runs({"files": {FILE_KEY: str(path)}}) | ||
| test_info = processor.build_test_info() | ||
|
|
||
| assert test_info.version == "5.10", "Should use first version comment" | ||
|
|
||
|
|
||
| def test_streams_version_different_formats(result_dir): | ||
| """Handle different version number formats (x.y, x.y.z, vX.Y, etc).""" | ||
| test_cases = [ | ||
| ("5.10", "5.10"), | ||
| ("5.10.1", "5.10.1"), | ||
| ("v5.10", "v5.10"), | ||
| ("2024.1", "2024.1"), | ||
| ] | ||
|
|
||
| for version_str, expected in test_cases: | ||
| csv = f"""# streams_version_# {version_str} | ||
| Array sizes,16384k,Start_Date,End_Date | ||
| Copy,1.0,2026-02-04T00:19:56Z,2026-02-04T00:20:00Z""" | ||
| path = _write_csv(result_dir, csv) | ||
|
|
||
| processor = StreamsProcessor(str(result_dir)) | ||
| processor.parse_runs({"files": {FILE_KEY: str(path)}}) | ||
| test_info = processor.build_test_info() | ||
|
|
||
| assert test_info.version == expected, f"Should handle version format: {version_str}" | ||
|
|
||
|
|
||
| def test_streams_version_resets_between_parses(result_dir): | ||
| """Processor reuse: version state should not leak between parse_runs() calls.""" | ||
| # First parse: CSV with benchmark version | ||
| csv1 = """# streams_version_# 5.10 | ||
| # Optimization level: O2 | ||
| Array sizes,16384k,Start_Date,End_Date | ||
| Copy,1.0,2026-02-04T00:19:56Z,2026-02-04T00:20:00Z""" | ||
| path1 = _write_csv(result_dir, csv1) | ||
|
|
||
| # Create test_info file with wrapper version for fallback | ||
| test_info_file = result_dir / "test_info" | ||
| test_info_file.write_text('{"streams": {"test_name": "streams", "repo_file": "v2.8.tar.gz"}}') | ||
|
|
||
| processor = StreamsProcessor(str(result_dir)) | ||
| processor.parse_runs({"files": {FILE_KEY: str(path1)}}) | ||
| test_info1 = processor.build_test_info() | ||
|
|
||
| assert test_info1.version == "5.10", "First parse should extract benchmark version" | ||
|
|
||
| # Second parse: CSV WITHOUT benchmark version (reusing same processor instance) | ||
| csv2 = """# Optimization level: O3 | ||
| Array sizes,16384k,Start_Date,End_Date | ||
| Copy,2.0,2026-02-05T00:19:56Z,2026-02-05T00:20:00Z""" | ||
| path2 = _write_csv(result_dir, csv2) | ||
|
|
||
| processor.parse_runs({"files": {FILE_KEY: str(path2)}}) | ||
| test_info2 = processor.build_test_info() | ||
|
|
||
| assert test_info2.version == "v2.8", "Second parse should fall back to wrapper version, not retain stale '5.10'" | ||
| assert test_info2.wrapper_version == "v2.8" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.