Skip to content

Commit 2b33696

Browse files
lezwonpmeier
andauthored
Apply suggestions from code review
Co-authored-by: Philip Meier <[email protected]>
1 parent 4838443 commit 2b33696

File tree

1 file changed

+9
-9
lines changed
  • torchvision/prototype/datasets/_builtin

1 file changed

+9
-9
lines changed

torchvision/prototype/datasets/_builtin/sbu.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ def _preprocess(self, path: pathlib.Path) -> pathlib.Path:
4040
except Exception:
4141
broken_urls.append(url)
4242

43-
if broken_urls:
44-
print(f"Failed to download {len(broken_urls)} images")
45-
self._write_broken_urls_to_file(broken_urls, data_folder)
46-
47-
return data_folder
43+
if broken_urls:
44+
broken_urls_file = folder.parent / "broken_urls.txt"
45+
warnings.warn(
46+
f"Failed to download {len(broken_urls)} ({len(broken_urls) / len(urls):.2%}) images. "
47+
f"They are logged in {broken_urls_file}."
48+
)
49+
with open(broken_urls_file, "w") as fh:
50+
fh.write("\n".join(broken_urls) + "\n")
4851

49-
def _write_broken_urls_to_file(self, broken_urls: List, data_folder: pathlib.Path) -> None:
50-
with open(data_folder / "missing.txt", "w") as fh:
51-
fh.write("\n".join(broken_urls))
52-
print("Missing images are logged at:", data_folder / "missing.txt")
52+
return folder
5353

5454
def resources(self, config: DatasetConfig) -> List[OnlineResource]:
5555
return [

0 commit comments

Comments
 (0)