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

标签 python jupyter-notebook reporting

我想尽可能详细地报告我的笔记本的执行情况。简而言之,我想实时查看我的笔记本正在执行的每个操作。例如,我的一个函数有一个 sleep 周期为 5 秒的循环,我希望看到程序实际上正在 sleep 并且循环的其他步骤正在执行。
我一直在努力寻找如何做到这一点,我只能找到获得需要触发错误的事后调试报告的方法。

最佳答案

您可能需要考虑 trace 模块,它有一个编程接口(interface)。
例子:

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=".")
想到的其他选项是 tqdm (简单的进度条),或this answer 中列出的内容.

关于python - 获取笔记本的详细实时报告/监控,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66650617/

相关文章:

python - 我想找到一个数字中数字的平方和,我的代码对于正数工作正常,但似乎不适用于负数

python - 如何使用 Python 和 Google 日历 API 创建 Google 日历事件

sql-server - Azure Data Studio 不记得或保留连接

python - 为什么 LogLocator 每 2 个十年只给我一次刻度?

mysql - 经常性的数据需求——自动查询,还是直接在SQL中存储数据?

javascript - [Python][Javascript] 无法弄清楚如何将 API 调用从 NEXTjs 网页 GUI 发送到 Python Falcon 后端

python :TypeError: this constructor takes no arguments

jupyter-notebook - 将 Jupyter Lab 中的笔记本导出为 PDF 时隐藏所有代码

sql-server - Reporting Services 2008 : Is there a way to change item properties, 取决于报告的呈现方式?

user-interface - 除以零显示值