Open oberrauch opened 3 years ago
Thanks! That's weird. Does it happen often? I any case, any PR is welcome, no need to be too fancy here.
Following our discussion in Slack, here's a similar issue which might be related.
I’m getting an error when re-running workflow.init_glacier_directories()
on a Linux SSH server. I haven’t encountered this behaviour in local, but when I run gdirs = workflow.init_glacier_directories(rgi_ids, from_prepro_level=3, prepro_border=10)
for the second time I get:
ERROR: LoadError: PyError ($(Expr(:escape, :(ccall(#= /nethome/bolib001/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'OSError'>
OSError(39, 'Directory not empty')
File "/nethome/bolib001/.conda/envs/oggm_env/lib/python3.8/site-packages/oggm/workflow.py", line 529, in init_glacier_directories
gdirs = execute_entity_task(gdir_from_prepro, entities,
File "/nethome/bolib001/.conda/envs/oggm_env/lib/python3.8/site-packages/oggm/workflow.py", line 191, in execute_entity_task
out = [pc(gdir) for gdir in gdirs]
File "/nethome/bolib001/.conda/envs/oggm_env/lib/python3.8/site-packages/oggm/workflow.py", line 191, in <listcomp>
out = [pc(gdir) for gdir in gdirs]
File "/nethome/bolib001/.conda/envs/oggm_env/lib/python3.8/site-packages/oggm/workflow.py", line 108, in __call__
res = self._call_internal(func, arg, kwargs)
File "/nethome/bolib001/.conda/envs/oggm_env/lib/python3.8/site-packages/oggm/workflow.py", line 102, in _call_internal
return call_func(gdir, **kwargs)
File "/nethome/bolib001/.conda/envs/oggm_env/lib/python3.8/site-packages/oggm/workflow.py", line 251, in gdir_from_prepro
return oggm.GlacierDirectory(entity, from_tar=from_tar)
File "/nethome/bolib001/.conda/envs/oggm_env/lib/python3.8/site-packages/oggm/utils/_workflow.py", line 2126, in __init__
shutil.rmtree(_dir)
File "/nethome/bolib001/.conda/envs/oggm_env/lib/python3.8/shutil.py", line 719, in rmtree
onerror(os.rmdir, path, sys.exc_info())
File "/nethome/bolib001/.conda/envs/oggm_env/lib/python3.8/shutil.py", line 717, in rmtree
os.rmdir(path)
If I close my session and open a new one I no longer get this error. So basically I can still run OGGM, but it strongly hampers development and debugging.
OK so looking into it these are two separate problems.
@JordiBolibar we have discussed your problem offline
@oberrauch the DS_Store problem really baffles me, but it seems to be a recurring issue with these files. I'll try to have a look when time permits, but in the meantime just delete this folder manually
I can find a lot of stackoverflow issues related to the infamous DS_Store files, but never in relation to rmtree... I'm quite confused...
Deleting it by hand works fine for me for now. As far as I understood it the problem is that .DS_Store
is a file and hence os.listdir('.DS_Store')
throws this error. Maybe using os.path.isdir()
would be the cleanest option like
# If new ident, remove all other dirs so spare space
for d in os.listdir(cfg.PATHS['test_dir']):
if d and d != s and os.path.isdir(d):
shutil.rmtree(os.path.join(cfg.PATHS['test_dir'], d))
but this is code in python itself (rmtree
), not something we can control
What I find fascinating is that it should be a bug report for Python itself I would say
Can you check if this still happens in more recent python versions? (not urgent)
Deleting all directories inside the OGGM test directory (since #1064) can result in a error when trying to delete the DS_Store file on MacOS. Following the traceback:
Quick and dirty solution would be to set
ignore_errors=True
inshutil.rmtree
. The more elaborate solution probably to supply a handler viaonerror
, since this could also happen for other files (even though I'm not sure how the should end up in thetests
directory in the first place).