Datasets:
Download scripts/test_validator.py from herbwood27/FORGE: direct link, hf CLI and curl.
- Browser
- Download file 3.85 kB
-
https://huggingface.co/datasets/herbwood27/FORGE/resolve/main/scripts/test_validator.py
- Command line
-
hf download hf://datasets/herbwood27/FORGE/scripts/test_validator.py
-
curl -L -o test_validator.py https://huggingface.co/datasets/herbwood27/FORGE/resolve/main/scripts/test_validator.py
3.85 kB
| import unittest | |
| from validate_dataset import check_columns,COLUMNS,FORBIDDEN,scan,check_taxonomy_row,check_image_entry,check_non_null_columns | |
| class ValidatorRegressionTests(unittest.TestCase): | |
| def test_correct_schema(self): check_columns(COLUMNS) | |
| def test_missing_symbolic_trace(self): | |
| with self.assertRaises(AssertionError): check_columns([c for c in COLUMNS if c!='symbolic_trace']) | |
| def test_missing_visible_facts(self): | |
| with self.assertRaises(AssertionError): check_columns([c for c in COLUMNS if c!='visible_facts']) | |
| def test_missing_reasoning_text(self): | |
| with self.assertRaises(AssertionError): check_columns([c for c in COLUMNS if c!='reasoning_text']) | |
| def test_private_global_id(self): | |
| with self.assertRaises(AssertionError): check_columns(COLUMNS+[FORBIDDEN[0]]) | |
| def test_private_candidate_id(self): | |
| with self.assertRaises(AssertionError): check_columns(COLUMNS+[FORBIDDEN[1]]) | |
| def test_private_source_document(self): | |
| with self.assertRaises(AssertionError): check_columns(COLUMNS+[FORBIDDEN[2]]) | |
| def test_accidental_simplified_schema(self): | |
| with self.assertRaises(AssertionError): check_columns(['id','question','answer','hop_count','reasoning_family',FORBIDDEN[0]]) | |
| def test_public_urls_and_environment_names(self): scan(['https://example.org/license','HF_HUB_OFFLINE','HF_DATASETS_OFFLINE','HF_TOKEN']) | |
| def test_windows_path(self): | |
| with self.assertRaises(AssertionError): scan('C:'+chr(92)+'private'+chr(92)+'file') | |
| def test_credential(self): | |
| with self.assertRaises(AssertionError): scan('hf'+'_'+'a'*30) | |
| def test_missing_difficulty(self): | |
| with self.assertRaises(AssertionError): check_columns([c for c in COLUMNS if c!='difficulty']) | |
| def test_missing_family(self): | |
| with self.assertRaises(AssertionError): check_columns([c for c in COLUMNS if c!='family']) | |
| def test_hop_cannot_define_difficulty(self): | |
| with self.assertRaises(AssertionError): check_taxonomy_row({'reasoning_family':'balloon_bom_component','hop_count':13,'difficulty':'Hard','family':'C1'}) | |
| def test_wrong_hard_family(self): | |
| with self.assertRaises(AssertionError): check_taxonomy_row({'reasoning_family':'hard_compare_then_component','difficulty':'Hard','family':'C2'}) | |
| def test_plain_string_image(self): | |
| with self.assertRaises(AssertionError): check_image_entry('images/forge_000001.png','forge_000001') | |
| def test_embedded_image_bytes(self): | |
| with self.assertRaises(AssertionError): check_image_entry({'path':'hf://datasets/herbwood27/FORGE/images/forge_000001.png','bytes':b'png'},'forge_000001') | |
| def test_absolute_image_path(self): | |
| with self.assertRaises(AssertionError): check_image_entry({'path':'/'+ 'images/forge_000001.png','bytes':None},'forge_000001') | |
| def test_globally_null_column(self): | |
| row=dict.fromkeys(COLUMNS,'value');row['hop_count']=None | |
| with self.assertRaises(AssertionError): check_non_null_columns([row]) | |
| def test_correct_taxonomy_and_path(self): | |
| check_taxonomy_row({'reasoning_family':'hard_compare_then_component','difficulty':'Hard','family':'C1'}) | |
| check_image_entry({'path':None,'bytes':b'\x89PNG\r\n\x1a\n'},'forge_000001') | |
| def test_relative_image_path_rejected(self): | |
| with self.assertRaises(AssertionError): check_image_entry({'path':'images/forge_000001.png','bytes':None},'forge_000001') | |
| def test_wrong_repository_rejected(self): | |
| with self.assertRaises(AssertionError): check_image_entry({'path':'hf://datasets/other/repo/images/forge_000001.png','bytes':None},'forge_000001') | |
| def test_missing_embedded_bytes(self): | |
| with self.assertRaises(AssertionError): check_image_entry({'path':None,'bytes':None},'forge_000001') | |
| def test_nonnull_path_rejected(self): | |
| with self.assertRaises(AssertionError): check_image_entry({'path':'forge_000001.png','bytes':b'\x89PNG\r\n\x1a\n'},'forge_000001') | |
| if __name__=='__main__': unittest.main() | |