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

[Common Voice] Make sure bytes are correctly deleted if path exists #4212

Merged
merged 1 commit into from
Apr 26, 2022

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Apr 25, 2022

path should be set to local path inside audio feature if exist so that bytes can correctly be deleted.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 25, 2022

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

@polinaeterna
Copy link
Contributor

cool that you noticed that we store unnecessary bytes again :D

@@ -792,8 +792,9 @@ def _generate_examples(self, local_extracted_archive, archive_iterator, metadata
result = {key: value for key, value in zip(data_fields, field_values)}

# set audio feature
path = os.path.join(local_extracted_archive, path) if local_extracted_archive else path
result["audio"] = {"path": path, "bytes": f.read()}
Copy link
Contributor

@polinaeterna polinaeterna Apr 25, 2022

Choose a reason for hiding this comment

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

maybe to be clearer and not to read bytes when it's non needed even smth like

result["audio"] = {"path": path, "bytes": f.read() if not local_extracted_archive else None}

or

result["audio"] = {"path": path}
if not local_extracted_archive:
    result["audio"]["bytes"] = f.read()

?

not sure that it's clearer that way though

Copy link
Member

Choose a reason for hiding this comment

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

I would keep as it is right now.

Reading the bytes doesn't cost anything, since they are actually already in memory from iter_archive. And bytes are discarded if the path is a local path to avoid duplicating data already (see #4187)

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 fix !

@patrickvonplaten patrickvonplaten merged commit 8c826fb into master Apr 26, 2022
@patrickvonplaten patrickvonplaten deleted the patrickvonplaten-patch-2 branch April 26, 2022 22:48
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.

4 participants