Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d09a80d0
提交
d09a80d0
authored
8月 10, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
8月 12, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change logging warnings to warnings.warn
It should be easier to test these warnings using our standard `pytest.warns` approach under these changes.
上级
9b3e9d8d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
45 行增加
和
48 行删除
+45
-48
cmodule.py
aesara/link/c/cmodule.py
+45
-48
没有找到文件。
aesara/link/c/cmodule.py
浏览文件 @
d09a80d0
...
@@ -555,7 +555,7 @@ class KeyData:
...
@@ -555,7 +555,7 @@ class KeyData:
with
open
(
self
.
key_pkl
,
"wb"
)
as
f
:
with
open
(
self
.
key_pkl
,
"wb"
)
as
f
:
pickle
.
dump
(
self
,
f
,
protocol
=
pickle
.
HIGHEST_PROTOCOL
)
pickle
.
dump
(
self
,
f
,
protocol
=
pickle
.
HIGHEST_PROTOCOL
)
except
pickle
.
PicklingError
:
except
pickle
.
PicklingError
:
_logger
.
warning
(
f
"Cache leak due to unpickle-able key data
{self.keys}"
)
warnings
.
warn
(
f
"Cache leak due to unpickle-able key data:
{self.keys}"
)
os
.
remove
(
self
.
key_pkl
)
os
.
remove
(
self
.
key_pkl
)
raise
raise
...
@@ -824,8 +824,8 @@ class ModuleCache:
...
@@ -824,8 +824,8 @@ class ModuleCache:
# os. So it is normal that this happens from time
# os. So it is normal that this happens from time
# to time.
# to time.
_logger
.
warning
(
_logger
.
warning
(
"
ModuleCache.refresh() Found
key "
"
`ModuleCache.refresh` Found a
key "
f
"without
dll in cache, deleting it. {key_pkl}"
,
f
"without
a cached shared library ({key_pkl}); deleting it."
)
)
rmtree
(
rmtree
(
root
,
root
,
...
@@ -852,7 +852,7 @@ class ModuleCache:
...
@@ -852,7 +852,7 @@ class ModuleCache:
rmtree
(
rmtree
(
root
,
root
,
ignore_nocleanup
=
True
,
ignore_nocleanup
=
True
,
msg
=
"
b
roken cache directory [EOF]"
,
msg
=
"
B
roken cache directory [EOF]"
,
level
=
logging
.
WARNING
,
level
=
logging
.
WARNING
,
)
)
continue
continue
...
@@ -886,9 +886,9 @@ class ModuleCache:
...
@@ -886,9 +886,9 @@ class ModuleCache:
root
,
root
,
ignore_nocleanup
=
True
,
ignore_nocleanup
=
True
,
msg
=
(
msg
=
(
"
invalid cache entry format -- t
his "
"
Invalid cache entry format. T
his "
"should not happen unless
your
cache "
"should not happen unless
the
cache "
"
was really old
"
"
is outdated.
"
),
),
level
=
logging
.
WARN
,
level
=
logging
.
WARN
,
)
)
...
@@ -921,14 +921,14 @@ class ModuleCache:
...
@@ -921,14 +921,14 @@ class ModuleCache:
# TODO: check if this can happen at all
# TODO: check if this can happen at all
to_del
=
[
key
for
key
in
key_data
.
keys
if
not
key
[
0
]]
to_del
=
[
key
for
key
in
key_data
.
keys
if
not
key
[
0
]]
if
to_del
:
if
to_del
:
_logger
.
warning
(
warnings
.
warn
(
"
ModuleCache.refresh() Found
unversioned "
"
`ModuleCache.refresh` found an
unversioned "
f
"key in
cache, removing it. {key_pkl}"
,
f
"key in
the cache ({key_pkl}); removing it."
)
)
# Since the version is in the module hash, all
# Since the version is in the module hash, all
# keys should be unversioned.
# keys should be unversioned.
if
len
(
to_del
)
!=
len
(
key_data
.
keys
):
if
len
(
to_del
)
!=
len
(
key_data
.
keys
):
_logger
.
warning
(
warnings
.
warn
(
"Found a mix of unversioned and "
"Found a mix of unversioned and "
"versioned keys for the same "
"versioned keys for the same "
f
"module {key_pkl}"
,
f
"module {key_pkl}"
,
...
@@ -986,12 +986,11 @@ class ModuleCache:
...
@@ -986,12 +986,11 @@ class ModuleCache:
else
:
else
:
dir1
=
os
.
path
.
dirname
(
self
.
entry_from_key
[
key
])
dir1
=
os
.
path
.
dirname
(
self
.
entry_from_key
[
key
])
dir2
=
os
.
path
.
dirname
(
entry
)
dir2
=
os
.
path
.
dirname
(
entry
)
_logger
.
warning
(
warnings
.
warn
(
"The same cache key is associated
to
"
"The same cache key is associated
with
"
f
"different modules ({dir1} and {dir2}). This "
f
"different modules ({dir1} and {dir2}). This "
"is not supposed to happen! You may "
"is not supposed to happen. The cache directory "
"need to manually delete your cache "
"may need to be manually delete in order to fix this."
"directory to fix this."
,
)
)
# Clean up the name space to prevent bug.
# Clean up the name space to prevent bug.
if
key_data
.
keys
:
if
key_data
.
keys
:
...
@@ -1025,10 +1024,10 @@ class ModuleCache:
...
@@ -1025,10 +1024,10 @@ class ModuleCache:
# considered a failure of the OTHER process, that deleted
# considered a failure of the OTHER process, that deleted
# it.
# it.
if
entry
in
self
.
module_from_name
:
if
entry
in
self
.
module_from_name
:
_logger
.
warning
(
warnings
.
warn
(
"A module that was loaded by this "
"A module that was loaded by this "
"ModuleCache can no longer be read from file "
"ModuleCache can no longer be read from file "
f
"{entry}.
.. t
his could lead to problems."
,
f
"{entry}.
T
his could lead to problems."
,
)
)
del
self
.
module_from_name
[
entry
]
del
self
.
module_from_name
[
entry
]
...
@@ -1045,7 +1044,7 @@ class ModuleCache:
...
@@ -1045,7 +1044,7 @@ class ModuleCache:
# Under /tmp, file are removed periodically by the
# Under /tmp, file are removed periodically by the
# os. So it is normal that this happen from time to
# os. So it is normal that this happen from time to
# time.
# time.
_logger
.
warning
(
warnings
.
warn
(
f
"Removing key file {pkl_file_to_remove} because the "
f
"Removing key file {pkl_file_to_remove} because the "
"corresponding module is gone from the "
"corresponding module is gone from the "
"file system."
"file system."
...
@@ -1158,11 +1157,9 @@ class ModuleCache:
...
@@ -1158,11 +1157,9 @@ class ModuleCache:
elif
config
.
cmodule__warn_no_version
:
elif
config
.
cmodule__warn_no_version
:
key_flat
=
flatten
(
key
)
key_flat
=
flatten
(
key
)
ops
=
[
k
for
k
in
key_flat
if
isinstance
(
k
,
Op
)]
ops
=
[
k
for
k
in
key_flat
if
isinstance
(
k
,
Op
)]
_logger
.
warning
(
warnings
.
warn
(
"not all the"
f
"The following `Op`(s) do not implement `COp.c_code_cache_version`: {ops}. "
" following op(s) implement"
"They will be recompiled across processes/Python sessions"
" c_code_cache_version(). This makes them"
" recompiled for each process."
+
str
(
ops
)
)
)
self
.
_update_mappings
(
key
,
key_data
,
module
.
__file__
,
not
key_broken
)
self
.
_update_mappings
(
key
,
key_data
,
module
.
__file__
,
not
key_broken
)
return
key_data
return
key_data
...
@@ -1350,7 +1347,7 @@ class ModuleCache:
...
@@ -1350,7 +1347,7 @@ class ModuleCache:
# contain all modules older than age_thresh_del.
# contain all modules older than age_thresh_del.
if
age_thresh_del
<
self
.
age_thresh_use
:
if
age_thresh_del
<
self
.
age_thresh_use
:
if
age_thresh_del
>
0
:
if
age_thresh_del
>
0
:
_logger
.
warning
(
_logger
.
info
(
"Clearing modules that were not deemed "
"Clearing modules that were not deemed "
f
"too old to use: age_thresh_del={age_thresh_del}, "
f
"too old to use: age_thresh_del={age_thresh_del}, "
f
"self.age_thresh_use={self.age_thresh_use}"
f
"self.age_thresh_use={self.age_thresh_use}"
...
@@ -1434,14 +1431,14 @@ class ModuleCache:
...
@@ -1434,14 +1431,14 @@ class ModuleCache:
shutil
.
rmtree
(
to_delete
)
shutil
.
rmtree
(
to_delete
)
_logger
.
debug
(
f
"Deleted: {to_delete}"
)
_logger
.
debug
(
f
"Deleted: {to_delete}"
)
except
Exception
:
except
Exception
:
_logger
.
warning
(
f
"Could not delete {to_delete}"
)
warnings
.
warn
(
f
"Could not delete {to_delete}"
)
continue
continue
to_rename
=
os
.
path
.
join
(
self
.
dirname
,
base_dir
)
to_rename
=
os
.
path
.
join
(
self
.
dirname
,
base_dir
)
if
os
.
path
.
isdir
(
to_rename
):
if
os
.
path
.
isdir
(
to_rename
):
try
:
try
:
shutil
.
move
(
to_rename
,
to_delete
)
shutil
.
move
(
to_rename
,
to_delete
)
except
Exception
:
except
Exception
:
_logger
.
warning
(
f
"Could not move {to_rename} to {to_delete}"
)
warnings
.
warn
(
f
"Could not move {to_rename} to {to_delete}"
)
def
clear_unversioned
(
self
,
min_age
=
None
):
def
clear_unversioned
(
self
,
min_age
=
None
):
"""Delete unversioned dynamic modules.
"""Delete unversioned dynamic modules.
...
@@ -1607,7 +1604,7 @@ def _rmtree(
...
@@ -1607,7 +1604,7 @@ def _rmtree(
with
open
(
os
.
path
.
join
(
parent
,
"delete.me"
),
"w"
):
with
open
(
os
.
path
.
join
(
parent
,
"delete.me"
),
"w"
):
pass
pass
except
Exception
as
ee
:
except
Exception
as
ee
:
_logger
.
warning
(
warnings
.
warn
(
f
"Failed to remove or mark cache directory {parent} for removal {ee}"
f
"Failed to remove or mark cache directory {parent} for removal {ee}"
)
)
...
@@ -1633,13 +1630,13 @@ def get_module_cache(dirname: str, init_args=None) -> ModuleCache:
...
@@ -1633,13 +1630,13 @@ def get_module_cache(dirname: str, init_args=None) -> ModuleCache:
_module_cache
=
ModuleCache
(
dirname
,
**
init_args
)
_module_cache
=
ModuleCache
(
dirname
,
**
init_args
)
atexit
.
register
(
_module_cache
.
_on_atexit
)
atexit
.
register
(
_module_cache
.
_on_atexit
)
elif
init_args
:
elif
init_args
:
_logger
.
warning
(
warnings
.
warn
(
"Ignoring init arguments for module cache because it "
"Ignoring init arguments for module cache because it "
"was created prior to this call"
"was created prior to this call"
)
)
if
_module_cache
.
dirname
!=
dirname
:
if
_module_cache
.
dirname
!=
dirname
:
_logger
.
warning
(
warnings
.
warn
(
"Returning
a module cache instance with a
different "
"Returning
module cache instance with
different "
f
"dirname ({_module_cache.dirname}) than requested ({dirname})"
f
"dirname ({_module_cache.dirname}) than requested ({dirname})"
)
)
return
_module_cache
return
_module_cache
...
@@ -2073,13 +2070,11 @@ class GCC_compiler(Compiler):
...
@@ -2073,13 +2070,11 @@ class GCC_compiler(Compiler):
and
"clang-omp++"
not
in
config
.
cxx
and
"clang-omp++"
not
in
config
.
cxx
and
"icpc"
not
in
config
.
cxx
and
"icpc"
not
in
config
.
cxx
):
):
_logger
.
warning
(
warnings
.
warn
(
"Your Aesara flag `cxx` seems not to be"
"`aesara.config.cxx` is not an identifiable `g++` compiler. "
" the g++ compiler. So we disable the compiler optimization"
"Aesara will disable compiler optimizations specific to `g++`. "
" specific to g++ that tell to compile for a specific CPU."
"At worst, this could cause slow downs.
\n
"
" At worst, this could cause slow down.
\n
"
"Those parameters can be added manually via the `cxxflags` setting."
" You can add those parameters to the compiler yourself"
" via the Aesara flag `gcc__cxxflags`."
)
)
detect_march
=
False
detect_march
=
False
...
@@ -2142,7 +2137,7 @@ class GCC_compiler(Compiler):
...
@@ -2142,7 +2137,7 @@ class GCC_compiler(Compiler):
)
)
else
:
else
:
reported_lines
=
native_lines
reported_lines
=
native_lines
_logger
.
warning
(
warnings
.
warn
(
"Aesara was not able to find the"
"Aesara was not able to find the"
" g++ parameters that tune the compilation to your "
" g++ parameters that tune the compilation to your "
" specific CPU. This can slow down the execution of Aesara"
" specific CPU. This can slow down the execution of Aesara"
...
@@ -2154,15 +2149,17 @@ class GCC_compiler(Compiler):
...
@@ -2154,15 +2149,17 @@ class GCC_compiler(Compiler):
default_lines
=
get_lines
(
f
"{config.cxx} -E -v -"
)
default_lines
=
get_lines
(
f
"{config.cxx} -E -v -"
)
_logger
.
info
(
f
"g++ default lines: {default_lines}"
)
_logger
.
info
(
f
"g++ default lines: {default_lines}"
)
if
len
(
default_lines
)
<
1
:
if
len
(
default_lines
)
<
1
:
_logger
.
warning
(
reported_lines
=
get_lines
(
f
"{config.cxx} -E -v -"
,
parse
=
False
)
"Aesara was not able to find the"
warnings
.
warn
(
" default g++ parameters. This is needed to tune"
(
" the compilation to your specific"
"Aesara was not able to find the "
" CPU. This can slow down the execution of Aesara"
"default g++ parameters. This is needed to tune "
" functions. Please submit the following lines to"
"the compilation to your specific "
" Aesara's mailing list so that we can fix this"
"CPU. This can slow down the execution of Aesara "
" problem:
\n
%
s"
,
"functions. Please submit the following lines to "
get_lines
(
f
"{config.cxx} -E -v -"
,
parse
=
False
),
"Aesara's mailing list so that we can fix this "
f
"problem:
\n
{reported_lines}"
)
)
)
else
:
else
:
# Some options are actually given as "-option value",
# Some options are actually given as "-option value",
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论