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

FileStore: fix metadata overwriting path #736

Merged
merged 2 commits into from
Oct 25, 2022

Conversation

rkingsbury
Copy link
Collaborator

When a user adds metadata to FileStore it is stored on disk. Both the file_id and the path are retained in the .json file to make it possible to manually associated metadata with specific files. However, when the metadata was read into the FileStore, the path attribute stored on disk was overwriting the path attribute determine by FileStore.__init__. This was not intended behavior, and caused problems when working with a FileStore across different computers where the absolute path of files is different (but the path relative to the FileStore root is the same). (For example, syncing a directory of files containing a FileStore across different computers using Dropbox, etc.)

This PR fixes the bug as follows:

  • Store a new field path_relative instead of path in the metadata .json file on disk. This preserves manual identifiability of metdata
  • Ensure that the path and last_updated fields cannot be overwritten by metadata updates
  • add tests

@codecov
Copy link

codecov bot commented Oct 25, 2022

Codecov Report

Base: 88.37% // Head: 88.37% // No change to project coverage 👍

Coverage data is based on head (5032524) compared to base (fe2a735).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #736   +/-   ##
=======================================
  Coverage   88.37%   88.37%           
=======================================
  Files          41       41           
  Lines        3123     3123           
=======================================
  Hits         2760     2760           
  Misses        363      363           
Impacted Files Coverage Δ
src/maggma/stores/file_store.py 98.02% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@munrojm
Copy link
Member

munrojm commented Oct 25, 2022

This looks good! Ready to merge?

@rkingsbury
Copy link
Collaborator Author

This looks good! Ready to merge?

Yes, ready!

@munrojm munrojm merged commit 4f5d22c into materialsproject:main Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants