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

test code for issue #729 #734

Merged
merged 4 commits into from
Dec 12, 2016
Merged

test code for issue #729 #734

merged 4 commits into from
Dec 12, 2016

Conversation

hohdiy
Copy link
Contributor

@hohdiy hohdiy commented Dec 5, 2016

test code for issue #729

@@ -16,20 +16,23 @@ if [ -z $1 ]; then
do
base_protostr=$protostr/$file
new_protostr=$protostr/$file.unittest
diff $base_protostr $new_protostr -u
diff $base_protostr $new_protostr -u &&
diff $protostr/$file $protostr/$file.non_file_config.unittest -u
done
else
for file in ${configs[*]}
do
if ! $1 $protostr/$file.protostr $protostr/$file.protostr.unittest; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually in this branch, if statement used for check whether is different between $protostr/$file.protostr $protostr/$file.protostr.unittest. The rest diff command just used to show where is the difference.

Copy link
Collaborator

Choose a reason for hiding this comment

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

See #657

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -16,20 +16,23 @@ if [ -z $1 ]; then
do
base_protostr=$protostr/$file
new_protostr=$protostr/$file.unittest
diff $base_protostr $new_protostr -u
diff $base_protostr $new_protostr -u &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

because of set -e is added, && is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

fi
done

for file in ${whole_configs[*]}
do
do
Copy link
Collaborator

Choose a reason for hiding this comment

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

bad indent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok


import sys
import getopt

Copy link
Collaborator

Choose a reason for hiding this comment

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

add

if __name__ == '__main__'

to python code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

After #450 PR, Developing Paddle need use pre-commit tools to check code style, auto-format code, etc. Please try to use pre-commit tool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok


cmdstr = """
from paddle.trainer.config_parser import *
from paddle.trainer_config_helpers import *
Copy link
Collaborator

Choose a reason for hiding this comment

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

This implementation is too tricky. Maybe the simplest implementation is just to write a single file to test parse_config from a python function with a very simple neural network. Although the test-coverage is not full we could test this mechanism work well or not.

@hohdiy
Copy link
Contributor Author

hohdiy commented Dec 7, 2016

  • .//.git/hooks/pre-commit.sample 这个pre-commit tool 有现成可用的吗?给我发一个?
  • 关于diff proto地方,看你是说有一个protobuf_equal程序,是说增加这个程序的执行来检查?
    • 我查看了原有的diff proto是对debug string 进行diff,当有diff时会以diff格式打印出来,应该是满足需求的。
    • 这个地方如果需要用你说的protobuf_equal,不太清楚应该怎么调用(因为那个bin是编译出来的,不是直接可用的)
  • 另外关于我使用生成代码模式对所有已有的config_parser单测过一遍,我感觉是一个一劳永逸的方法,后续只需关注配置文件模式的单测。
    • 我看你的建议是写一个独立的文件只测试一个简单的配置,但是会有单测覆盖的担心。
    • 这个地方我想坚持这种做法,是否ok?

其他点都按照你说的修改。
@reyoung

@reyoung
Copy link
Collaborator

reyoung commented Dec 7, 2016

.//.git/hooks/pre-commit.sample 这个pre-commit tool 有现成可用的吗?给我发一个?

See #450; we use this tool to manage our pre-commit.

关于diff proto地方,看你是说有一个protobuf_equal程序,是说增加这个程序的执行来检查?

不是的。在这个分支中,是if语句在判断两个protofile是不是一致,而不是后面的diff语句。后面的diff语句仅仅是作为错误输出提示用户的。

所以,那个if语句,应该改成类似于 if $1 a.proto a.proto.unittest && $1 a.proto a.proto.by.function

另外关于我使用生成代码模式对所有已有的config_parser单测过一遍,我感觉是一个一劳永逸的方法,后续只需关注配置文件模式的单测

这里有一个问题,是import的东西可能不仅仅是这两个包。用户也可以import numpy之类的第三方包。在那种情况下,这个script就错了。

其实,应该将生成的脚本改成类似于

import paddle.trainer.config_parser as parser

def config():
    # blow here, just copy user configuration file to this method WITH import statements.
    from paddle.trainer.trainer_config_helpers import *
    import numpy
    ....

if __name__ == '__main__':
    print parser.parse_config(config)

@hohdiy
Copy link
Contributor Author

hohdiy commented Dec 8, 2016

已经按照要求进行了修改。
这里需要说明一下,在自动生成代码时,import * 不能放在包含有闭包的函数中,所以我这边将import提到了最外面。对应的单测是:test_rnn_group.py
@reyoung

Copy link
Collaborator

@reyoung reyoung left a comment

Choose a reason for hiding this comment

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

LGTM. THX.

@reyoung reyoung merged commit 56c20f8 into PaddlePaddle:develop Dec 12, 2016
zhhsplendid pushed a commit to zhhsplendid/Paddle that referenced this pull request Sep 25, 2019
fix the kubectl address test=develop
lizexu123 pushed a commit to lizexu123/Paddle that referenced this pull request Feb 23, 2024
WAYKEN-TSE pushed a commit to WAYKEN-TSE/Paddle that referenced this pull request Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants