Spaces:
Sleeping
Sleeping
File size: 1,111 Bytes
3860419 |
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 |
"""
This module provides functionality to clean up benchmark directories by removing
all files and folders except for 'prompt' and 'main_prompt'.
"""
# list all folders in benchmark folder
# for each folder, run the benchmark
import os
import shutil
from pathlib import Path
from typer import run
def main():
"""
Main function that iterates through all directories in the 'benchmark' folder
and cleans them by removing all files and directories except for 'prompt' and
'main_prompt'.
"""
benchmarks = Path("benchmark")
for benchmark in benchmarks.iterdir():
if benchmark.is_dir():
print(f"Cleaning {benchmark}")
for path in benchmark.iterdir():
if path.name in ["prompt", "main_prompt"]:
continue
# Get filename of Path object
if path.is_dir():
# delete the entire directory
shutil.rmtree(path)
else:
# delete the file
os.remove(path)
if __name__ == "__main__":
run(main)
|