Skip to content

Turn warnings in prototype datasets tests into errors #5540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 25, 2022
Merged
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: 5 additions & 1 deletion test/builtin_dataset_mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pathlib
import pickle
import random
import warnings
import xml.etree.ElementTree as ET
from collections import defaultdict, Counter

Expand Down Expand Up @@ -470,7 +471,10 @@ def imagenet(info, root, config):
]
num_children = 1
synsets.extend((0, "", "", "", num_children, [], 0, 0) for _ in range(5))
savemat(data_root / "meta.mat", dict(synsets=synsets))
with warnings.catch_warnings():
# The warning is not for savemat, but rather for some internals savemet is using
warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning)
savemat(data_root / "meta.mat", dict(synsets=synsets))

make_tar(root, devkit_root.with_suffix(".tar.gz").name, compression="gz")
else: # config.split == "test"
Expand Down
1 change: 1 addition & 0 deletions test/test_prototype_builtin_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_coverage():
)


@pytest.mark.filterwarnings("error")
class TestCommon:
@parametrize_dataset_mocks(DATASET_MOCKS)
def test_smoke(self, test_home, dataset_mock, config):
Expand Down
4 changes: 2 additions & 2 deletions torchvision/prototype/datasets/_builtin/imagenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Mapper,
Filter,
Demultiplexer,
TarArchiveReader,
TarArchiveLoader,
Enumerator,
)
from torchvision.prototype.datasets.utils import (
Expand Down Expand Up @@ -158,7 +158,7 @@ def _make_datapipe(

# the train archive is a tar of tars
if config.split == "train":
dp = TarArchiveReader(dp)
dp = TarArchiveLoader(dp)

dp = hint_sharding(dp)
dp = hint_shuffling(dp)
Expand Down
2 changes: 1 addition & 1 deletion torchvision/prototype/datasets/_builtin/pcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _prepare_sample(self, data: Tuple[Any, Any]) -> Dict[str, Any]:
image, target = data # They're both numpy arrays at this point

return {
"image": features.Image(image),
"image": features.Image(image.transpose(2, 0, 1)),
"label": Label(target.item()),
}

Expand Down
8 changes: 4 additions & 4 deletions torchvision/prototype/datasets/utils/_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
FileLister,
FileOpener,
IterDataPipe,
ZipArchiveReader,
TarArchiveReader,
ZipArchiveLoader,
TarArchiveLoader,
RarArchiveLoader,
)
from torchvision.datasets.utils import (
Expand Down Expand Up @@ -72,8 +72,8 @@ def _loader(self, path: pathlib.Path) -> IterDataPipe[Tuple[str, IO]]:
return dp

_ARCHIVE_LOADERS = {
".tar": TarArchiveReader,
".zip": ZipArchiveReader,
".tar": TarArchiveLoader,
".zip": ZipArchiveLoader,
".rar": RarArchiveLoader,
}

Expand Down