提交 0e505675 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Use the logging system instead of printing

上级 2487363d
import os, sys import os, logging, sys
import theano import theano
from theano import config from theano import config
from theano.gof.compilelock import get_lock, release_lock from theano.gof.compilelock import get_lock, release_lock
from theano.gof import cmodule from theano.gof import cmodule
_logger = logging.getLogger('theano.gof.lazylinker_c')
def warning(*msg):
_logger.warning(_logger_name+'WARNING: '+' '.join(str(m) for m in msg))
def info(*msg):
_logger.info(_logger_name+'INFO: '+' '.join(str(m) for m in msg))
def debug(*msg):
_logger.debug(_logger_name+'DEBUG: '+' '.join(str(m) for m in msg))
# Ensure the compiledir is in `sys.path` to be able to reload an existing # Ensure the compiledir is in `sys.path` to be able to reload an existing
# precompiled library. # precompiled library.
if config.compiledir not in sys.path: if config.compiledir not in sys.path:
...@@ -34,7 +44,7 @@ except ImportError: ...@@ -34,7 +44,7 @@ except ImportError:
if version != getattr(lazylinker_ext, '_version', None): if version != getattr(lazylinker_ext, '_version', None):
raise ImportError() raise ImportError()
except ImportError: except ImportError:
print "COMPILING NEW CVM" info("COMPILING NEW CVM")
dirname = 'lazylinker_ext' dirname = 'lazylinker_ext'
cfile = os.path.join(theano.__path__[0], 'gof', 'lazylinker_c.c') cfile = os.path.join(theano.__path__[0], 'gof', 'lazylinker_c.c')
code = open(cfile).read() code = open(cfile).read()
...@@ -56,7 +66,7 @@ except ImportError: ...@@ -56,7 +66,7 @@ except ImportError:
from lazylinker_ext import lazylinker_ext as lazy_c from lazylinker_ext import lazylinker_ext as lazy_c
assert (lazylinker_ext._version == assert (lazylinker_ext._version ==
lazy_c.get_version()) lazy_c.get_version())
print "NEW VERSION", lazylinker_ext._version info("NEW VERSION", lazylinker_ext._version)
finally: finally:
# Release lock on compilation directory. # Release lock on compilation directory.
release_lock() release_lock()
......
...@@ -4,6 +4,7 @@ IfElse is an Op that works with the LazyLinker to support conditional graph eval ...@@ -4,6 +4,7 @@ IfElse is an Op that works with the LazyLinker to support conditional graph eval
:TODO: Add text to library documentation describing the IfElse Op. :TODO: Add text to library documentation describing the IfElse Op.
""" """
from copy import deepcopy from copy import deepcopy
import logging
from theano.gof import PureOp, Apply, generic, Container from theano.gof import PureOp, Apply, generic, Container
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论