Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Megatron-LM
Commits
5a1aa663
Commit
5a1aa663
authored
Mar 11, 2022
by
Jared Casper
Browse files
Proper exit when we can't load a plugin.
parent
58cca6e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
tools/checkpoint_util.py
tools/checkpoint_util.py
+3
-4
No files found.
tools/checkpoint_util.py
View file @
5a1aa663
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment