tensorflow / tensorflow/datasets
required dependency on importlib_resources missing
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 1.6k
- Avg merge
- 3h 54m
- Merged PRs (30d)
- 1
Description
/!\ PLEASE INCLUDE THE FULL STACKTRACE AND CODE SNIPPET
Short description
Description of the bug.
Our downstream project depends on tfds and while we're in the process of patching in our repo, the better answer would be for you to fix it directly in yours.
Simply adding a dependency for higher python versions than 3.9 for importlib_resources should be sufficient.
Our repo is https://github.com/trueagi-io/FabricPC and here's the stacktrace.
Downloading and preparing dataset Unknown size (download: Unknown size, generated: Unknown size, total: Unknown size) to /home/ni/tensorflow_datasets/mnist/3.0.1...
Traceback (most recent call last):
File "/home/ni/repos/test/test2/FabricPC/examples/mnist_demo.py", line 90, in
train_loader = MnistLoader(
^^^^^^^^^^^^
File "/home/ni/repos/test/test2/FabricPC/fabricpc/utils/data/dataloader.py", line 57, in init
ds, info = tfds.load(
^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/logging/init.py", line 176, in call
return function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/load.py", line 669, in load
_download_and_prepare_builder(dbuilder, download, download_and_prepare_kwargs)
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/load.py", line 519, in _download_and_prepare_builder
dbuilder.download_and_prepare(**download_and_prepare_kwargs)
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/logging/init.py", line 176, in call
return function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/dataset_builder.py", line 726, in download_and_prepare
dl_manager = self._make_download_manager(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/dataset_builder.py", line 1333, in _make_download_manager
url_infos=self.url_infos,
^^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/utils/py_utils.py", line 155, in get
return self.fget.get(None, objtype)() # pytype: disable=attribute-error
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/dataset_builder.py", line 492, in url_infos
checksums_path = cls._checksums_path
^^^^^^^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/utils/py_utils.py", line 155, in get
return self.fget.get(None, objtype)() # pytype: disable=attribute-error
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/dataset_builder.py", line 467, in _checksums_path
if not cls.code_path:
^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/utils/py_utils.py", line 155, in get
return self.fget.get(None, objtype)() # pytype: disable=attribute-error
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/tensorflow_datasets/core/dataset_builder.py", line 345, in code_path
or isinstance(path, importlib_resources.abc.Traversable)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/etils/epy/lazy_imports_utils.py", line 123, in getattr
return getattr(self._module, name)
^^^^^^^^^^^^
File "/usr/lib/python3.12/functools.py", line 995, in get
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/home/ni/repos/test/test2/oopy3/lib/python3.12/site-packages/etils/epy/lazy_imports_utils.py", line 84, in _module
module = importlib.import_module(self.module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'importlib_resources'
(oopy3) ni@singbuntu24:~/repos/test/test2/FabricPC$
Environment information
-
Operating System: ubuntu 24
-
Python version: 3.12.3
-
tensorflow-datasets/tfds-nightlyversion: tfds_nightly-4.9.9.dev202510250044-py3-none-any.whl -
tensorflow/tf-nightlyversion: -
Does the issue still exists with the last
tfds-nightlypackage (pip install --upgrade tfds-nightly) ?
yes it does
Reproduction instructions
In a python3.12 (and possibly other >3.9) virtual environment on a machine where a dataset has not yet been downloaded, try to use tfds to fetch the dataset and you'll get an error.
<put a code snippet, a link to a gist or a colab here>
If you share a colab, make sure to update the permissions to share it.
Link to logs
If applicable, <link to gist with logs, stack trace>
Expected behavior
What you expected to happen.
I expected the dataset to download and instead got the above stacktrace.
After pip install importlib_resources the problem disappears.
Additional context
Add any other context about the problem here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting tensorflow-datasets' dependency metadata and the dataset-loading path that reaches importlib_resources. Reproduce the failure in a Python 3.12 environment before and after installing the missing package. Done means a fresh environment can download an uncached dataset without a ModuleNotFoundError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- data, machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100