Skip to content

Commit f734fb3

Browse files
committed
Print stderr when both qsub and sacctmgr fails
The command `sacctmgr` fails on some computers (mila01 namely), but the current behavior gives the impression sbatch is simply not available. Printing the stderr makes it more obvious that sbatch should be available, but something is broken behind sacctmgr. It only appears when using -vv options nevertheless.
1 parent 29973b0 commit f734fb3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

smartdispatch/utils.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
import distutils.spawn
33
import hashlib
44
import json
5+
import logging
56
import re
67
import unicodedata
78

89
from subprocess import Popen, PIPE
910

1011

12+
logger = logging.getLogger(__name__)
13+
14+
1115
TIME_REGEX = re.compile(
1216
"^(?:(?:(?:(\d*):)?(\d*):)?(\d*):)?(\d*)$")
1317

@@ -157,11 +161,18 @@ def detect_cluster():
157161

158162
def get_slurm_cluster_name():
159163
try:
160-
stdout = Popen("sacctmgr list cluster", stdout=PIPE, shell=True).communicate()[0]
164+
popen = Popen("sacctmgr list cluster", stdout=PIPE, shell=True)
165+
stdout, stderr = popen.communicate()
166+
except OSError:
167+
return None
168+
169+
try:
161170
stdout = stdout.decode()
162171
cluster_name = stdout.splitlines()[2].strip().split(' ')[0]
163-
except IndexError, OSError:
172+
except IndexError:
173+
logger.debug(stderr)
164174
return None
175+
165176
return cluster_name
166177

167178

0 commit comments

Comments
 (0)