Download tools/test_content_scopes.py from Lexmount/LexBench-Web-Fetch: direct link, hf CLI and curl.
- Browser
- Download file 2.81 kB
-
https://huggingface.co/datasets/Lexmount/LexBench-Web-Fetch/resolve/refs%2Fpr%2F9/tools/test_content_scopes.py
- Command line
-
hf download hf://datasets/Lexmount/LexBench-Web-Fetch@refs/pr/9/tools/test_content_scopes.py
-
curl -L -o test_content_scopes.py https://huggingface.co/datasets/Lexmount/LexBench-Web-Fetch/resolve/refs%2Fpr%2F9/tools/test_content_scopes.py
2.81 kB
| """Annotation cohorts add acceptance scopes without changing the released population.""" | |
| from pathlib import Path | |
| import json | |
| import unittest | |
| from test_review_scope import suite_dirs | |
| ROOT = Path(__file__).resolve().parents[1] | |
| class ContentScopesTests(unittest.TestCase): | |
| def test_annotations_reuse_population_and_preserve_both_scopes(self): | |
| tasks = json.loads((ROOT/'definitions/evaluation/content-scopes-530/tasks.json').read_text())['cases'] | |
| population = json.loads((ROOT/'definitions/populations/primary-content-20261103.json').read_text()) | |
| self.assertEqual(len(tasks), 530) | |
| self.assertEqual({c['id'] for c in tasks}, {c['suite']+'--'+c['id'] for c in population['cases']}) | |
| for task in tasks: | |
| self.assertEqual(set(task['content_scopes']) - {'version'}, {'main', 'full'}) | |
| self.assertNotIn('content-scopes-530', suite_dirs()) | |
| self.assertEqual(set(suite_dirs()), set(population['frozen_task_bindings'])) | |
| def test_annotation_registry_does_not_expand_edition(self): | |
| manifest = json.loads((ROOT/'manifest.json').read_text()) | |
| self.assertEqual(manifest['edition']['task_count'], 530) | |
| registry = json.loads((ROOT/'definitions/registry.json').read_text()) | |
| entry = next(s for s in registry['suites'] if s['id']=='content-scopes-530') | |
| self.assertEqual(entry['kind'], 'annotation_cohort') | |
| self.assertEqual(entry['source_population'], 'primary-content-20261103') | |
| class EditionTests(unittest.TestCase): | |
| def test_edition_selects_exactly_the_population_cases(self): | |
| manifest = json.loads((ROOT/'manifest.json').read_text()) | |
| population = json.loads((ROOT/'definitions/populations/primary-content-20261103.json').read_text()) | |
| names = [c['name'] for c in manifest['edition']['configurations']] | |
| self.assertNotIn('dynamic-examples', names) | |
| self.assertNotIn('challenge-examples', names) | |
| selected = set() | |
| for name in names: | |
| for line in (ROOT/'data'/(name+'.jsonl')).read_text().splitlines(): | |
| row = json.loads(line) | |
| selected.add((row['source_suite'], row['id'])) | |
| self.assertEqual(selected, {(c['suite'], c['id']) for c in population['cases']}) | |
| def test_challenge_set_is_published_outside_the_edition(self): | |
| rows = [json.loads(l) for l in (ROOT/'data/challenge-examples.jsonl').read_text().splitlines()] | |
| population = json.loads((ROOT/'definitions/populations/primary-content-20261103.json').read_text()) | |
| excluded = {(c['suite'], c['id']) for c in population['excluded']} | |
| self.assertEqual(len(rows), 10) | |
| self.assertTrue({(r['source_suite'], r['id']) for r in rows} <= excluded) | |
| self.assertFalse((ROOT/'data/dynamic-examples.jsonl').exists()) | |