Skip to content

Commit 143fe28

Browse files
jucorclaude
andcommitted
Make math_blob optional for regression testing
Allow datasets to be valid for regression testing without the Clojure math_blob file. This enables testing when database access is unavailable (e.g., when DATABASE_URL is not set). Changes: - DatasetInfo.is_valid now only requires votes, comments, and golden_snapshot - Added has_clojure_reference property to check if Clojure comparison is possible - Updated documentation to clarify math_blob is optional - Added tests for new behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 6342c2f commit 143fe28

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

delphi/polismath/regression/datasets.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
directory naming: <report_id>-<name>/
66
77
Required files for regression testing:
8-
- *-votes.csv, *-comments.csv, {report_id}_math_blob.json, golden_snapshot.json
8+
- *-votes.csv, *-comments.csv, golden_snapshot.json
9+
10+
Optional files:
11+
- {report_id}_math_blob.json (for Clojure comparison - requires database access to download)
912
"""
1013

1114
import glob
@@ -38,8 +41,13 @@ class DatasetInfo:
3841

3942
@property
4043
def is_valid(self) -> bool:
41-
"""Has all files needed for regression testing."""
42-
return all([self.has_golden, self.has_math_blob, self.has_votes, self.has_comments])
44+
"""Has all files needed for regression testing (math_blob is optional)."""
45+
return all([self.has_golden, self.has_votes, self.has_comments])
46+
47+
@property
48+
def has_clojure_reference(self) -> bool:
49+
"""Has math_blob for comparison with Clojure implementation."""
50+
return self.has_math_blob
4351

4452
@property
4553
def description(self) -> str:
@@ -117,6 +125,7 @@ def list_available_datasets(include_local: bool = False) -> Dict[str, dict]:
117125
'is_local': d.is_local,
118126
'has_golden': d.has_golden,
119127
'has_math_blob': d.has_math_blob,
128+
'has_clojure_reference': d.has_clojure_reference,
120129
}
121130
for name, d in discover_datasets(include_local).items()
122131
}

delphi/tests/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ real_data/
9292
**Required files per dataset:**
9393
- `*-votes.csv` - Vote data
9494
- `*-comments.csv` - Comment data
95-
- `{report_id}_math_blob.json` - Clojure math output
9695
- `golden_snapshot.json` - For regression testing
9796

97+
**Optional files:**
98+
- `{report_id}_math_blob.json` - Clojure math output (for Clojure comparison, requires database access)
99+
98100
### Running Tests with Local Datasets
99101

100102
```bash

delphi/tests/test_datasets.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,26 @@ def test_is_valid_all_files(self):
3838
info = DatasetInfo("t", "r1", Path("/x"), False, True, True, True, True)
3939
assert info.is_valid
4040

41-
def test_is_valid_missing_file(self):
41+
def test_is_valid_without_math_blob(self):
42+
"""Math blob is optional for regression testing."""
43+
# has_golden=True, has_math_blob=False, has_votes=True, has_comments=True
44+
info = DatasetInfo("t", "r1", Path("/x"), False, True, False, True, True)
45+
assert info.is_valid
46+
assert not info.has_clojure_reference
47+
48+
def test_is_valid_missing_required_file(self):
49+
"""Missing golden/votes/comments makes dataset invalid."""
50+
# Missing golden
4251
info = DatasetInfo("t", "r1", Path("/x"), False, False, True, True, True)
4352
assert not info.is_valid
4453

54+
def test_has_clojure_reference(self):
55+
"""has_clojure_reference reflects math_blob presence."""
56+
with_blob = DatasetInfo("t", "r1", Path("/x"), False, True, True, True, True)
57+
without_blob = DatasetInfo("t", "r1", Path("/x"), False, True, False, True, True)
58+
assert with_blob.has_clojure_reference
59+
assert not without_blob.has_clojure_reference
60+
4561

4662
class TestCheckFiles:
4763
def test_all_files_exist(self, tmp_path):

0 commit comments

Comments
 (0)