GMPavanLab / Swarm-CG

Swarm-CG: Automatic Parametrization of Bonded Terms in MARTINI-based Coarse-Grained Models of Simple to Complex Molecules via Fuzzy Self-Tuning Particle Swarm Optimization
https://pubs.acs.org/doi/10.1021/acsomega.0c05469
MIT License
42 stars 10 forks source link

scg_optimize fails on WSL due to permission denied #32

Open maurobedoya opened 3 years ago

maurobedoya commented 3 years ago

Dear Swarm-CG creators,

Running the scg_optimize executable on WSL crashes with the following error:

shutil.Error: [('.internal/input_CG_simulation_files', 'CG_sim_files_eval_step_1', "[Errno 13] Permission denied: 
'CG_sim_files_eval_step_1'")]

We traced the error to line 2690 in swarmCG.py:

# create new directory for new parameters evaluation
current_eval_dir = f'{config.iteration_sim_files_dirname}_eval_step_{ns.nb_eval}'
shutil.copytree(config.input_sim_files_dirname, current_eval_dir)

We found that there is a bug in the copytree function on WSL (https://bugs.python.org/issue38633). A temporary fix could be to add the following lines at the beginning of the file:

import errno
orig_copyxattr = shutil._copyxattr
def patched_copyxattr(src, dst, *, follow_symlinks=True):
  try:
    orig_copyxattr(src, dst, follow_symlinks=follow_symlinks)
  except OSError as ex:
    if ex.errno != errno.EACCES: raise
shutil._copyxattr = patched_copyxattr

Thanks to @franciscoadasme for his help in the debugging.

I hope this helps!

giovannidoni commented 3 years ago

Thank you @maurobedoya for adding this issue and for the suggestion. Will take this into account in the development of the refactoring currently ongoing in the develop branch.