Skip to content
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][task 293-296] reformat example code with google style in vision #56458

Merged
merged 8 commits into from
Aug 25, 2023

Conversation

ooooo-create
Copy link
Contributor

PR types

Others

PR changes

Others

Description

修改如下文件的示例代码,使其通过 xdoctest 检查:

  • python/paddle/vision/datasets/folder.py
  • python/paddle/vision/datasets/mnist.py
  • python/paddle/vision/datasets/voc2012.py
  • python/paddle/vision/image.py

预览:

Related links

@sunzhongkai588 @SigureMo @megemini

@paddle-bot
Copy link

paddle-bot bot commented Aug 19, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Aug 19, 2023
# <class 'paddle.Tensor'> [3, 281, 500]
print(type(label), label.shape)
# <class 'numpy.ndarray'> (281, 500)
>>> import itertools
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

这个应该是下载数据集超时了,@megemini 是否有方法通过 directive 来修改超时时间呢,比如 # doctest: +TIMEOUT(15)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好问题!简单的说,不行 ~ xdoctest 不支持自定义 directive ~

不过,之前也有想过,目前这个 timeout 不太灵活,如果能指定时间就好了 ~

#56400 这个 PR 里面看看能不能一起搞定吧!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是要添加# doctest: +TIMEOUT()吗

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

暂时还不可以加,等 #56400 合入后 merge 一下才可以,这个 PR 应该近期就可以 merge

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#56400 已 merge,麻烦 merge 下最新的 develop 尝试加上 TIMEOUT directive

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我添加了# doctest: +TIMEOUT(15),是15太短了吗,还是我命令写的有问题,现在失败了,pr-ci-static-check直接暂停了

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

奇怪,我 rerun 下等会再看看

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2023-08-23 13:57:24 ----------------End of the Check--------------------
2023-08-23 13:57:24 7 sample codes ran success
2023-08-23 13:57:24 <DocTest(<modname?> paddle.vision.datasets.DatasetFolder:1:0 ln 1)>
2023-08-23 13:57:24 <DocTest(<modname?> paddle.vision.datasets.FashionMNIST:1:0 ln 1)>
2023-08-23 13:57:24 <DocTest(<modname?> paddle.vision.datasets.ImageFolder:1:0 ln 1)>
2023-08-23 13:57:24 <DocTest(<modname?> paddle.vision.datasets.MNIST:1:0 ln 1)>
2023-08-23 13:57:24 <DocTest(<modname?> paddle.vision.get_image_backend:1:0 ln 1)>
2023-08-23 13:57:24 <DocTest(<modname?> paddle.vision.image_load:1:0 ln 1)>
2023-08-23 13:57:24 <DocTest(<modname?> paddle.vision.set_image_backend:1:0 ln 1)>
2023-08-23 13:57:24 1 sample codes ran timeout
2023-08-23 13:57:24 paddle.vision.datasets.VOC2012:1 - more than 15.0s
2023-08-23 13:57:24 Sample code check is successful!

15秒太短,看日志里面下载没跑完~~~

@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Aug 21, 2023
Copy link
Contributor

@megemini megemini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

示例中有大量的

            >>> for i in range(len(data_folder_1)):
            ...     img, label = data_folder_1[i]
            ...     # do something with img and label
            ...     print(type(img), img.size, label)
            ...     # <class 'PIL.Image.Image'> (32, 32) 0

类似的输出 ~ 我觉得不用改,这样就挺好,不然输出有可能受文件顺序的影响,而且也太繁琐。

@SigureMo 看看怎么搞?

@SigureMo
Copy link
Member

类似的输出 ~ 我觉得不用改,这样就挺好,不然输出有可能受文件顺序的影响,而且也太繁琐。

for 循环的我觉得确实可以不用展开,目的不是对比输出,主要是展示输出是什么(如果没记错当初这些示例代码还是我统一的写法)

Copy link
Contributor

@megemini megemini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ~ 辛苦!

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

@luotao1 luotao1 merged commit 861a16c into PaddlePaddle:develop Aug 25, 2023
@ooooo-create ooooo-create deleted the ooooo/xdoctest293 branch August 31, 2023 10:19
BeingGod pushed a commit to BeingGod/Paddle that referenced this pull request Sep 9, 2023
…vision` (PaddlePaddle#56458)

* [Doctest]fix No.293-296, test=docs_preview

* empty commit

* code style

* empty commit

* fix timeout

* fix timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants