diff --git a/allennlp/commands/__init__.py b/allennlp/commands/__init__.py index e4f067c620d..164a7258cb6 100644 --- a/allennlp/commands/__init__.py +++ b/allennlp/commands/__init__.py @@ -53,14 +53,13 @@ def main(prog: str = None, args = parser.parse_args() - # Import any additional modules needed (to register custom classes). - for package_name in args.include_package: - import_submodules(package_name) - # If a subparser is triggered, it adds its work as `args.func`. # So if no such attribute has been added, no subparser was triggered, # so give the user some help. if 'func' in dir(args): + # Import any additional modules needed (to register custom classes). + for package_name in args.include_package: + import_submodules(package_name) args.func(args) else: parser.print_help()