MCPcopy Index your code
hub / github.com/microsoft/BitNet / create_quick_dataset

Method create_quick_dataset

utils/test_perplexity.py:91–105  ·  view source on GitHub ↗

Create a temporary dataset with only the first N characters for quick testing.

(self, dataset_path, num_chars=4096)

Source from the content-addressed store, hash-verified

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."""

Callers 1

run_all_testsMethod · 0.95

Calls 2

writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected