Jupyter 日志控制修正
notebook.fix_logging
在 Jupyter 笔记本中采用惯用方式来控制日志记录。
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-02
- Stars
- ★ 155
- Forks
- 170
01 前言 Front Matter
- model
- haiku
- description
- Use idiom for controlling logging in Jupyter notebooks
03 SKILL.md 正文
Goal
-
Implement the instructions in
.claude/skills/notebook.rules.mdunder## Use Standard Template Structure -
Use the structure from
.claude/templates/notebook.template.pyfor consistent notebook initialization -
Use
display -
In the local utility
*_utils.pythere should be a function likeimport helpers.hnotebook as hnotebo def init_loggers(notebook_log: logging.Logger) -> None: """ Wire the notebook logger into the utils logger. :param notebook_log: logger owned by the notebook """ hnotebo.init_loggers(notebook_log, utils_log=_LOG)hnotebo.init_loggers()already callsconfig_notebook(), initializeshdbgat INFO level, and redirects the notebook and utils loggers to print- If the notebook needs a third-party logger (e.g.,
causalml), redirect it insideinit_loggers()withhnotebo.set_logger_to_print():hnotebo.set_logger_to_print(logging.getLogger("causalml"))
-
In the notebook, the last setup cell calls
utils.init_loggers(_LOG)instead oflogging.basicConfig()orhdbg.init_logger()
Workflow
Sync Notebook
- At the end, sync the paired
.pyfile with Jupytext following the conventions in# Code Architecture and Responsibility->## Utilities vs. Notebook Responsibilitiesin.claude/skills/notebook.rules.md
Conventions
- Always follow the conventions and guidelines in
.claude/skills/notebook.rules.md
Verification
- [ ] Confirm the notebook init cell matches
.claude/templates/notebook.template.py - [ ] Confirm
utils.init_loggers()is called and log messages print in the notebook - [ ] Confirm the
.ipynband paired.pyfile are in sync via Jupytext
04 同仓库更多 Skills
Docker 文件同步与模板对齐
tutorial_in_60_mins.propagate_docker_changes
同步教程和课程项目的 Docker 文件,使其与 project_template 保持一致。
Markdown 合并至 Jupyter Notebook
tutorial_in_60_mins.merge_markdown
将 Markdown 文件的内容合并到 Jupyter Notebook 中。
60 分钟教程格式规范化
tutorial_in_60_mins.format
格式化目录,使其遵循「Learn X in 60 Minutes」(60 分钟学会 X)教程约定。
60 分钟教程目录创建
tutorial_in_60_mins.create
按照「Learn X in 60 Minutes」(60 分钟学会 X)约定创建教程目录。
todo.reorg_in_progress
Reorganize ai_task_queue.md so in-progress tasks, not-started tasks, and mislabeled topic headers sit under the right H1 stage
todo.reorg_headers
Reorganize ai_task_queue.md .md so every H2 topic matches ALL TOPICS and every H3 task sits under the right topic, keeping its H1 stage