meuleman / epilogos

Methods for summarizing and visualizing multi-biosample functional genomic annotations
https://epilogos.net
GNU General Public License v3.0
41 stars 5 forks source link

Consider wrapping `subprocess` calls in `try/except` blocks #24

Open alexpreynolds opened 3 years ago

alexpreynolds commented 3 years ago

https://github.com/meuleman/epilogos/blob/80bf1f5b0846b495d40eda0cd0315c8c0d371b2c/src/computeEpilogosSlurm.py#L453

Using a try/except block where you use subprocess calls can help with catching local issues with running command-line tools outside of Python:

try:
    subprocess.run("scancel {}".format(allJobIDs), shell=True)
except subprocess.CalledProcessError as e:
    # handle error...

Certain error codes might have to do with the binary not being found, or in the case of scancel, one or more job IDs passed to it might not found associated with any jobs internally, etc. Better handling of errors can help end users catch odd problems, or help with debugging.