Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tensorflow_datasets/graphs/cardiotox/cardiotox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions tensorflow_datasets/image/lsun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" % (
Expand All @@ -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"),
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions tensorflow_datasets/image_classification/cifar10_n/cifar10_n.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
),
)

Expand Down
4 changes: 2 additions & 2 deletions tensorflow_datasets/question_answering/coqa/coqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
Expand Down
8 changes: 4 additions & 4 deletions tensorflow_datasets/ranking/istella/istella.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,19 @@ 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"),
"test": self._generate_examples(path / "test.txt"),
}

# 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
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_datasets/ranking/mslr_web/mslr_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions tensorflow_datasets/ranking/yahoo_ltrc/yahoo_ltrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand All @@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions tensorflow_datasets/rl_unplugged/dmlab_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tensorflow_datasets/rl_unplugged/rlu_atari/rlu_atari.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading