DatasetInfo.read_from_directory reads the deprecated FieldDescriptor.label eagerly, warning on every open
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python, tensorflow
Research direction
Read tensorflow_datasets/core/dataset_info.py around lines 788–792 and check how read_from_directory restores each field. Reproduce with the issue's python -W error::DeprecationWarning command against a prepared dataset. The issue is resolved when restoring fields no longer reads the deprecated label when is_repeated is available, and the command completes without the warning.
Written by the indexing model from the issue text.
Description
DatasetInfo.read_from_directory evaluates the deprecated protobuf label fallback eagerly on every field it restores, so every open of a prepared dataset emits a protobuf DeprecationWarning (and fails under -W error), even on protobuf versions that provide is_repeated.
tensorflow_datasets/core/dataset_info.py (master, and 4.9.10, lines ~788-792):
is_repeated = getattr(
field,
"is_repeated",
getattr(field, "label", None) == getattr(field, "LABEL_REPEATED", 3),
)
The third argument to getattr is evaluated before getattr runs, so field.label is read even when field.is_repeated exists. With protobuf releases that deprecate FieldDescriptor.label, this warns once per restored field:
DeprecationWarning: label() is deprecated. Use is_required() or is_repeated() instead.
Suggested fix: evaluate the fallback only when is_repeated is missing, e.g.
if hasattr(field, "is_repeated"):
is_repeated = field.is_repeated
else:
is_repeated = field.label == field.LABEL_REPEATED
Reproduction: with tensorflow-datasets 4.9.10 and a current protobuf, python -W error::DeprecationWarning -c "import tensorflow_datasets as tfds; tfds.builder('mnist', data_dir=<a prepared dir>).info" raises from dataset_info.py:791.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 1.6k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from tensorflow/datasets
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
tensorflow/datasets#11253 ·
Maintainers usually reply within 1 day
-
required dependency on importlib_resources missingPossibly taken @ArS377 claimed this 102 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tensorflow/datasets#11212 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
tfds.features.Audio eagerly imports TensorFlow in _AudioDecoder.__init__, breaking TensorFlow-less usagePossibly taken @raashish1601 claimed this 29 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 76/100
tensorflow/datasets#11233 ·
Maintainers usually reply within 1 day
-
dataset request
Difficulty 4/5 3-5 days Newbie friendliness 20/100
tensorflow/datasets#11228 ·
Maintainers usually reply within 1 day
-
QM9 download links are brokenPossibly taken @mylonasc claimed this 141 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
tensorflow/datasets#11210 · 1 comment ·
Maintainers usually reply within 1 day
All issues in tensorflow/datasets
Similar issues
-
Server mode OAuth2: 'NoneType' object is not subscriptable on every request after re-submitting the OAuth2 login while already logged inPossibly taken @Rarasinhoo claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
pgadmin-org/pgadmin4#10733 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
aws-samples/sample-per-model-bedrock#752 ·
Maintainers usually reply within 1 day
-
lesson-submission pending-review
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Ikalus1988/MisakaNet#4452 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OCHA-DAP/topo-tools#250 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day