Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Aug 18, 2023
1 parent d3782e2 commit 7f8ed88
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions torchvision/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from torchvision.datapoints._dataset_wrapper import wrap_dataset_for_transforms_v2

from ._optical_flow import FlyingChairs, FlyingThings3D, HD1K, KittiFlow, Sintel
from ._stereo_matching import (
CarlaStereo,
Expand Down Expand Up @@ -131,3 +129,16 @@
"ETH3DStereo",
"wrap_dataset_for_transforms_v2",
)


# We override current module's attributes to handle the import:
# from torchvision.datasets import wrap_dataset_for_transforms_v2
# without a cyclic error.
# Ref: https://peps.python.org/pep-0562/
def __getattr__(name):
if name in ("wrap_dataset_for_transforms_v2",):
from torchvision.datapoints._dataset_wrapper import wrap_dataset_for_transforms_v2

return wrap_dataset_for_transforms_v2

raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

0 comments on commit 7f8ed88

Please sign in to comment.