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

Save file name in embed_storage #5285

Merged
merged 4 commits into from
Nov 24, 2022
Merged

Save file name in embed_storage #5285

merged 4 commits into from
Nov 24, 2022

Conversation

lhoestq
Copy link
Member

@lhoestq lhoestq commented Nov 23, 2022

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

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 23, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@polinaeterna polinaeterna left a 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()],
Copy link
Contributor

@polinaeterna polinaeterna Nov 23, 2022

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.

Copy link
Member Author

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

Copy link
Contributor

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

@lhoestq
Copy link
Member Author

lhoestq commented Nov 23, 2022

I updated the tests, met le know if it sounds good to you now :)

Copy link
Contributor

@polinaeterna polinaeterna left a 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()],
Copy link
Contributor

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

tests/test_table.py Show resolved Hide resolved
tests/test_upstream_hub.py Show resolved Hide resolved
Co-authored-by: Polina Kazakova <polina@huggingface.co>
@lhoestq lhoestq merged commit 494a3d8 into main Nov 24, 2022
@lhoestq lhoestq deleted the save-paths-in-embed_storage branch November 24, 2022 14:08
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.

3 participants