-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclear_metadata.py
More file actions
48 lines (37 loc) · 1.58 KB
/
clear_metadata.py
File metadata and controls
48 lines (37 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
"""
Script to delete all metadata.json files from exercism exercises.
This allows regenerating them with corrected counting logic.
"""
import os
import glob
def clear_all_metadata():
"""Delete all metadata.json files from exercise directories."""
practice_dir = "/Users/marcvanduyn/Projects/Microsoft/llm-cpp-eval/benchmark/practice"
if not os.path.exists(practice_dir):
print(f"Practice directory not found: {practice_dir}")
return
# Find all metadata.json files
metadata_pattern = os.path.join(practice_dir, "*/metadata.json")
metadata_files = glob.glob(metadata_pattern)
print(f"Found {len(metadata_files)} metadata.json files to delete")
deleted_count = 0
for metadata_file in metadata_files:
try:
# Extract exercise name for logging
exercise_name = os.path.basename(os.path.dirname(metadata_file))
# Delete the metadata file
os.remove(metadata_file)
print(f"Deleted metadata for {exercise_name}")
deleted_count += 1
except Exception as e:
print(f"Error deleting {metadata_file}: {e}")
print(f"\nDeleted {deleted_count} metadata.json files")
print("You can now run create_metadata.py to regenerate with corrected counting logic")
if __name__ == "__main__":
# Ask for confirmation before deleting
response = input("This will delete all metadata.json files from exercises. Continue? (y/N): ")
if response.lower() in ['y', 'yes']:
clear_all_metadata()
else:
print("Operation cancelled")