Skip to content

Commit 7f8ed88

Browse files
committed
Fixes
1 parent d3782e2 commit 7f8ed88

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

torchvision/datasets/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from torchvision.datapoints._dataset_wrapper import wrap_dataset_for_transforms_v2
2-
31
from ._optical_flow import FlyingChairs, FlyingThings3D, HD1K, KittiFlow, Sintel
42
from ._stereo_matching import (
53
CarlaStereo,
@@ -131,3 +129,16 @@
131129
"ETH3DStereo",
132130
"wrap_dataset_for_transforms_v2",
133131
)
132+
133+
134+
# We override current module's attributes to handle the import:
135+
# from torchvision.datasets import wrap_dataset_for_transforms_v2
136+
# without a cyclic error.
137+
# Ref: https://peps.python.org/pep-0562/
138+
def __getattr__(name):
139+
if name in ("wrap_dataset_for_transforms_v2",):
140+
from torchvision.datapoints._dataset_wrapper import wrap_dataset_for_transforms_v2
141+
142+
return wrap_dataset_for_transforms_v2
143+
144+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

0 commit comments

Comments
 (0)