Skip to content

Provide a more error-locating-friendly companion to nbdev_export:nbscholar_check(along with nbscholar_export) nbscholar_check:一个更易定位错误的 nbdev_export 伴侣 #1538

@2catycm

Description

@2catycm

Summary

  • When nbdev_export fails, it’s hard to pinpoint which .ipynb and line caused the error.
  • nbdev_export 报错时,往往难以快速定位到底是哪个 .ipynb、哪一行出错。

What Is It

  • nbscholar_check performs strict Python AST checks per notebook and prints VSCode-clickable errors (/abs/path.ipynb:line:column: SyntaxError: ...).
  • nbscholar_export acts as a drop-in companion to nbdev_export: on failure, it guides you to run nbscholar_check for fast pinpointing.
  • nbscholar_check 对每个笔记本进行严格的 Python AST 校验,并以 VSCode 可点击格式输出错误(/abs/path.ipynb:line:column: SyntaxError: ...)。
  • nbscholar_exportnbdev_export 的伴侣:失败时提示使用 nbscholar_check 快速定位问题。

Why It Helps

  • Export cells are enforced with strict AST (cells starting with #| export / #| exporti); non-export cells tolerate common IPython syntax (%%, %, ?/??) to avoid false positives.
  • Errors show as clickable links in VSCode’s terminal, taking you directly to the file, line, and column.
  • 对导出单元(以 #| export / #| exporti 开头)严格 AST;普通单元兼容 IPython 常见语法,减少误报。
  • VSCode 终端中以可点击链接展示错误,直达文件、行列位置,定位更高效。

Quick Start

  • Install
pip install git+https://github.com/THU-CVML/ScholarlyInfrastructure.git
  • Check a file or directory
nbscholar_check .
  • Export companion (same usage as nbdev_export)
nbscholar_export
  • 安装
pip install git+https://github.com/THU-CVML/ScholarlyInfrastructure.git
  • 检查单个文件或整目录
nbscholar_check .
  • 作为导出伴侣(与 nbdev_export 用法一致)
nbscholar_export

Example Output

  • /absolute/path/to/notebooks/03_nbscholar (nbdev extensions).ipynb:123:7: SyntaxError: invalid syntax (cell 5)
  • 点击该链接即可在 VSCode 中打开对应 .ipynb 并跳到相应行列。
  • 在 VSCode 终端中点击即可直达错误位置与上下文。

Call To Action

  • Try nbscholar_check / nbscholar_export and share feedback: https://github.com/THU-CVML/ScholarlyInfrastructure.git
  • If this improves your export and debugging workflow, please give us a Star!
  • 欢迎试用并反馈:https://github.com/THU-CVML/ScholarlyInfrastructure.git
  • 如果觉得好用,欢迎点 Star 支持我们!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions