Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
242b91be
提交
242b91be
authored
6月 22, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename file to don't be run by nosetests and pep8
上级
eca8a715
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
40 行增加
和
19 行删除
+40
-19
nose_pr.py
theano/misc/nose_pr.py
+40
-19
没有找到文件。
theano/misc/
test
_pr.py
→
theano/misc/
nose
_pr.py
浏览文件 @
242b91be
...
@@ -21,7 +21,8 @@ import re
...
@@ -21,7 +21,8 @@ import re
import
requests
import
requests
import
shutil
import
shutil
import
time
import
time
from
subprocess
import
call
,
check_call
,
check_output
,
PIPE
,
STDOUT
,
CalledProcessError
from
subprocess
import
(
call
,
check_call
,
check_output
,
PIPE
,
STDOUT
,
CalledProcessError
)
import
sys
import
sys
import
gh_api
import
gh_api
...
@@ -30,12 +31,13 @@ basedir = os.path.join(os.path.expanduser("~"), ".theano_pr_tests")
...
@@ -30,12 +31,13 @@ basedir = os.path.join(os.path.expanduser("~"), ".theano_pr_tests")
repodir
=
os
.
path
.
join
(
basedir
,
"Theano"
)
repodir
=
os
.
path
.
join
(
basedir
,
"Theano"
)
ipy_repository
=
'git://github.com/Theano/Theano.git'
ipy_repository
=
'git://github.com/Theano/Theano.git'
ipy_http_repository
=
'http://github.com/Theano/Theano.git'
ipy_http_repository
=
'http://github.com/Theano/Theano.git'
gh_project
=
"Theano/Theano"
gh_project
=
"Theano/Theano"
supported_pythons
=
[
'python2.6'
,
'python2.7'
,
'python3.1'
,
'python3.2'
]
supported_pythons
=
[
'python2.6'
,
'python2.7'
,
'python3.1'
,
'python3.2'
]
supported_pythons
=
[
'python2.7'
]
supported_pythons
=
[
'python2.7'
]
unavailable_pythons
=
[]
unavailable_pythons
=
[]
def
available_python_versions
():
def
available_python_versions
():
"""Get the executable names of available versions of Python on the system.
"""Get the executable names of available versions of Python on the system.
"""
"""
...
@@ -49,6 +51,7 @@ def available_python_versions():
...
@@ -49,6 +51,7 @@ def available_python_versions():
venvs
=
[]
venvs
=
[]
def
setup
():
def
setup
():
"""Prepare the repository and virtualenvs."""
"""Prepare the repository and virtualenvs."""
global
venvs
global
venvs
...
@@ -64,30 +67,34 @@ def setup():
...
@@ -64,30 +67,34 @@ def setup():
for
venv
in
glob
(
'venv-*'
):
for
venv
in
glob
(
'venv-*'
):
shutil
.
rmtree
(
venv
)
shutil
.
rmtree
(
venv
)
for
py
in
available_python_versions
():
for
py
in
available_python_versions
():
check_call
([
'virtualenv'
,
'-p'
,
py
,
'--system-site-packages'
,
'venv-
%
s'
%
py
])
check_call
([
'virtualenv'
,
'-p'
,
py
,
'--system-site-packages'
,
'venv-
%
s'
%
py
])
venvs
.
append
((
py
,
'venv-
%
s'
%
py
))
venvs
.
append
((
py
,
'venv-
%
s'
%
py
))
# Check out and update the repository
# Check out and update the repository
if
not
os
.
path
.
exists
(
'Theano'
):
if
not
os
.
path
.
exists
(
'Theano'
):
try
:
try
:
check_call
([
'git'
,
'clone'
,
ipy_repository
])
check_call
([
'git'
,
'clone'
,
ipy_repository
])
except
CalledProcessError
:
except
CalledProcessError
:
check_call
([
'git'
,
'clone'
,
ipy_http_repository
])
check_call
([
'git'
,
'clone'
,
ipy_http_repository
])
os
.
chdir
(
repodir
)
os
.
chdir
(
repodir
)
check_call
([
'git'
,
'checkout'
,
'master'
])
check_call
([
'git'
,
'checkout'
,
'master'
])
try
:
try
:
check_call
([
'git'
,
'pull'
,
ipy_repository
,
'master'
])
check_call
([
'git'
,
'pull'
,
ipy_repository
,
'master'
])
except
CalledProcessError
:
except
CalledProcessError
:
check_call
([
'git'
,
'pull'
,
ipy_http_repository
,
'master'
])
check_call
([
'git'
,
'pull'
,
ipy_http_repository
,
'master'
])
os
.
chdir
(
basedir
)
os
.
chdir
(
basedir
)
missing_libs_re
=
re
.
compile
(
r"Tools and libraries NOT available at test time:\n"
missing_libs_re
=
re
.
compile
(
r"Tools and libraries NOT available at test"
r"\s*(.*?)\n"
)
r" time:\n\s*(.*?)\n"
)
def
get_missing_libraries
(
log
):
def
get_missing_libraries
(
log
):
m
=
missing_libs_re
.
search
(
log
)
m
=
missing_libs_re
.
search
(
log
)
if
m
:
if
m
:
return
m
.
group
(
1
)
return
m
.
group
(
1
)
def
get_branch
(
repo
,
branch
,
owner
,
mergeable
):
def
get_branch
(
repo
,
branch
,
owner
,
mergeable
):
os
.
chdir
(
repodir
)
os
.
chdir
(
repodir
)
if
mergeable
:
if
mergeable
:
...
@@ -103,6 +110,7 @@ def get_branch(repo, branch, owner, mergeable):
...
@@ -103,6 +110,7 @@ def get_branch(repo, branch, owner, mergeable):
check_call
([
'git'
,
'checkout'
,
'FETCH_HEAD'
])
check_call
([
'git'
,
'checkout'
,
'FETCH_HEAD'
])
os
.
chdir
(
basedir
)
os
.
chdir
(
basedir
)
def
run_tests
(
venv
):
def
run_tests
(
venv
):
py
=
os
.
path
.
join
(
basedir
,
venv
,
'bin'
,
'python'
)
py
=
os
.
path
.
join
(
basedir
,
venv
,
'bin'
,
'python'
)
print
(
py
)
print
(
py
)
...
@@ -115,9 +123,9 @@ def run_tests(venv):
...
@@ -115,9 +123,9 @@ def run_tests(venv):
# Environment variables:
# Environment variables:
orig_path
=
os
.
environ
[
"PATH"
]
orig_path
=
os
.
environ
[
"PATH"
]
os
.
environ
[
"PATH"
]
=
os
.
path
.
join
(
basedir
,
venv
,
'bin'
)
+
':'
+
os
.
environ
[
"PATH"
]
os
.
environ
[
"PATH"
]
=
os
.
path
.
join
(
basedir
,
venv
,
'bin'
)
+
':'
+
os
.
environ
[
"PATH"
]
os
.
environ
.
pop
(
"PYTHONPATH"
,
None
)
os
.
environ
.
pop
(
"PYTHONPATH"
,
None
)
import
pdb
;
pdb
.
set_trace
()
iptest
=
os
.
path
.
join
(
basedir
,
venv
,
'bin'
,
'theano-test'
)
iptest
=
os
.
path
.
join
(
basedir
,
venv
,
'bin'
,
'theano-test'
)
# if not os.path.exists(iptest):
# if not os.path.exists(iptest):
# iptest = os.path.join(basedir, venv, 'bin', 'iptest3')
# iptest = os.path.join(basedir, venv, 'bin', 'iptest3')
...
@@ -132,6 +140,7 @@ def run_tests(venv):
...
@@ -132,6 +140,7 @@ def run_tests(venv):
# Restore $PATH
# Restore $PATH
os
.
environ
[
"PATH"
]
=
orig_path
os
.
environ
[
"PATH"
]
=
orig_path
def
markdown_format
(
pr
,
results_urls
,
unavailable_pythons
):
def
markdown_format
(
pr
,
results_urls
,
unavailable_pythons
):
def
format_result
(
py
,
passed
,
gist_url
,
missing_libraries
):
def
format_result
(
py
,
passed
,
gist_url
,
missing_libraries
):
s
=
"*
%
s: "
%
py
s
=
"*
%
s: "
%
py
...
@@ -155,16 +164,22 @@ def markdown_format(pr, results_urls, unavailable_pythons):
...
@@ -155,16 +164,22 @@ def markdown_format(pr, results_urls, unavailable_pythons):
"Not available for testing: "
+
", "
.
join
(
unavailable_pythons
)]
"Not available for testing: "
+
", "
.
join
(
unavailable_pythons
)]
return
"
\n
"
.
join
(
lines
)
return
"
\n
"
.
join
(
lines
)
def
post_results_comment
(
pr
,
results
,
num
,
unavailable_pythons
=
unavailable_pythons
):
def
post_results_comment
(
pr
,
results
,
num
,
unavailable_pythons
=
unavailable_pythons
):
body
=
markdown_format
(
pr
,
results
,
unavailable_pythons
)
body
=
markdown_format
(
pr
,
results
,
unavailable_pythons
)
gh_api
.
post_issue_comment
(
gh_project
,
num
,
body
)
gh_api
.
post_issue_comment
(
gh_project
,
num
,
body
)
def
print_results
(
pr
,
results_urls
,
unavailable_pythons
=
unavailable_pythons
):
def
print_results
(
pr
,
results_urls
,
unavailable_pythons
=
unavailable_pythons
):
print
(
"
\n
"
)
print
(
"
\n
"
)
if
pr
[
'mergeable'
]:
if
pr
[
'mergeable'
]:
print
(
"**Test results for commit
%
s merged into master**"
%
pr
[
'head'
][
'sha'
][:
7
])
print
(
"**Test results for commit
%
s merged into master**"
%
pr
[
'head'
][
'sha'
][:
7
])
else
:
else
:
print
(
"**Test results for commit
%
s (can't merge cleanly)**"
%
pr
[
'head'
][
'sha'
][:
7
])
print
(
"**Test results for commit
%
s (can't merge cleanly)**"
%
pr
[
'head'
][
'sha'
][:
7
])
print
(
"Platform:"
,
sys
.
platform
)
print
(
"Platform:"
,
sys
.
platform
)
for
py
,
passed
,
gist_url
,
missing_libraries
in
results_urls
:
for
py
,
passed
,
gist_url
,
missing_libraries
in
results_urls
:
if
passed
:
if
passed
:
...
@@ -176,14 +191,17 @@ def print_results(pr, results_urls, unavailable_pythons=unavailable_pythons):
...
@@ -176,14 +191,17 @@ def print_results(pr, results_urls, unavailable_pythons=unavailable_pythons):
print
(
" Libraries not available:"
,
missing_libraries
)
print
(
" Libraries not available:"
,
missing_libraries
)
print
(
"Not available for testing:"
,
", "
.
join
(
unavailable_pythons
))
print
(
"Not available for testing:"
,
", "
.
join
(
unavailable_pythons
))
def
dump_results
(
num
,
results
,
pr
):
def
dump_results
(
num
,
results
,
pr
):
with
open
(
os
.
path
.
join
(
basedir
,
'lastresults.pkl'
),
'wb'
)
as
f
:
with
open
(
os
.
path
.
join
(
basedir
,
'lastresults.pkl'
),
'wb'
)
as
f
:
pickle
.
dump
((
num
,
results
,
pr
,
unavailable_pythons
),
f
)
pickle
.
dump
((
num
,
results
,
pr
,
unavailable_pythons
),
f
)
def
load_results
():
def
load_results
():
with
open
(
os
.
path
.
join
(
basedir
,
'lastresults.pkl'
),
'rb'
)
as
f
:
with
open
(
os
.
path
.
join
(
basedir
,
'lastresults.pkl'
),
'rb'
)
as
f
:
return
pickle
.
load
(
f
)
return
pickle
.
load
(
f
)
def
save_logs
(
results
,
pr
):
def
save_logs
(
results
,
pr
):
results_paths
=
[]
results_paths
=
[]
for
py
,
passed
,
log
,
missing_libraries
in
results
:
for
py
,
passed
,
log
,
missing_libraries
in
results
:
...
@@ -192,7 +210,7 @@ def save_logs(results, pr):
...
@@ -192,7 +210,7 @@ def save_logs(results, pr):
else
:
else
:
result_locn
=
os
.
path
.
abspath
(
os
.
path
.
join
(
'venv-
%
s'
%
py
,
result_locn
=
os
.
path
.
abspath
(
os
.
path
.
join
(
'venv-
%
s'
%
py
,
pr
[
'head'
][
'sha'
][:
7
]
+
".log"
))
pr
[
'head'
][
'sha'
][:
7
]
+
".log"
))
with
io
.
open
(
result_locn
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
with
io
.
open
(
result_locn
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
log
)
f
.
write
(
log
)
...
@@ -200,6 +218,7 @@ def save_logs(results, pr):
...
@@ -200,6 +218,7 @@ def save_logs(results, pr):
return
results_paths
return
results_paths
def
post_logs
(
results
):
def
post_logs
(
results
):
results_urls
=
[]
results_urls
=
[]
for
py
,
passed
,
log
,
missing_libraries
in
results
:
for
py
,
passed
,
log
,
missing_libraries
in
results
:
...
@@ -212,9 +231,10 @@ def post_logs(results):
...
@@ -212,9 +231,10 @@ def post_logs(results):
return
results_urls
return
results_urls
def
test_pr
(
num
,
post_results
=
True
):
def
test_pr
(
num
,
post_results
=
True
):
# Get Github authorisation first, so that the user is prompted
straight away
# Get Github authorisation first, so that the user is prompted
# if their login is needed.
#
straight away
if their login is needed.
if
post_results
:
if
post_results
:
gh_api
.
get_auth_token
()
gh_api
.
get_auth_token
()
...
@@ -248,13 +268,14 @@ def test_pr(num, post_results=True):
...
@@ -248,13 +268,14 @@ def test_pr(num, post_results=True):
post_results_comment
(
pr
,
results_urls
,
num
)
post_results_comment
(
pr
,
results_urls
,
num
)
print
(
"(Posted to Github)"
)
print
(
"(Posted to Github)"
)
else
:
else
:
post_script
=
os
.
path
.
join
(
os
.
path
.
dirname
(
sys
.
argv
[
0
]),
"post_pr_test.py"
)
post_script
=
os
.
path
.
join
(
os
.
path
.
dirname
(
sys
.
argv
[
0
]),
"post_pr_test.py"
)
print
(
"To post the results to Github, run"
,
post_script
)
print
(
"To post the results to Github, run"
,
post_script
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
argparse
import
argparse
parser
=
argparse
.
ArgumentParser
(
description
=
"Test an
IPython
pull request"
)
parser
=
argparse
.
ArgumentParser
(
description
=
"Test an
Theano
pull request"
)
parser
.
add_argument
(
'-p'
,
'--publish'
,
action
=
'store_true'
,
parser
.
add_argument
(
'-p'
,
'--publish'
,
action
=
'store_true'
,
help
=
"Publish the results to Github"
)
help
=
"Publish the results to Github"
)
parser
.
add_argument
(
'number'
,
type
=
int
,
help
=
"The pull request number"
)
parser
.
add_argument
(
'number'
,
type
=
int
,
help
=
"The pull request number"
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论