-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Save file name in embed_storage #5285
Conversation
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you!
I've left a comment and I think a couple of tests that fail on the CI should be fixed according to this change - not assert that "path"
is None (like in test_writer_embed_local_files
)
@@ -229,7 +228,10 @@ def path_to_bytes(path): | |||
], | |||
type=pa.binary(), | |||
) | |||
path_array = pa.array([None] * len(storage), type=pa.string()) if drop_paths else storage.field("path") | |||
path_array = pa.array( | |||
[os.path.basename(path) if path is not None else None for path in storage.field("path").to_pylist()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to store full paths to avoid ambiguities + metadata information like classes might be reflected in directories names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may store personal information about the user though, not a big fan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, agree, users can include full paths in a separate field if needed
I updated the tests, met le know if it sounds good to you now :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me! added a small suggestion for tests
@@ -229,7 +228,10 @@ def path_to_bytes(path): | |||
], | |||
type=pa.binary(), | |||
) | |||
path_array = pa.array([None] * len(storage), type=pa.string()) if drop_paths else storage.field("path") | |||
path_array = pa.array( | |||
[os.path.basename(path) if path is not None else None for path in storage.field("path").to_pylist()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, agree, users can include full paths in a separate field if needed
Co-authored-by: Polina Kazakova <polina@huggingface.co>
Having the file name is useful in case we need to check the extension of the file (e.g. mp3), or in general in case it includes some metadata information (track id, image id etc.)
Related to #5276