提交 9c605c00 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Flake8 for gof/compiledir.py

上级 46ef1c33
...@@ -8,7 +8,6 @@ import re ...@@ -8,7 +8,6 @@ import re
import shutil import shutil
import struct import struct
import socket import socket
import subprocess
import sys import sys
import textwrap import textwrap
...@@ -55,16 +54,16 @@ def python_int_bitwidth(): ...@@ -55,16 +54,16 @@ def python_int_bitwidth():
compiledir_format_dict = { compiledir_format_dict = {
"platform": platform.platform(), "platform": platform.platform(),
"processor": platform.processor(), "processor": platform.processor(),
"python_version": platform.python_version(), "python_version": platform.python_version(),
"python_bitwidth": local_bitwidth(), "python_bitwidth": local_bitwidth(),
"python_int_bitwidth": python_int_bitwidth(), "python_int_bitwidth": python_int_bitwidth(),
"theano_version": theano.__version__, "theano_version": theano.__version__,
"numpy_version": numpy.__version__, "numpy_version": numpy.__version__,
"gxx_version": gcc_version_str.replace(" ", "_"), "gxx_version": gcc_version_str.replace(" ", "_"),
"hostname": socket.gethostname(), "hostname": socket.gethostname(),
} }
def short_platform(r=None, p=None): def short_platform(r=None, p=None):
...@@ -182,8 +181,8 @@ def filter_compiledir(path): ...@@ -182,8 +181,8 @@ def filter_compiledir(path):
if not os.access(path, os.R_OK | os.W_OK | os.X_OK): if not os.access(path, os.R_OK | os.W_OK | os.X_OK):
# If it exist we need read, write and listing access # If it exist we need read, write and listing access
raise ValueError( raise ValueError(
"compiledir '%s' exists but you don't have read, write" "compiledir '%s' exists but you don't have read, write"
" or listing permissions." % path) " or listing permissions." % path)
else: else:
try: try:
os.makedirs(path, 0770) # read-write-execute for user and group os.makedirs(path, 0770) # read-write-execute for user and group
...@@ -295,7 +294,8 @@ def cleanup(): ...@@ -295,7 +294,8 @@ def cleanup():
have_npy_abi_version = True have_npy_abi_version = True
elif obj.startswith('c_compiler_str='): elif obj.startswith('c_compiler_str='):
have_c_compiler = True have_c_compiler = True
elif (isinstance(obj, (theano.gof.Op, theano.gof.Type)) and elif (isinstance(obj, (theano.gof.Op,
theano.gof.Type)) and
hasattr(obj, 'c_code_cache_version')): hasattr(obj, 'c_code_cache_version')):
v = obj.c_code_cache_version() v = obj.c_code_cache_version()
if v not in [(), None] and v not in key[0]: if v not in [(), None] and v not in key[0]:
...@@ -310,7 +310,7 @@ def cleanup(): ...@@ -310,7 +310,7 @@ def cleanup():
if keydata.key_pkl != filename: if keydata.key_pkl != filename:
keydata.key_pkl = filename keydata.key_pkl = filename
keydata.remove_key(key) keydata.remove_key(key)
except IOError as e: except IOError:
_logger.error( _logger.error(
"Could not remove file '%s'. To complete " "Could not remove file '%s'. To complete "
"the clean-up, please remove manually " "the clean-up, please remove manually "
...@@ -395,7 +395,7 @@ def print_compiledir_content(): ...@@ -395,7 +395,7 @@ def print_compiledir_content():
if big_key_files: if big_key_files:
big_key_files = sorted(big_key_files, key=lambda t: str(t[1])) big_key_files = sorted(big_key_files, key=lambda t: str(t[1]))
big_total_size = sum([size for dir, size, ops in big_key_files]) big_total_size = sum([sz for _, sz, _ in big_key_files])
print(("There are directories with key files bigger than %d bytes " print(("There are directories with key files bigger than %d bytes "
"(they probably contain big tensor constants)" % "(they probably contain big tensor constants)" %
max_key_file_size)) max_key_file_size))
......
...@@ -268,7 +268,6 @@ whitelist_flake8 = [ ...@@ -268,7 +268,6 @@ whitelist_flake8 = [
"sparse/sandbox/truedot.py", "sparse/sandbox/truedot.py",
"sparse/sandbox/sp.py", "sparse/sandbox/sp.py",
"gof/destroyhandler.py", "gof/destroyhandler.py",
"gof/compiledir.py",
"gof/unify.py", "gof/unify.py",
"gof/lazylinker_c.py", "gof/lazylinker_c.py",
"gof/optdb.py", "gof/optdb.py",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论