-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xdoctest project #33
Xdoctest project #33
Conversation
✅ Deploy Preview for pfccblog ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
src/posts/xdoctest-project.md
Outdated
|
||
## 01 - 关于任务 | ||
|
||
`Python`源代码与官方文档中的`Example`,也就是示例代码,是学习与使用 Paddle 框架非常重要的学习与参考依据。赛题要求将 xdoctest 引入到飞桨框架的工作流中,利用 xdoctest 来自动检查示例代码运行正确,且与输出结果匹配,以确保示例代码输出的一致性,进一步提高飞桨框架示例代码的质量。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`Python`源代码与官方文档中的`Example`,也就是示例代码,是学习与使用 Paddle 框架非常重要的学习与参考依据。赛题要求将 xdoctest 引入到飞桨框架的工作流中,利用 xdoctest 来自动检查示例代码运行正确,且与输出结果匹配,以确保示例代码输出的一致性,进一步提高飞桨框架示例代码的质量。 | |
Python 源代码与官方文档中的 Example,也就是示例代码,是学习与使用 Paddle 框架非常重要的学习与参考依据。赛题要求将 xdoctest 引入到飞桨框架的工作流中,利用 xdoctest 来自动检查示例代码运行正确,且与输出结果匹配,以确保示例代码输出的一致性,进一步提高飞桨框架示例代码的质量。 |
这段稍后我改写下
src/posts/xdoctest-project.md
Outdated
|
||
### >>> print(solutions) 都有哪些现成的解决方案? | ||
|
||
[xdoctest](https://xdoctest.readthedocs.io/en/latest/) 是一个示例代码自动执行和检查工具,可以自动执行 Python docstring 中的示例代码,并对示例代码输出进行检查。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
图里说了 doctest,但这里并没有提及
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doctest 还是要提一下的,尤其要提一下 xdoctest 对比 doctest 的优势。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以参考 xdoctest 文档里面的描述:
The xdoctest package is a re-write of Python’s builtin doctest module. It replaces the old regex-based parser with a new abstract-syntax-tree based parser (using Python’s ast module). The goal is to make doctests easier to write, simpler to configure, and encourage the pattern of test driven development.
src/posts/xdoctest-project.md
Outdated
|
||
### >>> print(solutions) 都有哪些现成的解决方案? | ||
|
||
[xdoctest](https://xdoctest.readthedocs.io/en/latest/) 是一个示例代码自动执行和检查工具,可以自动执行 Python docstring 中的示例代码,并对示例代码输出进行检查。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doctest 还是要提一下的,尤其要提一下 xdoctest 对比 doctest 的优势。
src/posts/xdoctest-project.md
Outdated
- Paddle 代码和 docs 都有代码检查逻辑。 | ||
- 代码检查逻辑还不尽相同。 | ||
- Paddle 与 PyTorch 很多实现方式不一样。 | ||
- PyTorch 的检查方式并不完整。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pytorch/pytorch#82797
这个PR,当时调研看过吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pytorch/pytorch#82797 这个PR,当时调研看过吗?
没有 ... ... 当时对于 pytorch 的调研主要在文档和代码本身:
- pytorch 的 xdoctest 检查逻辑与脚本
- pytorch 的 xdoctest 实际检查结果
- pytorch 中示例代码对于 xdoctest 的使用,如 skip 指令等
当时确实没有想到在 pr 和 issue 上调研,如果能够更多了解当时 pytorch 对于 xdoctest 引入的前因后果,后面应该可以少走一些弯路 ~~~
回到这个 PR 本身,主要干了几件事:
- 修改示例中错误的格式
- 添加 skip 指令
- 处理渲染问题
以及提到了 global state 对于测试的影响。
这里对于示例的检查还是相对宽松的,比如随机数、global 影响等,基本是 skip 或者 ignore want 处理。
我们在引入 xdoctest 的时候尽量使用固定 seed 或者开进程的方式解决掉上述问题,让检查能够进行。
src/posts/xdoctest-project.md
Outdated
|
||
### >>> print(solutions) 都有哪些现成的解决方案? | ||
|
||
[xdoctest](https://xdoctest.readthedocs.io/en/latest/) 是一个示例代码自动执行和检查工具,可以自动执行 Python docstring 中的示例代码,并对示例代码输出进行检查。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以参考 xdoctest 文档里面的描述:
The xdoctest package is a re-write of Python’s builtin doctest module. It replaces the old regex-based parser with a new abstract-syntax-tree based parser (using Python’s ast module). The goal is to make doctests easier to write, simpler to configure, and encourage the pattern of test driven development.
<div style="display: flex; justify-content: center"> | ||
<figure style="width: 60%;"> | ||
<img src="../images/xdoctest-project/xdoctest-5.jpg"/> | ||
<figcaption>项目 milestones</figcaption> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Story~ 🥂
xdoctest 的结项 blog.