Skip to content

Commit

Permalink
[!157][SIMULTANEOUS] Add option for load_model_vocab to use user_dir
Browse files Browse the repository at this point in the history
# Why is the change needed?
If the `user_dir` is set in the model config, we cannot currently change it with the `--user-dir` argument.

# What changes does the patch introduce?
Replace the `user_dir` defined by the model with the `--user-dir` argument if this is set by command line.

# How was this patch tested?
Manual run
  • Loading branch information
sarapapi authored and mgaido91 committed Jun 17, 2024
1 parent fc2c11b commit d567765
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def add_args(parser):
help="Subword splitter type for target text")
parser.add_argument("--tgt-splitter-path", type=str, default=None,
help="Subword splitter model path for target text")
parser.add_argument("--user-dir", type=str, default="examples/simultaneous_translation",
parser.add_argument("--user-dir", type=str, default=None,
help="User directory for simultaneous translation")
parser.add_argument("--max-len", type=int, default=200,
help="Max length of translation")
Expand Down Expand Up @@ -130,7 +130,10 @@ def load_model_vocab(self):
if self.args.config is not None:
task_args.config_yaml = self.args.config

import_user_module(state["cfg"].common)
if self.args.user_dir is not None:
import_user_module(self.args.user_dir)
else:
import_user_module(state["cfg"].common)

self.task = tasks.setup_task(task_args)

Expand Down

0 comments on commit d567765

Please sign in to comment.