Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
[fbcode] Add support for PathManager in vacuum (#3635)
Browse files Browse the repository at this point in the history
* [fbcode] Add support for PathManager in vacuum

* Move requirements to iopath.
  • Loading branch information
stephenroller authored Apr 30, 2021
1 parent b5c2eb0 commit 2bb3f72
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions parlai/scripts/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Assumes we are working with a TorchAgent
"""

import os
import torch

from parlai.core.params import ParlaiParser
Expand Down Expand Up @@ -46,7 +45,7 @@ def run(self):
model_file = self.opt['path']
if not model_file:
raise RuntimeError('--model-file argument is required')
if not os.path.isfile(model_file):
if not PathManager.isfile(model_file):
raise RuntimeError(f"'{model_file}' does not exist")
logging.info(f"Loading {model_file}")
with PathManager.open(model_file, 'rb') as f:
Expand All @@ -55,7 +54,7 @@ def run(self):
)
if not self.opt['no_backup']:
logging.info(f"Backing up {model_file} to {model_file}.unvacuumed")
os.rename(model_file, model_file + ".unvacuumed")
PathManager.mv(model_file, model_file + ".unvacuumed")
for key in [
'optimizer',
'optimizer_type',
Expand Down
4 changes: 2 additions & 2 deletions parlai/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from fvcore.common.file_io import PathManagerBase as _PathManager
except ImportError:
raise ImportError(
"parlai now requires fvcore for some I/O operations. Please run "
"`pip install fvcore==0.1.1.post20200716`"
"parlai now requires iopath for some I/O operations. Please run "
"`pip install iopath`"
)

USE_ATOMIC_TORCH_SAVE = True
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ emoji==0.5.4
docformatter==1.3.0
flake8-bugbear==19.8.0
flake8==3.7.8
fvcore==0.1.1.post20200716
iopath~=0.1.8
gitdb2==2.0.5
GitPython==3.0.3
hydra-core~=1.0.6
Expand Down

0 comments on commit 2bb3f72

Please sign in to comment.