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

[Cleanup] Rewrite checksums.py to use importlib_resources #2561

Closed
Conchylicultor opened this issue Oct 12, 2020 · 1 comment · Fixed by #2564
Closed

[Cleanup] Rewrite checksums.py to use importlib_resources #2561

Conchylicultor opened this issue Oct 12, 2020 · 1 comment · Fixed by #2564
Labels

Comments

@Conchylicultor
Copy link
Member

Currently, https://github.com/tensorflow/datasets/blob/master/tensorflow_datasets/core/download/checksums.py read checksums using relative dir:

_ROOT_DIR = os.path.normpath(os.path.join(os.path.dirname(__file__), '../..'))

This is hacky when more modern https://docs.python.org/3/library/importlib.html#importlib.resources.files exists with a Pathlib-like interface.

path = importlib_resources.files('tensorflow_datasets') / 'url_checksums'
files = [p for p in path.listdir() if str(p).endswith('txt')]

It would make TFDS work even when Python is executed inside compressed .zip archive.

@iamsdas
Copy link
Contributor

iamsdas commented Oct 12, 2020

Added the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants