diff --git a/histoqc/__main__.py b/histoqc/__main__.py index d86ff7d..02363d8 100644 --- a/histoqc/__main__.py +++ b/histoqc/__main__.py @@ -65,6 +65,7 @@ def main(argv=None): parser.add_argument('--symlink', metavar="TARGET_DIR", help="create symlink to outdir in TARGET_DIR", default=None) + parser.add_argument('--debug', action='store_true', help="trigger debugging behavior") args = parser.parse_args(argv) # --- multiprocessing and logging setup ----------------------------------- @@ -162,10 +163,11 @@ def main(argv=None): 'shared_dict': mpm.dict(), 'num_files': num_files, 'force': args.force, - 'seed': args.seed + 'seed': args.seed, + 'debug': args.debug } failed = mpm.list() - setup_plotting_backend(lm.logger) + setup_plotting_backend(lm.logger, debug=args.debug) try: if args.nprocesses > 1: diff --git a/histoqc/_pipeline.py b/histoqc/_pipeline.py index 5012ce4..66a5922 100644 --- a/histoqc/_pipeline.py +++ b/histoqc/_pipeline.py @@ -188,7 +188,7 @@ def log_pipeline(config, log_manager): # --- worker process helpers ------------------------------------------ -def setup_plotting_backend(logger=None): +def setup_plotting_backend(logger=None, debug=False): """loads the correct matplotlib backend Parameters @@ -197,13 +197,13 @@ def setup_plotting_backend(logger=None): the logging.Logger instance """ import matplotlib - if platform.system() != "Windows" and not os.environ.get('DISPLAY'): - if logger is not None: - logger.info('no display found. Using non-interactive Agg backend') - matplotlib.use('Agg') - else: + + if debug and (platform.system() == "Windows" or os.environ.get('DISPLAY')): matplotlib.use('TkAgg') + else: + matplotlib.use('Agg') + class BatchedResultFile: """BatchedResultFile encapsulates the results writing