Skip to content

Commit

Permalink
try to chmod
Browse files Browse the repository at this point in the history
  • Loading branch information
joein committed Nov 11, 2024
1 parent d022874 commit f1b9176
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ def delete_model_cache(model_dir: Union[str, Path]) -> None:
"""

def on_error(func, path, exc_info):
print(f"Failed to remove {path}. {exc_info}")
import stat
import os

# Is the error an access error?
if not os.access(path, os.W_OK):
os.chmod(path, stat.S_IWUSR)
func(path)
else:
raise

if isinstance(model_dir, str):
model_dir = Path(model_dir)
Expand Down

0 comments on commit f1b9176

Please sign in to comment.