Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _split_generators(self, dl_manager):
# There is no predefined train/val/test split for this dataset.
return [
tfds.core.SplitGenerator(
name=tfds.Split.TRAIN, gen_kwargs=dict(filepath=filepath)
name=tfds.Split.TRAIN, gen_kwargs=dict(filepath=filepath) # pyrefly: ignore[missing-attribute]
),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ def _split_generators(self, dl_manager):
)
return [
tfds.core.SplitGenerator(
name=tfds.Split.TRAIN,
name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute]
# These kwargs will be passed to _generate_examples
gen_kwargs={'csv_path': extracted_path['train_path']},
),
tfds.core.SplitGenerator(
name=tfds.Split.VALIDATION,
name=tfds.Split.VALIDATION, # pyrefly: ignore[missing-attribute]
# These kwargs will be passed to _generate_examples
gen_kwargs={'csv_path': extracted_path['dev_path']},
),
tfds.core.SplitGenerator(
name=tfds.Split.TEST,
name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute]
# These kwargs will be passed to _generate_examples
gen_kwargs={'csv_path': extracted_path['test_path']},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _info(self) -> tfds.core.DatasetInfo:
def _split_generators(self, dl_manager: tfds.download.DownloadManager):
"""Returns SplitGenerators."""
path = dl_manager.download_and_extract(URL)
return {tfds.Split.TRAIN: self._generate_examples(path)}
return {tfds.Split.TRAIN: self._generate_examples(path)} # pyrefly: ignore[missing-attribute]

def _generate_examples(self, path):
"""Yields examples."""
Expand Down
10 changes: 5 additions & 5 deletions tensorflow_datasets/datasets/flic/flic_dataset_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ def _info(self):

def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
extract_path = dl_manager.download_and_extract(self.builder_config.url)
extract_path = dl_manager.download_and_extract(self.builder_config.url) # pyrefly: ignore[missing-attribute]

mat_path = os.path.join(
extract_path, self.builder_config.dir, "examples.mat"
extract_path, self.builder_config.dir, "examples.mat" # pyrefly: ignore[missing-attribute]
)
with tf.io.gfile.GFile(mat_path, "rb") as f:
data = tfds.core.lazy_imports.scipy.io.loadmat(
Expand All @@ -111,15 +111,15 @@ def _split_generators(self, dl_manager):

return [
tfds.core.SplitGenerator(
name=tfds.Split.TRAIN,
name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute]
gen_kwargs={
"extract_path": extract_path,
"data": data,
"selection_column": 7, # indicates train split selection
},
),
tfds.core.SplitGenerator(
name=tfds.Split.TEST,
name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute]
gen_kwargs={
"extract_path": extract_path,
"data": data,
Expand All @@ -133,7 +133,7 @@ def _generate_examples(self, extract_path, data, selection_column):
for u_id, example in enumerate(data["examples"]):
if example[selection_column]:
img_path = os.path.join(
extract_path, self.builder_config.dir, "images", example[3]
extract_path, self.builder_config.dir, "images", example[3] # pyrefly: ignore[missing-attribute]
)
yield u_id, {
"image": img_path,
Expand Down
8 changes: 4 additions & 4 deletions tensorflow_datasets/datasets/groove/groove_dataset_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ def _info(self):
},
"midi": tf.string,
}
if self.builder_config.include_audio:
features_dict["audio"] = tfds.features.Audio(
dtype=np.float32, sample_rate=self.builder_config.audio_rate
if self.builder_config.include_audio: # pyrefly: ignore[missing-attribute]
features_dict["audio"] = tfds.features.Audio( # pyrefly: ignore[bad-assignment]
dtype=np.float32, sample_rate=self.builder_config.audio_rate # pyrefly: ignore[missing-attribute]
)
return self.dataset_info_from_configs(
features=tfds.features.FeaturesDict(features_dict),
features=tfds.features.FeaturesDict(features_dict), # pyrefly: ignore[bad-argument-type]
homepage="https://g.co/magenta/groove-dataset",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,20 @@ def _split_generators(self, dl_manager):
splits = []
_add_split_if_exists(
split_list=splits,
split=tfds.Split.TRAIN,
split=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute]
split_path=train_path,
dl_manager=dl_manager,
)
_add_split_if_exists(
split_list=splits,
split=tfds.Split.VALIDATION,
split=tfds.Split.VALIDATION, # pyrefly: ignore[missing-attribute]
split_path=val_path,
dl_manager=dl_manager,
validation_labels=imagenet_common.get_validation_labels(val_path),
)
_add_split_if_exists(
split_list=splits,
split=tfds.Split.TEST,
split=tfds.Split.TEST, # pyrefly: ignore[missing-attribute]
split_path=test_path,
dl_manager=dl_manager,
labels_exist=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _split_generators(self, dl_manager):
splits = super(Builder, self)._split_generators(dl_manager)

corruptions.FROST_FILENAMES = dl_manager.download(_FROST_FILENAMES)
return [s for s in splits if s.name != tfds.Split.TRAIN]
return [s for s in splits if s.name != tfds.Split.TRAIN] # pyrefly: ignore[missing-attribute]

def _generate_examples(
self, archive, validation_labels=None, labels_exist=None
Expand Down Expand Up @@ -215,8 +215,8 @@ def _get_corrupted_example(self, x):
Returns:
numpy array, corrupted images.
"""
corruption_type = self.builder_config.corruption_type
severity = self.builder_config.severity
corruption_type = self.builder_config.corruption_type # pyrefly: ignore[missing-attribute]
severity = self.builder_config.severity # pyrefly: ignore[missing-attribute]
x = np.clip(x, 0, 255)

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _split_generators(self, dl_manager):
)

# Download and load subset file.
subset_file = SUBSET2FILES[self.builder_config.name]
subset_file = SUBSET2FILES[self.builder_config.name] # pyrefly: ignore[missing-attribute]
if isinstance(subset_file, list): # it will only be a list during testing,
subset_file = subset_file[0] # where the first entry is 1shot.txt.
subset = set(subset_file.read_text().splitlines())
Expand All @@ -77,13 +77,13 @@ def _split_generators(self, dl_manager):
tuneset = set(TUNE_FILE.read_text().splitlines())

return {
tfds.Split.TRAIN: self._generate_examples(
tfds.Split.TRAIN: self._generate_examples( # pyrefly: ignore[missing-attribute]
archive=dl_manager.iter_archive(train_path), subset=subset
),
tfds.Split('tune'): self._generate_examples(
archive=dl_manager.iter_archive(train_path), subset=tuneset
),
tfds.Split.VALIDATION: self._generate_examples(
tfds.Split.VALIDATION: self._generate_examples( # pyrefly: ignore[missing-attribute]
archive=dl_manager.iter_archive(val_path),
validation_labels=imagenet_common.get_validation_labels(val_path),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _split_generators(self, dl_manager):
)
return [
tfds.core.SplitGenerator(
name=tfds.Split.VALIDATION,
name=tfds.Split.VALIDATION, # pyrefly: ignore[missing-attribute]
gen_kwargs={
'archive': dl_manager.iter_archive(val_path),
'original_labels': imagenet_common.get_validation_labels(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ def _split_generators(self, dl_manager):
)

# Download and load subset file.
subset_file = dl_manager.download(SUBSET2FILES[self.builder_config.name])
subset_file = dl_manager.download(SUBSET2FILES[self.builder_config.name]) # pyrefly: ignore[missing-attribute]
if isinstance(subset_file, list): # it will only be a list during testing,
subset_file = subset_file[0] # where the first entry is 1percent.txt.
with epath.Path(subset_file).open() as fp:
subset = set(fp.read().splitlines()) # remove trailing `\r` in Windows

return [
tfds.core.SplitGenerator(
name=tfds.Split.TRAIN,
name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute]
gen_kwargs={
'archive': dl_manager.iter_archive(train_path),
'subset': subset,
},
),
tfds.core.SplitGenerator(
name=tfds.Split.VALIDATION,
name=tfds.Split.VALIDATION, # pyrefly: ignore[missing-attribute]
gen_kwargs={
'archive': dl_manager.iter_archive(val_path),
'validation_labels': imagenet_common.get_validation_labels(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _split_generators(self, dl_manager):
return [
tfds.core.SplitGenerator(
# The dataset provides only a test split.
name=tfds.Split.TEST,
name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute]
# These kwargs will be passed to _generate_examples
gen_kwargs={'imagenet_a_root': imagenet_a_root},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _split_generators(self, dl_manager):
return [
tfds.core.SplitGenerator(
# The dataset provides only a test split.
name=tfds.Split.TEST,
name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute]
# These kwargs will be passed to _generate_examples
gen_kwargs={'imagenet_r_root': imagenet_r_root},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Builder(tfds.core.GeneratorBasedBuilder):

def _info(self):
names_file = tfds.core.tfds_path(_LABELS_FNAME)
size = self.builder_config.size
size = self.builder_config.size # pyrefly: ignore[missing-attribute]
return self.dataset_info_from_configs(
features=tfds.features.FeaturesDict({
'image': tfds.features.Image(shape=(size, size, 3)),
Expand All @@ -75,7 +75,7 @@ def _info(self):
)

def _split_generators(self, dl_manager):
size = self.builder_config.size
size = self.builder_config.size # pyrefly: ignore[missing-attribute]

if size in [8, 16, 32]:
train_path, val_path = dl_manager.download([
Expand All @@ -96,7 +96,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={
'archive': itertools.chain(
*[
Expand All @@ -107,7 +107,7 @@ def _split_generators(self, dl_manager):
},
),
tfds.core.SplitGenerator(
name=tfds.Split.VALIDATION,
name=tfds.Split.VALIDATION, # pyrefly: ignore[missing-attribute]
gen_kwargs={
'archive': dl_manager.iter_archive(val_path),
},
Expand All @@ -121,7 +121,7 @@ def _generate_examples(self, archive):
if content:
fobj_mem = io.BytesIO(content)
data = np.load(fobj_mem, allow_pickle=False)
size = self.builder_config.size
size = self.builder_config.size # pyrefly: ignore[missing-attribute]
for i, (image, label) in enumerate(zip(data['data'], data['labels'])):
record = {
# The data is packed flat as CHW where as most image datasets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _split_generators(self, dl_manager: tfds.download.DownloadManager):
path = dl_manager.download(_IMAGENET_SKETCH_URL)
return [
tfds.core.SplitGenerator(
name=tfds.Split.TEST,
name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute]
gen_kwargs={
'archive': dl_manager.iter_archive(path),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ def _info(self):

def _split_generators(self, dl_manager):
"""Returns a SplitGenerator for the test set."""
variant_url = _IMAGENET_V2_URLS[self.builder_config.variant]
variant_url = _IMAGENET_V2_URLS[self.builder_config.variant] # pyrefly: ignore[missing-attribute]
imagenet_v2_root = os.path.join(
dl_manager.download_and_extract(variant_url),
_TAR_TOPDIR[self.builder_config.variant],
_TAR_TOPDIR[self.builder_config.variant], # pyrefly: ignore[missing-attribute]
)
return [
tfds.core.SplitGenerator(
# The dataset provides only a test split.
name=tfds.Split.TEST,
name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute]
# These kwargs will be passed to _generate_examples
gen_kwargs={'imagenet_v2_root': imagenet_v2_root},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ def _info(self):

def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
dirname = self.builder_config.dirname
dirname = self.builder_config.dirname # pyrefly: ignore[missing-attribute]
url = _URL_PREFIX + "{}.tgz".format(dirname)
path = dl_manager.download_and_extract(url)
train_path = os.path.join(path, dirname, "train")
val_path = os.path.join(path, dirname, "val")

return [
tfds.core.SplitGenerator(
name=tfds.Split.TRAIN,
name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute]
gen_kwargs={
"datapath": train_path,
},
),
tfds.core.SplitGenerator(
name=tfds.Split.VALIDATION,
name=tfds.Split.VALIDATION, # pyrefly: ignore[missing-attribute]
gen_kwargs={
"datapath": val_path,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _info(self):

def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
size = self.builder_config.size
size = self.builder_config.size # pyrefly: ignore[missing-attribute]
if size in _SIZES:
size_str = "" if size == "full-size" else "-" + size[:-2]
url = "/".join([_URL_PREFIX, "imagewang%s.tgz" % size_str])
Expand All @@ -85,13 +85,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={
"datapath": train_path,
},
),
tfds.core.SplitGenerator(
name=tfds.Split.VALIDATION,
name=tfds.Split.VALIDATION, # pyrefly: ignore[missing-attribute]
gen_kwargs={
"datapath": val_path,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _info(self):
return self.dataset_info_from_configs(
features=tfds.features.FeaturesDict({
"text": tfds.features.Text(
encoder_config=self.builder_config.text_encoder_config
encoder_config=self.builder_config.text_encoder_config # pyrefly: ignore[missing-attribute]
),
"label": tfds.features.ClassLabel(names=["neg", "pos"]),
}),
Expand All @@ -86,14 +86,14 @@ def _split_generators(self, dl_manager):

return [
tfds.core.SplitGenerator(
name=tfds.Split.TRAIN,
name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute]
gen_kwargs={
"archive": archive(),
"directory": os.path.join("aclImdb", "train"),
},
),
tfds.core.SplitGenerator(
name=tfds.Split.TEST,
name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute]
gen_kwargs={
"archive": archive(),
"directory": os.path.join("aclImdb", "test"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,21 @@ def _split_generators(

return [
tfds.core.SplitGenerator(
name=tfds.Split.TRAIN,
name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute]
gen_kwargs={
"day_to_paths": _get_day_to_paths(
os.path.join(data_dir, "train")
)
},
),
tfds.core.SplitGenerator(
name=tfds.Split.VALIDATION,
name=tfds.Split.VALIDATION, # pyrefly: ignore[missing-attribute]
gen_kwargs={
"day_to_paths": _get_day_to_paths(os.path.join(data_dir, "dev"))
},
),
tfds.core.SplitGenerator(
name=tfds.Split.TEST,
name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute]
gen_kwargs={
"day_to_paths": _get_day_to_paths(
os.path.join(data_dir, "test")
Expand Down
Loading
Loading