Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: junifer reset fails as it tries to delete junifer_jobs directory #332

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changes/newsfragments/332.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``junifer reset`` to properly delete storage directory and handle ``junifer_jobs`` deletion if not empty by `Synchon Mandal`_
14 changes: 8 additions & 6 deletions junifer/api/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Synchon Mandal <[email protected]>
# License: AGPL

import os
import shutil
import typing
from pathlib import Path
Expand Down Expand Up @@ -339,12 +340,12 @@
storage = config["storage"]
storage_uri = Path(storage["uri"])
logger.info(f"Deleting {storage_uri.resolve()!s}")
# Delete storage; will be str
# Delete storage
if storage_uri.exists():
# Delete files in the directory
for file in storage_uri.iterdir():
# Delete files in the job storage directory
for file in storage_uri.parent.iterdir():
file.unlink(missing_ok=True)
# Remove directory
# Remove job storage directory
storage_uri.parent.rmdir()

# Fetch job name (if present)
Expand All @@ -359,8 +360,9 @@
if job_dir.exists():
# Remove files and directories
shutil.rmtree(job_dir)
# Remove directory
job_dir.parent.rmdir()
# Remove parent directory (if empty)
if not next(os.scandir(job_dir.parent), None):
job_dir.parent.rmdir()

Check failure on line 365 in junifer/api/functions.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W291)

junifer/api/functions.py:365:39: W291 Trailing whitespace

Check failure on line 365 in junifer/api/functions.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W291)

junifer/api/functions.py:365:39: W291 Trailing whitespace


def list_elements(
Expand Down
Loading