diff --git a/tensorflow_datasets/graphs/cardiotox/cardiotox.py b/tensorflow_datasets/graphs/cardiotox/cardiotox.py index fb6ba4f5d5d..121a1414444 100644 --- a/tensorflow_datasets/graphs/cardiotox/cardiotox.py +++ b/tensorflow_datasets/graphs/cardiotox/cardiotox.py @@ -142,13 +142,13 @@ def _split_generators(self, dl_manager: tfds.download.DownloadManager): """Returns SplitGenerators.""" return { - tfds.Split.TRAIN: self._generate_examples( + tfds.Split.TRAIN: self._generate_examples( # pyrefly: ignore[missing-attribute] os.path.join(_DATA_URL, _FILENAME_TRAIN), is_training=True ), - tfds.Split.VALIDATION: self._generate_examples( + tfds.Split.VALIDATION: self._generate_examples( # pyrefly: ignore[missing-attribute] os.path.join(_DATA_URL, _FILENAME_VAL), is_training=False ), - tfds.Split.TEST: self._generate_examples( + tfds.Split.TEST: self._generate_examples( # pyrefly: ignore[missing-attribute] os.path.join(_DATA_URL, _FILENAME_TEST), is_training=False ), tfds.Split('test2'): self._generate_examples( diff --git a/tensorflow_datasets/image/lsun.py b/tensorflow_datasets/image/lsun.py index 8d910bcb081..3e5661af310 100644 --- a/tensorflow_datasets/image/lsun.py +++ b/tensorflow_datasets/image/lsun.py @@ -119,14 +119,14 @@ def _info(self): ) def _split_generators(self, dl_manager): - if self.builder_config.name in _SCENES_CATEGORIES: + if self.builder_config.name in _SCENES_CATEGORIES: # pyrefly: ignore[missing-attribute] extracted_dirs = dl_manager.download_and_extract({ "train": LSUN_SCENE_URL % (self.builder_config.name, "train"), "val": LSUN_SCENE_URL % (self.builder_config.name, "val"), }) return [ tfds.core.SplitGenerator( - name=tfds.Split.TRAIN, + name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute] gen_kwargs={ "extracted_dir": extracted_dirs["train"], "file_path": "%s_%s_lmdb" % ( @@ -136,7 +136,7 @@ def _split_generators(self, dl_manager): }, ), tfds.core.SplitGenerator( - name=tfds.Split.VALIDATION, + name=tfds.Split.VALIDATION, # pyrefly: ignore[missing-attribute] gen_kwargs={ "extracted_dir": extracted_dirs["val"], "file_path": "%s_%s_lmdb" % (self.builder_config.name, "val"), @@ -151,7 +151,7 @@ def _split_generators(self, dl_manager): ) return [ tfds.core.SplitGenerator( - name=tfds.Split.TRAIN, + name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute] gen_kwargs={ "extracted_dir": extracted_dirs["train"], "file_path": self.builder_config.name, diff --git a/tensorflow_datasets/image_classification/cifar100_n/cifar100_n.py b/tensorflow_datasets/image_classification/cifar100_n/cifar100_n.py index e9e00ab639c..149d1759e0a 100644 --- a/tensorflow_datasets/image_classification/cifar100_n/cifar100_n.py +++ b/tensorflow_datasets/image_classification/cifar100_n/cifar100_n.py @@ -193,12 +193,12 @@ def _generate_examples(self, split_prefix, filepaths, dl_paths): # Note: The human labels are provided according to default shuffling # of 'cifar100'. We need to invert the shuffling to assign the right # human label to each example. - annotations_index = np.where(annotations_order == index)[0][0] + annotations_index = np.where(annotations_order == index)[0][0] # pyrefly: ignore[unbound-name] - record['noise_label'] = noise_label[annotations_index] + record['noise_label'] = noise_label[annotations_index] # pyrefly: ignore[unbound-name] # Worker metadata is shared every 5 samples - record['worker_id'] = worker_id[index // 5] - record['worker_time'] = worker_time[index // 5] + record['worker_id'] = worker_id[index // 5] # pyrefly: ignore[unbound-name] + record['worker_time'] = worker_time[index // 5] # pyrefly: ignore[unbound-name] else: # There is no annotator metadata for test split record['noise_label'] = -1 diff --git a/tensorflow_datasets/image_classification/cifar10_n/cifar10_n.py b/tensorflow_datasets/image_classification/cifar10_n/cifar10_n.py index 49b35f751fb..f9fb3e2a9f7 100644 --- a/tensorflow_datasets/image_classification/cifar10_n/cifar10_n.py +++ b/tensorflow_datasets/image_classification/cifar10_n/cifar10_n.py @@ -217,21 +217,21 @@ def _generate_examples(self, split_prefix, filepaths, dl_paths): # Note: The human labels are provided according to default shuffling # of 'cifar10'. We need to invert the shuffling to assign the right # human label to each example. - annotations_index = np.where(annotations_order == index)[0][0] + annotations_index = np.where(annotations_order == index)[0][0] # pyrefly: ignore[unbound-name] - record['worse_label'] = worse_label[annotations_index] - record['aggre_label'] = aggre_label[annotations_index] - record['random_label1'] = random_label1[annotations_index] - record['random_label2'] = random_label2[annotations_index] - record['random_label3'] = random_label3[annotations_index] + record['worse_label'] = worse_label[annotations_index] # pyrefly: ignore[unbound-name] + record['aggre_label'] = aggre_label[annotations_index] # pyrefly: ignore[unbound-name] + record['random_label1'] = random_label1[annotations_index] # pyrefly: ignore[unbound-name] + record['random_label2'] = random_label2[annotations_index] # pyrefly: ignore[unbound-name] + record['random_label3'] = random_label3[annotations_index] # pyrefly: ignore[unbound-name] # Worker metadata is shared every 10 samples - record['worker1_id'] = worker1_id[index // 10] - record['worker1_time'] = worker1_time[index // 10] - record['worker2_id'] = worker2_id[index // 10] - record['worker2_time'] = worker2_time[index // 10] - record['worker3_id'] = worker3_id[index // 10] - record['worker3_time'] = worker3_time[index // 10] + record['worker1_id'] = worker1_id[index // 10] # pyrefly: ignore[unbound-name] + record['worker1_time'] = worker1_time[index // 10] # pyrefly: ignore[unbound-name] + record['worker2_id'] = worker2_id[index // 10] # pyrefly: ignore[unbound-name] + record['worker2_time'] = worker2_time[index // 10] # pyrefly: ignore[unbound-name] + record['worker3_id'] = worker3_id[index // 10] # pyrefly: ignore[unbound-name] + record['worker3_time'] = worker3_time[index // 10] # pyrefly: ignore[unbound-name] else: # There is no annotator metadata for test split record['worse_label'] = -1 diff --git a/tensorflow_datasets/image_classification/controlled_noisy_web_labels/controlled_noisy_web_labels.py b/tensorflow_datasets/image_classification/controlled_noisy_web_labels/controlled_noisy_web_labels.py index 642f01b189c..1d1a2defc07 100644 --- a/tensorflow_datasets/image_classification/controlled_noisy_web_labels/controlled_noisy_web_labels.py +++ b/tensorflow_datasets/image_classification/controlled_noisy_web_labels/controlled_noisy_web_labels.py @@ -361,7 +361,7 @@ def _info(self) -> tfds.core.DatasetInfo: features = {} features['image'] = tfds.features.Image() features['label'] = tfds.features.ClassLabel( - num_classes=self.builder_config.num_classes + num_classes=self.builder_config.num_classes # pyrefly: ignore[missing-attribute] ) features['is_clean'] = tfds.features.Tensor(shape=(), dtype=np.bool_) features['id'] = tfds.features.Text() @@ -421,16 +421,16 @@ def _split_generators(self, dl_manager: tfds.download.DownloadManager): split_to_generator = {} - split_to_generator[tfds.Split.VALIDATION] = self._generate_val_examples( + split_to_generator[tfds.Split.VALIDATION] = self._generate_val_examples( # pyrefly: ignore[missing-attribute] val_split_file, dl_manager.iter_archive(val_path) ) for percent in _PERCENTS: - split_name = tfds.Split.TRAIN + '_' + '{:02d}'.format(percent) + split_name = tfds.Split.TRAIN + '_' + '{:02d}'.format(percent) # pyrefly: ignore[missing-attribute] split_file = os.path.join( noisy_split_path, '{}_noise_nl_{}'.format( - self.builder_config.color, str(percent / 100) + self.builder_config.color, str(percent / 100) # pyrefly: ignore[missing-attribute] ), ) split_to_generator[split_name] = self._generate_examples( diff --git a/tensorflow_datasets/image_classification/domainnet/domainnet.py b/tensorflow_datasets/image_classification/domainnet/domainnet.py index 226d1fb7e61..86434654153 100644 --- a/tensorflow_datasets/image_classification/domainnet/domainnet.py +++ b/tensorflow_datasets/image_classification/domainnet/domainnet.py @@ -432,10 +432,10 @@ def _info(self) -> tfds.core.DatasetInfo: def _split_generators(self, dl_manager: tfds.download.DownloadManager): """Returns SplitGenerators.""" - img_download_url = f'{self._BASE_URL}/{self.builder_config.img_url}' + img_download_url = f'{self._BASE_URL}/{self.builder_config.img_url}' # pyrefly: ignore[missing-attribute] self.img_path = dl_manager.download_and_extract(img_download_url) - domain = self.builder_config.name + domain = self.builder_config.name # pyrefly: ignore[missing-attribute] train_split_url = f'{self._BASE_URL}/domainnet/txt/{domain}_train.txt' test_split_url = f'{self._BASE_URL}/domainnet/txt/{domain}_test.txt' @@ -456,7 +456,7 @@ def _generate_examples( for i, img_class_line in enumerate(split_file.read().split('\n')): if not img_class_line: continue - key = f'{self.builder_config.name}_{split}_{i:08d}' + key = f'{self.builder_config.name}_{split}_{i:08d}' # pyrefly: ignore[missing-attribute] example_path, example_class = img_class_line.split(' ') example_fullpath = os.path.join(self.img_path, example_path) # pytype: disable=attribute-error # gen-stub-imports diff --git a/tensorflow_datasets/image_classification/i_naturalist2021/i_naturalist2021.py b/tensorflow_datasets/image_classification/i_naturalist2021/i_naturalist2021.py index c403e043ea8..ba9835897e3 100644 --- a/tensorflow_datasets/image_classification/i_naturalist2021/i_naturalist2021.py +++ b/tensorflow_datasets/image_classification/i_naturalist2021/i_naturalist2021.py @@ -109,9 +109,9 @@ def _split_generators(self, dl_manager: tfds.download.DownloadManager): generate_dict = {} for split, split_file in _SPLIT_FILENAMES.items(): generate_dict[split] = self._generate_examples( - images_archive=dl_manager.iter_archive(output_paths[f'{split}_img']), + images_archive=dl_manager.iter_archive(output_paths[f'{split}_img']), # pyrefly: ignore[bad-index] json_file=os.path.join( - output_paths[f'{split}_json'], f'{split_file}.json' + output_paths[f'{split}_json'], f'{split_file}.json' # pyrefly: ignore[bad-index] ), ) diff --git a/tensorflow_datasets/question_answering/coqa/coqa.py b/tensorflow_datasets/question_answering/coqa/coqa.py index 37c5066d827..ab1a19c7430 100644 --- a/tensorflow_datasets/question_answering/coqa/coqa.py +++ b/tensorflow_datasets/question_answering/coqa/coqa.py @@ -74,13 +74,13 @@ def _split_generators(self, dl_manager): return [ tfds.core.SplitGenerator( - name=tfds.Split.TRAIN, + name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute] gen_kwargs={ "filepath": downloaded_files["train"], }, ), tfds.core.SplitGenerator( - name=tfds.Split.TEST, + name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute] gen_kwargs={ "filepath": downloaded_files["test"], }, diff --git a/tensorflow_datasets/ranking/istella/istella.py b/tensorflow_datasets/ranking/istella/istella.py index 53fb4c4e7f9..dd903d3f5a0 100644 --- a/tensorflow_datasets/ranking/istella/istella.py +++ b/tensorflow_datasets/ranking/istella/istella.py @@ -136,11 +136,11 @@ def _info(self) -> tfds.core.DatasetInfo: def _split_generators(self, dl_manager: tfds.download.DownloadManager): """Returns SplitGenerators.""" - path = dl_manager.download_and_extract(_URLS[self.builder_config.name]) + path = dl_manager.download_and_extract(_URLS[self.builder_config.name]) # pyrefly: ignore[missing-attribute] # For some dataset configs, the data is in a subdirectory. - if self.builder_config.subdirectory is not None: - path = path / self.builder_config.subdirectory + if self.builder_config.subdirectory is not None: # pyrefly: ignore[missing-attribute] + path = path / self.builder_config.subdirectory # pyrefly: ignore[unsupported-operation] splits = { "train": self._generate_examples(path / "train.txt"), @@ -148,7 +148,7 @@ def _split_generators(self, dl_manager: tfds.download.DownloadManager): } # For some dataset configs, there is an additional validation split. - if self.builder_config.has_vali: + if self.builder_config.has_vali: # pyrefly: ignore[missing-attribute] splits["vali"] = self._generate_examples(path / "vali.txt") return splits diff --git a/tensorflow_datasets/ranking/mslr_web/mslr_web.py b/tensorflow_datasets/ranking/mslr_web/mslr_web.py index 1ed39d025f8..dacf60a9569 100644 --- a/tensorflow_datasets/ranking/mslr_web/mslr_web.py +++ b/tensorflow_datasets/ranking/mslr_web/mslr_web.py @@ -267,8 +267,8 @@ def _info(self) -> tfds.core.DatasetInfo: def _split_generators(self, dl_manager: tfds.download.DownloadManager): """Returns SplitGenerators.""" - size = self.builder_config.size - fold = self.builder_config.fold + size = self.builder_config.size # pyrefly: ignore[missing-attribute] + fold = self.builder_config.fold # pyrefly: ignore[missing-attribute] path = dl_manager.download_and_extract(_URLS[size]) return { diff --git a/tensorflow_datasets/ranking/yahoo_ltrc/yahoo_ltrc.py b/tensorflow_datasets/ranking/yahoo_ltrc/yahoo_ltrc.py index 2a50b82d06f..f0acbe26a60 100644 --- a/tensorflow_datasets/ranking/yahoo_ltrc/yahoo_ltrc.py +++ b/tensorflow_datasets/ranking/yahoo_ltrc/yahoo_ltrc.py @@ -99,7 +99,7 @@ def _info(self) -> tfds.core.DatasetInfo: encoding = tfds.features.Encoding.ZLIB features = { "float_features": tfds.features.Tensor( - shape=(None, self.builder_config.num_features), + shape=(None, self.builder_config.num_features), # pyrefly: ignore[missing-attribute] dtype=np.float64, encoding=encoding, ), @@ -126,10 +126,10 @@ def _split_generators(self, dl_manager: tfds.download.DownloadManager): archive_path = dl_manager.manual_dir / "ltrc_yahoo.tar.bz2" path = dl_manager.extract(archive_path) - prefix = self.builder_config.prefix + prefix = self.builder_config.prefix # pyrefly: ignore[missing-attribute] feature_names = { n: f"feature_{n}" - for n in range(1, self.builder_config.num_features + 1) + for n in range(1, self.builder_config.num_features + 1) # pyrefly: ignore[missing-attribute] } splits = { diff --git a/tensorflow_datasets/rl_unplugged/dmlab_dataset.py b/tensorflow_datasets/rl_unplugged/dmlab_dataset.py index edaf75e6936..f75db39814c 100644 --- a/tensorflow_datasets/rl_unplugged/dmlab_dataset.py +++ b/tensorflow_datasets/rl_unplugged/dmlab_dataset.py @@ -118,8 +118,8 @@ def get_citation(self): return _CITATION def get_file_prefix(self): - run = self.builder_config.name - task = self.builder_config.task + run = self.builder_config.name # pyrefly: ignore[missing-attribute] + task = self.builder_config.task # pyrefly: ignore[missing-attribute] return f'{self._INPUT_FILE_PREFIX}/{task}/{run}/tfrecord' def num_shards(self): @@ -129,7 +129,7 @@ def tf_example_to_step_ds( self, tf_example: tf.train.Example ) -> Dict[str, Any]: """Create an episode from a TF example.""" - episode_length = self.builder_config.episode_length + episode_length = self.builder_config.episode_length # pyrefly: ignore[missing-attribute] # Parse tf.Example. def sequence_feature(shape, dtype=tf.float32): diff --git a/tensorflow_datasets/rl_unplugged/rlu_atari/rlu_atari.py b/tensorflow_datasets/rl_unplugged/rlu_atari/rlu_atari.py index 7bae116baf0..8e138de061e 100644 --- a/tensorflow_datasets/rl_unplugged/rlu_atari/rlu_atari.py +++ b/tensorflow_datasets/rl_unplugged/rlu_atari/rlu_atari.py @@ -51,12 +51,12 @@ def get_citation(self): return atari_utils.citation() def get_file_prefix(self): - run = self.builder_config.run - game = self.builder_config.game + run = self.builder_config.run # pyrefly: ignore[missing-attribute] + game = self.builder_config.game # pyrefly: ignore[missing-attribute] return atari_utils.file_prefix(self._INPUT_FILE_PREFIX, run, game) def num_shards(self): - return atari_utils.num_shards(self.builder_config.game, self._SHARDS) + return atari_utils.num_shards(self.builder_config.game, self._SHARDS) # pyrefly: ignore[missing-attribute] def get_episode_id(self, episode): return atari_utils.episode_id(episode) diff --git a/tensorflow_datasets/rl_unplugged/rlu_atari_checkpoints/rlu_atari_checkpoints.py b/tensorflow_datasets/rl_unplugged/rlu_atari_checkpoints/rlu_atari_checkpoints.py index 8d79c2a9862..664bc1485f4 100644 --- a/tensorflow_datasets/rl_unplugged/rlu_atari_checkpoints/rlu_atari_checkpoints.py +++ b/tensorflow_datasets/rl_unplugged/rlu_atari_checkpoints/rlu_atari_checkpoints.py @@ -56,12 +56,12 @@ def get_citation(self): return atari_utils.citation() def get_file_prefix(self): - run = self.builder_config.run - game = self.builder_config.game + run = self.builder_config.run # pyrefly: ignore[missing-attribute] + game = self.builder_config.game # pyrefly: ignore[missing-attribute] return atari_utils.file_prefix(self._INPUT_FILE_PREFIX, run, game) def num_shards(self): - return atari_utils.num_shards(self.builder_config.game, self._SHARDS) + return atari_utils.num_shards(self.builder_config.game, self._SHARDS) # pyrefly: ignore[missing-attribute] def get_episode_id(self, episode): return atari_utils.episode_id(episode) diff --git a/tensorflow_datasets/rl_unplugged/rlu_atari_checkpoints_ordered/rlu_atari_checkpoints_ordered.py b/tensorflow_datasets/rl_unplugged/rlu_atari_checkpoints_ordered/rlu_atari_checkpoints_ordered.py index 418c79ff3e1..4f99f80f83f 100644 --- a/tensorflow_datasets/rl_unplugged/rlu_atari_checkpoints_ordered/rlu_atari_checkpoints_ordered.py +++ b/tensorflow_datasets/rl_unplugged/rlu_atari_checkpoints_ordered/rlu_atari_checkpoints_ordered.py @@ -77,12 +77,12 @@ def get_citation(self): return atari_utils.citation() def get_file_prefix(self): - run = self.builder_config.run - game = self.builder_config.game + run = self.builder_config.run # pyrefly: ignore[missing-attribute] + game = self.builder_config.game # pyrefly: ignore[missing-attribute] return atari_utils.file_prefix(self._INPUT_FILE_PREFIX, run, game) def num_shards(self): - return atari_utils.num_shards(self.builder_config.game, self._SHARDS) + return atari_utils.num_shards(self.builder_config.game, self._SHARDS) # pyrefly: ignore[missing-attribute] def get_episode_id(self, episode): # TODO(b/209933106): Ordered datasets need an int id so we cannot use the