Skip to content

Commit de936ed

Browse files
committed
add test
1 parent 123270c commit de936ed

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/test_prototype_builtin_datasets.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import io
2+
import pathlib
23

34
import builtin_dataset_mocks
45
import pytest
@@ -51,6 +52,34 @@ def dataset_parametrization(*names, decoder=to_bytes):
5152
)
5253

5354

55+
def test_optional_dependencies():
56+
required_dependencies = set()
57+
for name in datasets.list():
58+
required_dependencies.update(datasets.info(name).dependecies)
59+
60+
with open(pathlib.Path(__file__).parents[1] / "optional-requirements.txt") as file:
61+
for line in file:
62+
if line.startswith("#") and line[1:].strip() == "datasets":
63+
break
64+
65+
registered_dependencies = set()
66+
for line in file:
67+
if line.startswith("#"):
68+
break
69+
70+
registered_dependencies.add(line.strip())
71+
72+
# TODO: Until we have feature parity between the stable and prototype datasets, we check if the registered
73+
# dependencies are a superset of the requires ones. Afterwards we should check for equality.
74+
missing_dependencies = required_dependencies - registered_dependencies
75+
if missing_dependencies:
76+
raise AssertionError(
77+
f"The datasets depend on the third-party packages {sequence_to_str(sorted(missing_dependencies))}, "
78+
f"but they are not listed in the '# datasets' section in the file $TORCHVISION/optional-requirements.txt. "
79+
"Please add them."
80+
)
81+
82+
5483
class TestCommon:
5584
@dataset_parametrization()
5685
def test_smoke(self, dataset, mock_info):

0 commit comments

Comments
 (0)