Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable numba debug logging when DEBUG env variable is set?

I have a lot of numba compiled functions and classes in my code. For the sake of testing I have to run my program like this:

DEBUG=True python3 main.py

But when I start my program like this, numba prints tons of debug messages to stderr. These messages look like this:

2020-02-05 16:28:30,886 - numba.interpreter - DEBUG - label 0:
__numba_self_ = arg(0, name=__numba_self_) ['__numba_self_']
args = arg(1, name=args)                 ['args']
$4load_attr.1 = getattr(value=__numba_self_, attr=find) ['$4load_attr.1', '__numba_self_']
$8call_function_ex.3 = call $4load_attr.1(*args, func=$4load_attr.1, args=[], kws=[], vararg=args) ['$4load_attr.1', '$8call_function_ex.3', 'args']
$10return_value.4 = cast(value=$8call_function_ex.3) ['$10return_value.4', '$8call_function_ex.3']
return $10return_value.4                 ['$10return_value.4']

How can I disable this output, without unsetting DEBUG environment variable?

like image 541
Dimitrius Avatar asked Jan 01 '23 07:01

Dimitrius


1 Answers

import logging

numba_logger = logging.getLogger('numba')
numba_logger.setLevel(logging.WARNING)

will do the job. Just call at the beginning of your script!

like image 54
Daniel Paysan Avatar answered Jan 02 '23 21:01

Daniel Paysan