Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

DatasetInfo.read_from_directory reads the deprecated FieldDescriptor.label eagerly, warning on every open

オープン 初心者向け
#11,245 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@jabrailkhalil がすでに取り組んでいます。

2026年10月12日 から。

  • #11246 @jabrailkhalil による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, tensorflow
領域
backend, data

調査の方向性

tensorflow_datasets/core/dataset_info.pyの788~792行付近を読み、read_from_directoryが各フィールドをどのように復元するか確認してください。用意したデータセットに対して、issueにあるコマンドpython -W error::DeprecationWarningで再現してください。フィールドの復元時に、is_repeatedが利用可能であれば非推奨のlabelを読み取らなくなり、コマンドが警告なしで完了すれば、issueは解決です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
4.6k
フォーク
1.6k
平均マージ
9時間
マージ済み PR(30日)
8

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tensorflow/datasets のほかの issue

tensorflow/datasets の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。