提交 bcf15e5d authored 作者: Olivier Delalleau's avatar Olivier Delalleau

A warning is now displayed if 'theano-cache clear' fails to delete all temporary workdirs in cache

上级 6ea39844
#!/usr/bin/env python #!/usr/bin/env python
import sys import logging, os, sys
from theano import config 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.setLevel(logging.WARN)
if len(sys.argv) == 1: if len(sys.argv) == 1:
print config.compiledir print config.compiledir
elif sys.argv[1] in ('clear'): elif sys.argv[1] in ('clear'):
...@@ -11,6 +15,18 @@ elif sys.argv[1] in ('clear'): ...@@ -11,6 +15,18 @@ elif sys.argv[1] in ('clear'):
cache = get_module_cache(init_args=dict(do_refresh=False)) cache = get_module_cache(init_args=dict(do_refresh=False))
cache.clear(unversioned_min_age=-1, clear_base_files=True, cache.clear(unversioned_min_age=-1, clear_base_files=True,
delete_if_problem=True) delete_if_problem=True)
# Print a warning if some cached modules were not removed, so that the user
# knows he should manually delete them to properly clear the cache.
items = sorted(os.listdir(config.compiledir))
items = [item for item in sorted(os.listdir(cache.dirname))
if item.startswith('tmp')]
if items:
_logger.warning('There remain elements in the cache dir that you may '
'need to erase manually. The cache dir is:\n %s' %
config.compiledir)
_logger.debug('Remaining elements (%s): %s' %
(len(items), ', '.join(items)))
else: else:
print 'command "%s" not recognized' % sys.argv[1] print 'command "%s" not recognized' % sys.argv[1]
print 'Type "theano-cache" to print the cache location' print 'Type "theano-cache" to print the cache location'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论