SasView / sasmodels

Package for calculation of small angle scattering models using OpenCL.
BSD 3-Clause "New" or "Revised" License
15 stars 27 forks source link

makedirs can fail if not setting exist_ok=True #520

Closed bmaranville closed 1 year ago

bmaranville commented 1 year ago

I'm sure it was a weird edge-case race condition, but this code failed for me when working with a library that was using sasmodels. I think the error can be avoided by setting "exist_ok=True" in makedirs

  File "/home/bbm/dev/sasmodels/sasmodels/core.py", line 132, in load_model
    return build_model(load_model_info(model_name),
  File "/home/bbm/dev/sasmodels/sasmodels/core.py", line 339, in build_model
    return kerneldll.load_dll(source['dll'], model_info, numpy_dtype)
  File "/home/bbm/dev/sasmodels/sasmodels/kerneldll.py", line 301, in load_dll
    filename = make_dll(source, model_info, dtype=dtype)
  File "/home/bbm/dev/sasmodels/sasmodels/kerneldll.py", line 272, in make_dll
    os.makedirs(SAS_DLL_PATH)
  File "/home/bbm/miniforge3/envs/saswebcalc/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/home/bbm/.sasmodels/compiled_models'
butlerpd commented 1 year ago

@krzywon to verify if it is ready to merge.

bmaranville commented 1 year ago

Somehow I screwed up this trivial merge. The web merge tool is not very good. DO NOT ACCEPT THIS PR.

bmaranville commented 1 year ago

Ok, someone else changed the function signature and the body of the function in addition to this very simple change, which is causing the merge conflict. I am not able to make the merge cleanly for this reason, and I know nothing of the intent of the other changes.