Skip to content

Commit

Permalink
Merge pull request #47 from Helsinki-NLP/fix/explicit-task-req
Browse files Browse the repository at this point in the history
Making task id explicitly required for translation
  • Loading branch information
TimotheeMickus authored Jan 22, 2024
2 parents b281b59 + fa4ef73 commit dfbe9ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mammoth/opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ def translate_opts(parser, dynamic=False):
"Necessary for models whose output layers can assign "
"zero probability.",
)
group.add('--task_id', '-task_id', help="Task id to determine components to load for translation")
group.add('--task_id', '-task_id', help="Task id to determine components to load for translation", required=True)

group = parser.add_argument_group('Data')
group.add('--data_type', '-data_type', default="text", help="Type of the source input. Options: [text].")
Expand Down
11 changes: 7 additions & 4 deletions mammoth/tests/test_translation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ def test_detokenizing_with_no_tokenizer_fails(self):

if torch.cuda.is_available():

@unittest.skip('Broken in FoTraNMT') # FIXME
def test_moving_to_gpu_and_back(self):
torch.cuda.set_device(torch.device("cuda", 0))
model_id = 0
opts = {"models": ["test_model.pt"]}
opts = {"models": ["test_model.pt"], 'task_id': None}
model_root = TEST_DIR
sm = ServerModel(opts, model_id, model_root=model_root, load=True)
for p in sm.translator.model.parameters():
Expand All @@ -73,10 +74,11 @@ def test_moving_to_gpu_and_back(self):
for p in sm.translator.model.parameters():
self.assertEqual(p.device.type, "cpu")

@unittest.skip('Broken in FoTraNMT') # FIXME
def test_initialize_on_gpu_and_move_back(self):
torch.cuda.set_device(torch.device("cuda", 0))
model_id = 0
opts = {"models": ["test_model.pt"], "gpu": 0}
opts = {"models": ["test_model.pt"], "gpu": 0, 'task_id': None}
model_root = TEST_DIR
sm = ServerModel(opts, model_id, model_root=model_root, load=True)
for p in sm.translator.model.parameters():
Expand Down Expand Up @@ -170,6 +172,7 @@ def write(self, cfg):
% TEST_DIR
)

@unittest.skip('Broken in MAMMOTH') # FIXME
def test_start_without_initial_loading(self):
self.write(self.CFG_NO_LOAD)
sv = TranslationServer()
Expand Down Expand Up @@ -198,7 +201,7 @@ def test_start_without_initial_loading(self):
% TEST_DIR
)

@unittest.skip('Broken in FoTraNMT') # FIXME
@unittest.skip('Broken in MAMMOTH') # FIXME
def test_start_with_initial_loading(self):
self.write(self.CFG_LOAD)
sv = TranslationServer()
Expand Down Expand Up @@ -237,7 +240,7 @@ def test_start_with_initial_loading(self):
% TEST_DIR
)

@unittest.skip('Broken in FoTraNMT') # FIXME
@unittest.skip('Broken in MAMMOTH') # FIXME
def test_start_with_two_models(self):
self.write(self.CFG_2_MODELS)
sv = TranslationServer()
Expand Down

0 comments on commit dfbe9ef

Please sign in to comment.