Skip to content

Commit

Permalink
make dir at start of dict.save (facebookresearch#3250)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerp authored Nov 5, 2020
1 parent ba6349c commit 3a908bc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion parlai/core/dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ def save(self, filename=None, append=False, sort=True):
If ``sort`` (default ``True``), then first sort the dictionary before saving.
"""
filename = self.opt['dict_file'] if filename is None else filename
make_dir(os.path.dirname(filename))

if self.tokenizer in ['bpe', 'gpt2', 'bytelevelbpe', 'slow_bytelevel_bpe']:
needs_removal = self.bpe.finalize(
Expand All @@ -643,7 +644,6 @@ def save(self, filename=None, append=False, sort=True):

logging.info(f'Saving dictionary to {filename}')

make_dir(os.path.dirname(filename))
mode = 'a' if append else 'w'
with PathManager.open(filename, mode, encoding='utf-8') as write:
for i in self.ind2tok.keys():
Expand Down

0 comments on commit 3a908bc

Please sign in to comment.