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

#2837 Use cache folder for lockfile #2887

Merged
merged 8 commits into from
Oct 5, 2021

Conversation

Dref360
Copy link
Contributor

@Dref360 Dref360 commented Sep 9, 2021

Fixes #2837

Use a cache folder directory to store the FileLock.

The issue was that the lock file was in a readonly folder.

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change, I just have two comments:

tests/test_load.py Show resolved Hide resolved
@@ -452,8 +452,12 @@ def prepare_packaged_module(name):

if force_local_path is None:
main_folder_path = os.path.join(datasets_modules_path if dataset else metrics_modules_path, short_name)
# Create the lock file where we know we have write permissions.
lock_path = main_folder_path + ".lock"
os.makedirs(main_folder_path, exist_ok=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must notice line 678 that if force_download is set to True, the main_folder_path directory is deleted, which is an issue because it contains an open lock file. Therefore I would put the lock file it inside datasets_modules_path if dataset else metrics_modules_path instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thank you!

Something like:

# Create the lock file where we know we have write permissions.
lock_path = (datasets_modules_path if dataset else metrics_modules_path) + f"{name}.lock"

so that each dataset has their own lock file?

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

src/datasets/load.py Outdated Show resolved Hide resolved
@lhoestq
Copy link
Member

lhoestq commented Oct 5, 2021

The CI fail about the meteor metric is unrelated to this PR

@lhoestq lhoestq merged commit dcd523c into huggingface:master Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prepare_module issue when loading from read-only fs
2 participants