Skip to content

Commit

Permalink
Merge pull request #29 from Helsinki-NLP/fix/xenargophobic
Browse files Browse the repository at this point in the history
Halt and catch fire with unknown args as a default
  • Loading branch information
TimotheeMickus authored Oct 2, 2023
2 parents 9a25940 + e5e3534 commit 9232208
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mammoth/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
mammoth.opts._add_train_general_opts(parser)

# -data option is required, but not used in this test, so dummy.
opts = parser.parse_known_args(['-tasks', 'dummy', '-node_rank', '0', '-model_dim', '500'])[0]
opts = parser.parse_known_args(['-tasks', 'dummy', '-node_rank', '0', '-model_dim', '500'], strict=False)[0]


class TestModel(unittest.TestCase):
Expand Down
6 changes: 6 additions & 0 deletions mammoth/utils/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ def defaults(cls, *args):
defaults = dummy_parser.parse_known_args([])[0]
return defaults

def parse_known_args(self, *args, strict=True, **kwargs):
opts, unknown = super().parse_known_args(*args, **kwargs)
if strict and unknown:
raise ValueError(f'unknown arguments provided:\n{unknown}')
return opts, unknown

@classmethod
def update_model_opts(cls, model_opts):
cls._validate_adapters(model_opts)
Expand Down

0 comments on commit 9232208

Please sign in to comment.