提交 a4c17642 authored 作者: abergeron's avatar abergeron

Merge pull request #2143 from nouiz/log

Don't change the defaul log level during import. Otherwise, the user can...
...@@ -8,7 +8,6 @@ from theano import config ...@@ -8,7 +8,6 @@ from theano import config
from theano.gof.cc import get_module_cache from theano.gof.cc import get_module_cache
_logger = logging.getLogger('theano.bin.theano-cache') _logger = logging.getLogger('theano.bin.theano-cache')
_logger.setLevel(logging.WARN)
def print_help(exit_status): def print_help(exit_status):
......
...@@ -18,7 +18,6 @@ disable that plugin. ...@@ -18,7 +18,6 @@ disable that plugin.
import logging import logging
_logger = logging.getLogger('theano.bin.theano-nose') _logger = logging.getLogger('theano.bin.theano-nose')
_logger.setLevel(logging.WARN)
import os import os
import nose import nose
......
...@@ -97,7 +97,6 @@ AddConfigVar('DebugMode.check_preallocated_output_ndim', ...@@ -97,7 +97,6 @@ AddConfigVar('DebugMode.check_preallocated_output_ndim',
import logging import logging
_logger = logging.getLogger("theano.compile.debugmode") _logger = logging.getLogger("theano.compile.debugmode")
_logger.setLevel(logging.WARNING)
# Filter to avoid duplicating optimization warnings # Filter to avoid duplicating optimization warnings
...@@ -757,7 +756,6 @@ def _check_viewmap(node, storage_map): ...@@ -757,7 +756,6 @@ def _check_viewmap(node, storage_map):
good_alias, bad_alias = {}, {} good_alias, bad_alias = {}, {}
outstorage = storage_map[onode][0] outstorage = storage_map[onode][0]
instorage_id = [id(storage_map[i][0]) for i in node.inputs]
# first find out which input it aliases # first find out which input it aliases
view_map = getattr(node.op, 'view_map', {}) view_map = getattr(node.op, 'view_map', {})
...@@ -869,8 +867,6 @@ def _find_bad_optimizations0(order, reasons, r_vals): ...@@ -869,8 +867,6 @@ def _find_bad_optimizations0(order, reasons, r_vals):
for i, node in enumerate(order): for i, node in enumerate(order):
for new_r in node.outputs: for new_r in node.outputs:
for reason, r, old_graph_str, new_graph_str in reasons[new_r]: for reason, r, old_graph_str, new_graph_str in reasons[new_r]:
problem = False
#check if the value for new_r doesn't match the value for r #check if the value for new_r doesn't match the value for r
new_r_val = r_vals[new_r] new_r_val = r_vals[new_r]
r_val = r_vals[r] r_val = r_vals[r]
...@@ -1553,7 +1549,6 @@ class _Linker(gof.link.LocalLinker): ...@@ -1553,7 +1549,6 @@ class _Linker(gof.link.LocalLinker):
# don't do this ugly hacky way of setting the # don't do this ugly hacky way of setting the
# filter_checks_isfinite # filter_checks_isfinite
from theano.tensor import TensorType # to set filter_check_isfinite from theano.tensor import TensorType # to set filter_check_isfinite
from theano import tests # for config.unittests.rseed
fgraph = self.fgraph fgraph = self.fgraph
input_storage_ = input_storage input_storage_ = input_storage
output_storage_ = output_storage output_storage_ = output_storage
...@@ -1707,8 +1702,6 @@ class _Linker(gof.link.LocalLinker): ...@@ -1707,8 +1702,6 @@ class _Linker(gof.link.LocalLinker):
if r.owner is None] if r.owner is None]
try: try:
equiv_vals = {}
problematic = set()
# r_vals are the true values associated with each # r_vals are the true values associated with each
# variable in the graph they should not change during # variable in the graph they should not change during
# the evaluation of this function, even when the graph # the evaluation of this function, even when the graph
...@@ -2266,7 +2259,6 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions ...@@ -2266,7 +2259,6 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
"default for a SymbolicInputKit.") "default for a SymbolicInputKit.")
input_storage.append(default.storage) input_storage.append(default.storage)
default = None default = None
required = False
elif isinstance(input, SymbolicInputKit): elif isinstance(input, SymbolicInputKit):
# If the input is a SymbolicInputKit, it represents more than # If the input is a SymbolicInputKit, it represents more than
# one storage unit. The indices and subinputs lists represent # one storage unit. The indices and subinputs lists represent
......
...@@ -70,7 +70,6 @@ from theano.gof import cmodule ...@@ -70,7 +70,6 @@ from theano.gof import cmodule
import logging import logging
_logger = logging.getLogger("theano.gof.cc") _logger = logging.getLogger("theano.gof.cc")
_logger.setLevel(logging.WARN)
from theano.gof.callcache import CallCache from theano.gof.callcache import CallCache
......
...@@ -68,7 +68,6 @@ AddConfigVar('cmodule.preload_cache', ...@@ -68,7 +68,6 @@ AddConfigVar('cmodule.preload_cache',
in_c_key=False) in_c_key=False)
_logger = logging.getLogger("theano.gof.cmodule") _logger = logging.getLogger("theano.gof.cmodule")
_logger.setLevel(logging.WARNING)
METH_VARARGS = "METH_VARARGS" METH_VARARGS = "METH_VARARGS"
METH_NOARGS = "METH_NOARGS" METH_NOARGS = "METH_NOARGS"
......
...@@ -11,8 +11,10 @@ import logging ...@@ -11,8 +11,10 @@ import logging
from theano import config from theano import config
_logger = logging.getLogger("theano.gof.compilelock") _logger = logging.getLogger("theano.gof.compilelock")
# INFO will show the the messages "Refreshing lock" message # If the user provided a logging level, we don't want to override it.
_logger.setLevel(logging.INFO) if _logger.level == logging.NOTSET:
# INFO will show the the messages "Refreshing lock" message
_logger.setLevel(logging.INFO)
# In seconds, time that a process will wait before deciding to override an # In seconds, time that a process will wait before deciding to override an
# existing lock. An override only happens when the existing lock is held by # existing lock. An override only happens when the existing lock is held by
......
差异被折叠。
...@@ -10,7 +10,14 @@ import sys ...@@ -10,7 +10,14 @@ import sys
import tabnanny import tabnanny
import tokenize import tokenize
import argparse try:
import argparse
except ImportError:
raise ImportError(
"check_whitespace.py need Python module argparse introduced in"
" Python 2.7. It is available in pypi for compatibility."
" You can install it with this command 'pip install argparse'")
import reindent import reindent
from theano.compat.six import StringIO from theano.compat.six import StringIO
......
#!/usr/bin/env python
"""
This is a script for testing pull requests for Theano. It merges the pull
request with current master, installs and tests on all available versions of
Python, and posts the results to Gist if any tests fail.
It is copied from ipython
Usage:
python test_pr.py 1657
"""
from __future__ import print_function
import errno
from glob import glob
import io
import json
import os
import pickle
import re
import requests
import shutil
import time
from subprocess import (call, check_call, check_output,
PIPE, STDOUT, CalledProcessError)
import sys
import gh_api
basedir = os.path.join(os.path.expanduser("~"), ".theano_pr_tests")
repodir = os.path.join(basedir, "Theano")
ipy_repository = 'git://github.com/Theano/Theano.git'
ipy_http_repository = 'http://github.com/Theano/Theano.git'
gh_project = "Theano/Theano"
supported_pythons = ['python2.6', 'python2.7', 'python3.1', 'python3.2']
supported_pythons = ['python2.7']
unavailable_pythons = []
def available_python_versions():
"""Get the executable names of available versions of Python on the system.
"""
del unavailable_pythons[:]
for py in supported_pythons:
try:
check_call([py, '-c', 'import nose'], stdout=PIPE)
yield py
except (OSError, CalledProcessError):
unavailable_pythons.append(py)
venvs = []
def setup():
"""Prepare the repository and virtualenvs."""
global venvs
try:
os.mkdir(basedir)
except OSError, e:
if e.errno != errno.EEXIST:
raise
os.chdir(basedir)
# Delete virtualenvs and recreate
for venv in glob('venv-*'):
shutil.rmtree(venv)
for py in available_python_versions():
check_call(['virtualenv', '-p', py,
'--system-site-packages', 'venv-%s' % py])
venvs.append((py, 'venv-%s' % py))
# Check out and update the repository
if not os.path.exists('Theano'):
try:
check_call(['git', 'clone', ipy_repository])
except CalledProcessError:
check_call(['git', 'clone', ipy_http_repository])
os.chdir(repodir)
check_call(['git', 'checkout', 'master'])
try:
check_call(['git', 'pull', ipy_repository, 'master'])
except CalledProcessError:
check_call(['git', 'pull', ipy_http_repository, 'master'])
os.chdir(basedir)
missing_libs_re = re.compile(r"Tools and libraries NOT available at test"
r" time:\n\s*(.*?)\n")
def get_missing_libraries(log):
m = missing_libs_re.search(log)
if m:
return m.group(1)
def get_branch(repo, branch, owner, mergeable):
os.chdir(repodir)
if mergeable:
merged_branch = "%s-%s" % (owner, branch)
# Delete the branch first
call(['git', 'branch', '-D', merged_branch])
check_call(['git', 'checkout', '-b', merged_branch])
check_call(['git', 'pull', '--no-ff', '--no-commit', repo, branch])
check_call(['git', 'commit', '-m', "merge %s/%s" % (repo, branch)])
else:
# Fetch the branch without merging it.
check_call(['git', 'fetch', repo, branch])
check_call(['git', 'checkout', 'FETCH_HEAD'])
os.chdir(basedir)
def run_tests(venv):
py = os.path.join(basedir, venv, 'bin', 'python')
print(py)
os.chdir(repodir)
# cleanup build-dir
if os.path.exists('build'):
shutil.rmtree('build')
check_call([py, 'setup.py', 'install'])
os.chdir(basedir)
# Environment variables:
orig_path = os.environ["PATH"]
os.environ["PATH"] = os.path.join(basedir, venv,
'bin') + ':' + os.environ["PATH"]
os.environ.pop("PYTHONPATH", None)
iptest = os.path.join(basedir, venv, 'bin', 'theano-test')
# if not os.path.exists(iptest):
# iptest = os.path.join(basedir, venv, 'bin', 'iptest3')
print("\nRunning tests, this typically takes a few minutes...")
try:
return True, check_output([iptest], stderr=STDOUT).decode('utf-8')
except CalledProcessError, e:
return False, e.output.decode('utf-8')
finally:
# Restore $PATH
os.environ["PATH"] = orig_path
def markdown_format(pr, results_urls, unavailable_pythons):
def format_result(py, passed, gist_url, missing_libraries):
s = "* %s: " % py
if passed:
s += "OK"
else:
s += "Failed, log at %s" % gist_url
if missing_libraries:
s += " (libraries not available: " + missing_libraries + ")"
return s
if pr['mergeable']:
com = pr['head']['sha'][:7] + " merged into master"
else:
com = pr['head']['sha'][:7] + " (can't merge cleanly)"
lines = ["**Test results for commit %s**" % com,
"Platform: " + sys.platform,
""] + \
[format_result(*r) for r in results_urls] + \
["",
"Not available for testing: " + ", ".join(unavailable_pythons)]
return "\n".join(lines)
def post_results_comment(pr, results, num,
unavailable_pythons=unavailable_pythons):
body = markdown_format(pr, results, unavailable_pythons)
gh_api.post_issue_comment(gh_project, num, body)
def print_results(pr, results_urls, unavailable_pythons=unavailable_pythons):
print("\n")
if pr['mergeable']:
print("**Test results for commit %s merged into master**" %
pr['head']['sha'][:7])
else:
print(
"**Test results for commit %s (can't merge cleanly)**" %
pr['head']['sha'][:7])
print("Platform:", sys.platform)
for py, passed, gist_url, missing_libraries in results_urls:
if passed:
print(py, ":", "OK")
else:
print(py, ":", "Failed")
print(" Test log:", gist_url)
if missing_libraries:
print(" Libraries not available:", missing_libraries)
print("Not available for testing:", ", ".join(unavailable_pythons))
def dump_results(num, results, pr):
f = open(os.path.join(basedir, 'lastresults.pkl'), 'wb')
try:
pickle.dump((num, results, pr, unavailable_pythons), f)
finally:
f.close()
def load_results():
f = open(os.path.join(basedir, 'lastresults.pkl'), 'rb')
try:
ret = pickle.load(f)
finally:
f.close()
return ret
def save_logs(results, pr):
results_paths = []
for py, passed, log, missing_libraries in results:
if passed:
results_paths.append((py, passed, None, missing_libraries))
else:
result_locn = os.path.abspath(os.path.join('venv-%s' % py,
pr['head']['sha'][:7] + ".log"))
f = io.open(result_locn, 'w', encoding='utf-8')
try:
f.write(log)
finally:
f.close()
results_paths.append((py, False, result_locn, missing_libraries))
return results_paths
def post_logs(results):
results_urls = []
for py, passed, log, missing_libraries in results:
if passed:
results_urls.append((py, passed, None, missing_libraries))
else:
result_locn = gh_api.post_gist(log, description='Theano test log',
filename="results.log", auth=True)
results_urls.append((py, False, result_locn, missing_libraries))
return results_urls
def test_pr(num, post_results=True):
# Get Github authorisation first, so that the user is prompted
# straight away if their login is needed.
if post_results:
gh_api.get_auth_token()
setup()
pr = gh_api.get_pull_request(gh_project, num)
get_branch(repo=pr['head']['repo']['clone_url'],
branch=pr['head']['ref'],
owner=pr['head']['repo']['owner']['login'],
mergeable=pr['mergeable'],
)
results = []
for py, venv in venvs:
tic = time.time()
passed, log = run_tests(venv)
elapsed = int(time.time() - tic)
print("Ran tests with %s in %is" % (py, elapsed))
missing_libraries = get_missing_libraries(log)
if passed:
results.append((py, True, None, missing_libraries))
else:
results.append((py, False, log, missing_libraries))
dump_results(num, results, pr)
results_paths = save_logs(results, pr)
print_results(pr, results_paths)
if post_results:
results_urls = post_logs(results)
post_results_comment(pr, results_urls, num)
print("(Posted to Github)")
else:
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)
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description="Test an Theano pull request")
parser.add_argument('-p', '--publish', action='store_true',
help="Publish the results to Github")
parser.add_argument('number', type=int, help="The pull request number")
args = parser.parse_args()
test_pr(args.number, post_results=args.publish)
...@@ -16,7 +16,6 @@ import nvcc_compiler ...@@ -16,7 +16,6 @@ import nvcc_compiler
_logger_name = 'theano.sandbox.cuda' _logger_name = 'theano.sandbox.cuda'
_logger = logging.getLogger(_logger_name) _logger = logging.getLogger(_logger_name)
_logger.setLevel(logging.WARNING)
AddConfigVar('pycuda.init', AddConfigVar('pycuda.init',
"""If True, always initialize PyCUDA when Theano want to """If True, always initialize PyCUDA when Theano want to
......
...@@ -9,6 +9,7 @@ import theano ...@@ -9,6 +9,7 @@ import theano
from theano import gof, Type, Apply from theano import gof, Type, Apply
from theano import tensor, scalar, config from theano import tensor, scalar, config
from theano.compat.six import StringIO from theano.compat.six import StringIO
from theano.gradient import grad_undefined
from theano.scalar import Scalar from theano.scalar import Scalar
scal = scalar # somewhere scalar gets reassigned to be a function scal = scalar # somewhere scalar gets reassigned to be a function
...@@ -31,8 +32,6 @@ from theano.sandbox.cuda.elemwise import NaiveAlgo ...@@ -31,8 +32,6 @@ from theano.sandbox.cuda.elemwise import NaiveAlgo
_logger_name = 'theano.sandbox.cuda.basic_ops' _logger_name = 'theano.sandbox.cuda.basic_ops'
_logger = logging.getLogger(_logger_name) _logger = logging.getLogger(_logger_name)
_logger.setLevel(logging.INFO)
_logger.addHandler(logging.StreamHandler()) # TO REMOVE
def as_cuda_ndarray_variable(x): def as_cuda_ndarray_variable(x):
......
...@@ -7,21 +7,19 @@ that ndim is 0 as with all scalar type. ...@@ -7,21 +7,19 @@ that ndim is 0 as with all scalar type.
""" """
import copy, logging, sys import logging
import numpy import numpy
from theano.scalar.basic import upgrade_to_float_no_complex, complex_types from theano.scalar.basic import upgrade_to_float_no_complex, complex_types
from theano.scalar.basic_scipy import Erfinv from theano.scalar.basic_scipy import Erfinv
from theano.compat.six import StringIO from theano.compat.six import StringIO
from theano import Apply, Constant, Op, Type, Variable from theano import Apply
from theano import gof, scalar, tensor from theano import gof, scalar
_logger_name = 'theano.sandbox.cuda.elemwise' _logger_name = 'theano.sandbox.cuda.elemwise'
_logger = logging.getLogger(_logger_name) _logger = logging.getLogger(_logger_name)
_logger.setLevel(logging.INFO)
_logger.addHandler(logging.StreamHandler()) #TO REMOVE
def _logical_scalar(x): def _logical_scalar(x):
...@@ -432,7 +430,6 @@ class NaiveAlgo(object): ...@@ -432,7 +430,6 @@ class NaiveAlgo(object):
return sio.getvalue() return sio.getvalue()
def c_src_kernel_Ccontiguous(self, node, nodename): def c_src_kernel_Ccontiguous(self, node, nodename):
nd = node.outputs[0].type.ndim
sio = StringIO() sio = StringIO()
#print 'C_SRC_KERNEL', sio.getvalue() #print 'C_SRC_KERNEL', sio.getvalue()
......
import commands
import distutils import distutils
import logging import logging
import os import os
import re
import subprocess import subprocess
import sys import sys
import warnings import warnings
...@@ -19,7 +17,6 @@ from theano.gof.python25 import any ...@@ -19,7 +17,6 @@ from theano.gof.python25 import any
from theano.misc.windows import output_subprocess_Popen from theano.misc.windows import output_subprocess_Popen
_logger = logging.getLogger("theano.sandbox.cuda.nvcc_compiler") _logger = logging.getLogger("theano.sandbox.cuda.nvcc_compiler")
_logger.setLevel(logging.WARN)
from theano.configparser import (config, AddConfigVar, StrParam, from theano.configparser import (config, AddConfigVar, StrParam,
BoolParam, ConfigParam) BoolParam, ConfigParam)
...@@ -246,7 +243,6 @@ class NVCC_compiler(object): ...@@ -246,7 +243,6 @@ class NVCC_compiler(object):
preargs = list(preargs) preargs = list(preargs)
if sys.platform != 'win32': if sys.platform != 'win32':
preargs.append('-fPIC') preargs.append('-fPIC')
no_opt = False
cuda_root = config.cuda.root cuda_root = config.cuda.root
#The include dirs gived by the user should have precedence over #The include dirs gived by the user should have precedence over
......
...@@ -7,7 +7,6 @@ from theano.compile import optdb ...@@ -7,7 +7,6 @@ from theano.compile import optdb
_logger_name = 'theano.sandbox.gpuarray' _logger_name = 'theano.sandbox.gpuarray'
_logger = logging.getLogger(_logger_name) _logger = logging.getLogger(_logger_name)
_logger.setLevel(logging.WARNING)
error = _logger.error error = _logger.error
info = _logger.info info = _logger.info
......
...@@ -25,7 +25,7 @@ index aaebb43..2d06b29 100644 ...@@ -25,7 +25,7 @@ index aaebb43..2d06b29 100644
* cdef inline object get_array_base(ndarray arr): * cdef inline object get_array_base(ndarray arr):
*/ */
- __pyx_v_arr->base = __pyx_v_baseptr; - __pyx_v_arr->base = __pyx_v_baseptr;
+#if NPY_API < 0x00000007 +#if NPY_API_VERSION < 0x00000007
+ PyArray_BASE(__pyx_v_arr) = __pyx_v_baseptr; + PyArray_BASE(__pyx_v_arr) = __pyx_v_baseptr;
+#else +#else
+ PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_baseptr); + PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_baseptr);
......
...@@ -7156,7 +7156,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a ...@@ -7156,7 +7156,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
* *
* cdef inline object get_array_base(ndarray arr): * cdef inline object get_array_base(ndarray arr):
*/ */
#if NPY_API < 0x00000007 #if NPY_API_VERSION < 0x00000007
PyArray_BASE(__pyx_v_arr) = __pyx_v_baseptr; PyArray_BASE(__pyx_v_arr) = __pyx_v_baseptr;
#else #else
PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_baseptr); PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_baseptr);
......
...@@ -2,6 +2,7 @@ import errno ...@@ -2,6 +2,7 @@ import errno
import logging import logging
import os import os
import sys import sys
import warnings
import numpy import numpy
...@@ -13,7 +14,6 @@ from theano.gof import cmodule ...@@ -13,7 +14,6 @@ from theano.gof import cmodule
_logger = logging.getLogger('theano.scan_module.scan_perform') _logger = logging.getLogger('theano.scan_module.scan_perform')
_logger.setLevel(logging.WARN)
version = 0.283 # must match constant returned in function get_version() version = 0.283 # must match constant returned in function get_version()
......
...@@ -12,7 +12,6 @@ from theano import config ...@@ -12,7 +12,6 @@ from theano import config
from theano.gof.cmodule import GCC_compiler from theano.gof.cmodule import GCC_compiler
_logger = logging.getLogger('theano.tensor.blas') _logger = logging.getLogger('theano.tensor.blas')
#_logger.setLevel(logging.INFO)
def detect_macos_sdot_bug(): def detect_macos_sdot_bug():
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论