Re-raise exception to debugger, if using
-'''Train a multi-task model using AllenNLP '''
+'''Train a multi-task model using AllenNLP
+
+To debug this, run with -m ipdb:
+
+ python -m ipdb main.py --config_file ...
+'''
# pylint: disable=no-member
import argparse
import glob
@@ -115,14 +120,6 @@ def main(cl_arguments):
log.warning(
"GPU access failed. You might be using a CPU-only installation of PyTorch. Falling back to CPU.")
args.cuda = -1
- if args.debug:
- log.info("Debugging is ON; we're importing pdb!")
- try:
- pass
- #import ipdb as pdb
- except ImportError:
- pass
- #import pdb
# Prepare data #
log.info("Loading tasks...")
@@ -258,8 +255,9 @@ def main(cl_arguments):
if __name__ == '__main__':
try:
main(sys.argv[1:])
- except BaseException:
+ except BaseException as e:
# Make sure we log the trace for any crashes before exiting.
log.exception("Fatal error in main():")
+ raise e # re-raise exception, in case debugger is attached.
sys.exit(1)
sys.exit(0)
