Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
joein committed Nov 12, 2024
1 parent e6471fd commit 7f3517f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
- name: Run pytest
run: |
poetry run pytest -s -vv -l
poetry run pytest -s -vv -l tests/test_late_interaction_embeddings.py
21 changes: 21 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,30 @@ def delete_model_cache(model_dir: Union[str, Path]) -> None:
Args:
model_dir (Union[str, Path]): The path to the model cache directory.
"""
import os

def recursive_chmod(path: str, mode: int):
"""
Recursively change permissions of files and directories.
:param path: Path to the file or directory.
:param mode: File mode (e.g., 0o755).
"""
# Change the permission of the current path
print("change permission", path, mode)
os.chmod(path, mode)

# If the path is a directory, recursively apply chmod to its contents
if os.path.isdir(path):
for entry in os.listdir(path):
full_path = os.path.join(path, entry)
recursive_chmod(full_path, mode)

def on_error(func, path, exc_info):
exc_type, exc_value, exc_traceback = exc_info
# Example usage:
# Change permissions to 755 recursively for a directory
recursive_chmod(path, 0o755)
print("Failed to remove: ", path)
print("Exception: ", exc_value)
print("Traceback: ", traceback.format_tb(exc_traceback))
Expand Down

0 comments on commit 7f3517f

Please sign in to comment.