Skip to content

Commit

Permalink
remove folder with only meta files
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethEnevoldsen committed Aug 14, 2024
1 parent 1e028d6 commit 678e117
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.

This file was deleted.

This file was deleted.

13 changes: 13 additions & 0 deletions scripts/normalize_results_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ def resolve_conflict(current_path: Path, expected_path: Path) -> None:
resolve_conflict_result(current_path, expected_path)


def remove_folders_with_only_meta_files(results_folder: Path) -> None:
"""Remove folders that only contain a meta file."""
for folder in results_folder.glob("*/*"):
if len(list(folder.glob("*.json"))) == 1:
meta_file = list(folder.glob("*.json"))[0]
if meta_file.name == "model_meta.json":
logger.info(f"Removing folder {folder}")
meta_file.unlink()
folder.rmdir()


def main(attempt_to_resolve_conflict: bool) -> None:
"""Main function."""
results_folder = Path(__file__).parent.parent / "results"
Expand Down Expand Up @@ -107,6 +118,8 @@ def main(attempt_to_resolve_conflict: bool) -> None:
if conflict_encountered and not attempt_to_resolve_conflict:
raise Exception("Conflicts encountered.")

remove_folders_with_only_meta_files(results_folder)


if __name__ == "__main__":
logging.basicConfig(
Expand Down

0 comments on commit 678e117

Please sign in to comment.