Get verbose real time reporting/monitoring of notebook

Viewed 158

I want to get as verbose reporting of the execution of my notebook as possible. To put it simply, I want to see every action my notebook is taking in real time. For example, one of my functions has a loop with a sleep period of five seconds, I'd like to see that the program is actually sleeping and that the other steps of the loop are executing.

I've struggled to find how to do this, I can only find ways to get after-the-fact debug reports which require errors to be triggered.

1 Answers

You might want to consider the trace module, which has a programmatic interface.

Example:

import sys
import trace

# create a Trace object, telling it what to ignore, and whether to
# do tracing or line-counting or both.
tracer = trace.Trace(
    ignoredirs=[sys.prefix, sys.exec_prefix],
    trace=0,
    count=1
)

# run the new command using the given tracer
tracer.run('main()')

# make a report, placing output in the current directory
r = tracer.results()
r.write_results(show_missing=True, coverdir=".")

Other options that come to mind are tqdm (simple progress bar), or what's listed in this answer.

Related