[GitHub] [airflow] jmcarp commented on a change in pull request #4828: [AIRFLOW-4002] Optionally open debugger on errors in airflow test.

2019-03-05 Thread GitBox
jmcarp commented on a change in pull request #4828: [AIRFLOW-4002] Optionally 
open debugger on errors in airflow test.
URL: https://github.com/apache/airflow/pull/4828#discussion_r262790267
 
 

 ##
 File path: airflow/bin/cli.py
 ##
 @@ -2032,6 +2047,11 @@ class CLIFactory(object):
 'task_params': Arg(
 ("-tp", "--task_params"),
 help="Sends a JSON params dict to the task"),
+'post_mortem': Arg(
+("-pm", "--post_mortem"),
+action="store_true",
 
 Review comment:
   In argparse, store_true sets the default to false, so I think this is 
correct.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [airflow] jmcarp commented on a change in pull request #4828: [AIRFLOW-4002] Optionally open debugger on errors in airflow test.

2019-03-05 Thread GitBox
jmcarp commented on a change in pull request #4828: [AIRFLOW-4002] Optionally 
open debugger on errors in airflow test.
URL: https://github.com/apache/airflow/pull/4828#discussion_r262790183
 
 

 ##
 File path: airflow/bin/cli.py
 ##
 @@ -686,10 +687,24 @@ def test(args, dag=None):
 task.params.update(passed_in_params)
 ti = TaskInstance(task, args.execution_date)
 
-if args.dry_run:
-ti.dry_run()
-else:
-ti.run(ignore_task_deps=True, ignore_ti_state=True, test_mode=True)
+try:
+if args.dry_run:
+ti.dry_run()
+else:
+ti.run(ignore_task_deps=True, ignore_ti_state=True, test_mode=True)
+except Exception:
+if args.post_mortem:
+debugger = get_debugger()
+debugger.post_mortem()
+else:
+raise
+
+
+def get_debugger():
+try:
+return importlib.import_module("ipdb")
+except ImportError:
+return importlib.import_module("pdb")
 
 Review comment:
   Agreed, I factored this back into the `test` function.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services