简体   繁体   English

获取笔记本的详细实时报告/监控

[英]Get verbose real time reporting/monitoring of notebook

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.例如,我的一个函数有一个睡眠周期为 5 秒的循环,我希望看到程序实际上正在睡眠并且循环的其他步骤正在执行。

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.我一直在努力寻找如何做到这一点,我只能找到获得需要触发错误的事后调试报告的方法。

You might want to consider the trace module, which has a programmatic interface.您可能需要考虑具有编程接口的trace模块。

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 .想到的其他选项是tqdm (简单进度条),或者这个答案中列出的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM