Create a temporary dataset with only the first N characters for quick testing.
(self, dataset_path, num_chars=4096)
| 89 | return datasets |
| 90 | |
| 91 | def create_quick_dataset(self, dataset_path, num_chars=4096): |
| 92 | """Create a temporary dataset with only the first N characters for quick testing.""" |
| 93 | temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt', encoding='utf-8') |
| 94 | self.temp_files.append(temp_file.name) |
| 95 | |
| 96 | try: |
| 97 | with open(dataset_path, 'r', encoding='utf-8', errors='ignore') as f: |
| 98 | content = f.read(num_chars) |
| 99 | temp_file.write(content) |
| 100 | temp_file.close() |
| 101 | return Path(temp_file.name) |
| 102 | except Exception as e: |
| 103 | print(f"⚠️ Failed to create quick dataset: {e}") |
| 104 | temp_file.close() |
| 105 | return dataset_path |
| 106 | |
| 107 | def cleanup_temp_files(self): |
| 108 | """Clean up temporary files.""" |
no test coverage detected