From a5b4f2d0a7c03110d484f9d91253bb55efbd930f Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Fri, 4 Mar 2022 08:27:45 +0100 Subject: [PATCH 1/5] [DEBUG] eurosat prototype on windows and macos --- .circleci/config.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b616f3bde93..68212b7fc74 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -335,9 +335,7 @@ jobs: file_or_dir: test/test_onnx.py unittest_prototype: - docker: - - image: circleci/python:3.7 - resource_class: xlarge + executor: windows-cpu steps: - checkout - run: @@ -357,7 +355,7 @@ jobs: name: Enable prototype tests command: echo 'export PYTORCH_TEST_WITH_PROTOTYPE=1' >> $BASH_ENV - run_tests_selective: - file_or_dir: test/test_prototype_*.py + file_or_dir: test/test_prototype_builtin_datasets.py binary_linux_wheel: <<: *binary_common From ac5a25ffb03573d48eb8596aa26800836cf1a3f8 Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Fri, 4 Mar 2022 08:46:26 +0100 Subject: [PATCH 2/5] print paths --- .circleci/config.yml | 2 +- torchvision/prototype/datasets/_builtin/eurosat.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 68212b7fc74..e6786f7f964 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -355,7 +355,7 @@ jobs: name: Enable prototype tests command: echo 'export PYTORCH_TEST_WITH_PROTOTYPE=1' >> $BASH_ENV - run_tests_selective: - file_or_dir: test/test_prototype_builtin_datasets.py + file_or_dir: test/test_prototype_builtin_datasets.py::TestCommon -k eurosat binary_linux_wheel: <<: *binary_common diff --git a/torchvision/prototype/datasets/_builtin/eurosat.py b/torchvision/prototype/datasets/_builtin/eurosat.py index fdbba077669..c593f74d0cc 100644 --- a/torchvision/prototype/datasets/_builtin/eurosat.py +++ b/torchvision/prototype/datasets/_builtin/eurosat.py @@ -35,6 +35,7 @@ def resources(self, config: DatasetConfig) -> List[OnlineResource]: def _prepare_sample(self, data: Tuple[str, Any]) -> Dict[str, Any]: path, buffer = data + print(path) category = pathlib.Path(path).parent.name return dict( label=Label.from_category(category, categories=self.categories), From 6847414740041c4655f94437152b7b518b2e7389 Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Fri, 4 Mar 2022 09:26:11 +0100 Subject: [PATCH 3/5] fix eurosat mock data setup --- test/builtin_dataset_mocks.py | 12 ++++++------ test/test_prototype_builtin_datasets.py | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/builtin_dataset_mocks.py b/test/builtin_dataset_mocks.py index 94305952568..561e61ab1ed 100644 --- a/test/builtin_dataset_mocks.py +++ b/test/builtin_dataset_mocks.py @@ -1329,20 +1329,20 @@ def cub200(info, root, config): @register_mock def eurosat(info, root, config): - data_folder = pathlib.Path(root, "eurosat", "2750") + data_folder = pathlib.Path(root, "2750") data_folder.mkdir(parents=True) num_examples_per_class = 3 - classes = ("AnnualCrop", "Forest") - for cls in classes: + categories = ["AnnualCrop", "Forest"] + for category in categories: create_image_folder( root=data_folder, - name=cls, - file_name_fn=lambda idx: f"{cls}_{idx}.jpg", + name=category, + file_name_fn=lambda idx: f"{category}_{idx + 1}.jpg", num_examples=num_examples_per_class, ) make_zip(root, "EuroSAT.zip", data_folder) - return len(classes) * num_examples_per_class + return len(categories) * num_examples_per_class @register_mock diff --git a/test/test_prototype_builtin_datasets.py b/test/test_prototype_builtin_datasets.py index eaa92094ad7..de60caa8d44 100644 --- a/test/test_prototype_builtin_datasets.py +++ b/test/test_prototype_builtin_datasets.py @@ -52,6 +52,8 @@ def test_sample(self, test_home, dataset_mock, config): try: sample = next(iter(dataset)) + except StopIteration: + raise AssertionError("Unable to draw any sample.") from None except Exception as error: raise AssertionError("Drawing a sample raised the error above.") from error From 3b9b6e9a7710188cc3e150de2db9ad4a850df8a0 Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Fri, 4 Mar 2022 09:39:41 +0100 Subject: [PATCH 4/5] revert changes --- .circleci/config.yml | 6 ++++-- torchvision/prototype/datasets/_builtin/eurosat.py | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e6786f7f964..b616f3bde93 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -335,7 +335,9 @@ jobs: file_or_dir: test/test_onnx.py unittest_prototype: - executor: windows-cpu + docker: + - image: circleci/python:3.7 + resource_class: xlarge steps: - checkout - run: @@ -355,7 +357,7 @@ jobs: name: Enable prototype tests command: echo 'export PYTORCH_TEST_WITH_PROTOTYPE=1' >> $BASH_ENV - run_tests_selective: - file_or_dir: test/test_prototype_builtin_datasets.py::TestCommon -k eurosat + file_or_dir: test/test_prototype_*.py binary_linux_wheel: <<: *binary_common diff --git a/torchvision/prototype/datasets/_builtin/eurosat.py b/torchvision/prototype/datasets/_builtin/eurosat.py index c593f74d0cc..fdbba077669 100644 --- a/torchvision/prototype/datasets/_builtin/eurosat.py +++ b/torchvision/prototype/datasets/_builtin/eurosat.py @@ -35,7 +35,6 @@ def resources(self, config: DatasetConfig) -> List[OnlineResource]: def _prepare_sample(self, data: Tuple[str, Any]) -> Dict[str, Any]: path, buffer = data - print(path) category = pathlib.Path(path).parent.name return dict( label=Label.from_category(category, categories=self.categories), From 5d427fe4bcb51986576e1f9a32addb4e8f6453f4 Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Fri, 4 Mar 2022 10:09:13 +0100 Subject: [PATCH 5/5] minor cleanup --- test/builtin_dataset_mocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/builtin_dataset_mocks.py b/test/builtin_dataset_mocks.py index 561e61ab1ed..48c8f4d3b7f 100644 --- a/test/builtin_dataset_mocks.py +++ b/test/builtin_dataset_mocks.py @@ -1329,7 +1329,7 @@ def cub200(info, root, config): @register_mock def eurosat(info, root, config): - data_folder = pathlib.Path(root, "2750") + data_folder = root / "2750" data_folder.mkdir(parents=True) num_examples_per_class = 3