Commit 5a1aa663 authored by Jared Casper's avatar Jared Casper
Browse files

Proper exit when we can't load a plugin.

parent 58cca6e9
...@@ -2,6 +2,7 @@ import argparse ...@@ -2,6 +2,7 @@ import argparse
import importlib import importlib
import torch.multiprocessing as mp import torch.multiprocessing as mp
import os import os
import sys
# A loader is a python file with at least two functions # A loader is a python file with at least two functions
# - add_arguments - takes in a parser and adds any arguments needed # - add_arguments - takes in a parser and adds any arguments needed
...@@ -76,12 +77,10 @@ def load_plugin(plugin_type, name): ...@@ -76,12 +77,10 @@ def load_plugin(plugin_type, name):
try: try:
plugin = importlib.import_module(module_name) plugin = importlib.import_module(module_name)
except ModuleNotFoundError: except ModuleNotFoundError:
print(f"Unable to load {plugin_type} plugin {name}. Exiting.") sys.exit(f"Unable to load {plugin_type} plugin {name}. Exiting.")
exit
if not hasattr(plugin, 'add_arguments'): if not hasattr(plugin, 'add_arguments'):
print(f"{module_name} module is not a plugin. Exiting.") sys.exit(f"{module_name} module is not a plugin. Exiting.")
exit
print(f"Loaded {module_name} as the {plugin_type}.") print(f"Loaded {module_name} as the {plugin_type}.")
return plugin return plugin
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment