Skip to content

Commit

Permalink
suppress errors in vision/fair/fvcore
Browse files Browse the repository at this point in the history
Differential Revision: D47643174

fbshipit-source-id: e56e41f77d2e2558038c1935907fcfa299c2d8db
  • Loading branch information
generatedunixname89002005307016 authored and facebook-github-bot committed Jul 20, 2023
1 parent d817f01 commit b905b9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions fvcore/common/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def save(self, name: str, **kwargs: Any) -> None:
assert os.path.basename(save_file) == basename, basename
self.logger.info("Saving checkpoint to {}".format(save_file))
with self.path_manager.open(save_file, "wb") as f:
# pyre-fixme[22]: The cast is redundant.
torch.save(data, cast(IO[bytes], f))
self.tag_last_checkpoint(basename)

Expand Down Expand Up @@ -186,8 +187,6 @@ def get_checkpoint_file(self) -> str:
# if file doesn't exist, maybe because it has just been
# deleted by a separate process
return ""
# pyre-fixme[6]: For 2nd argument expected `Union[PathLike[str], str]` but
# got `Union[bytes, str]`.
return os.path.join(self.save_dir, last_saved)

def get_all_checkpoint_files(self) -> List[str]:
Expand Down Expand Up @@ -234,7 +233,7 @@ def tag_last_checkpoint(self, last_filename_basename: str) -> None:
"""
save_file = os.path.join(self.save_dir, "last_checkpoint")
with self.path_manager.open(save_file, "w") as f:
f.write(last_filename_basename) # pyre-ignore
f.write(last_filename_basename)

def _load_file(self, f: str) -> Dict[str, Any]:
"""
Expand All @@ -249,6 +248,7 @@ def _load_file(self, f: str) -> Dict[str, Any]:
to torch.Tensor or numpy arrays.
"""
with self.path_manager.open(f, "rb") as file:
# pyre-fixme[22]: The cast is redundant.
return torch.load(cast(IO[bytes], file), map_location=torch.device("cpu"))

def _load_model(self, checkpoint: Any) -> _IncompatibleKeys:
Expand Down
2 changes: 1 addition & 1 deletion io_tests/test_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def test_open_writes(self) -> None:
# HTTPURLHandler does not support writing, only reading.
with self.assertRaises(AssertionError):
with PathManager.open(self._remote_uri, "w") as f:
f.write("foobar") # pyre-ignore
f.write("foobar")

def test_bad_args(self) -> None:
with self.assertRaises(NotImplementedError):
Expand Down

0 comments on commit b905b9b

Please sign in to comment.