You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
self.update(b*bsize-self.n) # will also set self.n = b * bsize
54
51
55
52
56
-
classCustomLogger(logging.Logger):
57
-
"""Extend the Logger class to add custom methods for the new levels"""
53
+
defdrmaa_nativespec(specs: str, session) ->str:
54
+
"""
55
+
Converts (CLI default) native Torque walltime and memory specifications to the DRMAA implementation (currently only Slurm is supported)
58
56
59
-
defbcdebug(self, message, *args, **kwargs):
60
-
"""Custom BIDSCOIN DEBUG messages"""
61
-
ifself.isEnabledFor(BCDEBUG_LEVEL):
62
-
self._log(BCDEBUG_LEVEL, message, args, **kwargs)
57
+
:param specs: Native Torque walltime and memory specifications, e.g. '-l walltime=00:10:00,mem=2gb'
58
+
:param session: The DRMAA session
59
+
:return: The converted native specifications
60
+
"""
63
61
64
-
defverbose(self, message, *args, **kwargs):
65
-
"""Custom BIDSCOIN VERBOSE messages"""
66
-
ifself.isEnabledFor(VERBOSE_LEVEL):
67
-
self._log(VERBOSE_LEVEL, message, args, **kwargs)
62
+
jobmanager: str=session.drmaaImplementation
63
+
64
+
if'-l 'inspecsand'pbs'notinjobmanager.lower():
68
65
69
-
defsuccess(self, message, *args, **kwargs):
70
-
"""Custom BIDSCOIN SUCCESS messages"""
71
-
ifself.isEnabledFor(SUCCESS_LEVEL):
72
-
self._log(SUCCESS_LEVEL, message, args, **kwargs)
66
+
if'slurm'injobmanager.lower():
67
+
specs= (specs.replace('-l ', '')
68
+
.replace(',', ' ')
69
+
.replace('walltime', '--time')
70
+
.replace('mem', '--mem')
71
+
.replace('gb','000'))
72
+
else:
73
+
LOGGER.warning(f"Default `--cluster` native specifications are not (yet) provided for {jobmanager}. Please add them to your command if you get DRMAA errors")
LOGGER.error(f"{len(failedjobs)} HPC jobs failed to run:\n{failedjobs}\nThis may well be due to an underspecified `--cluster` input option (e.g. not enough memory)")
# Add the console streamhandler and bring some color to those boring logs! :-)
109
-
coloredlogs.install(level=BCDEBUGifDEBUGelseVERBOSEifnotlogfile.nameelse'INFO', fmt=cfmt, datefmt=datefmt) # NB: Using tqdm sets the streamhandler level to 0, see: https://github.com/tqdm/tqdm/pull/1235
162
+
coloredlogs.install(level='BCDEBUG'ifDEBUGelse'VERBOSE'ifnotlogfile.nameelse'INFO', fmt=cfmt, datefmt=datefmt) # NB: Using tqdm sets the streamhandler level to 0, see: https://github.com/tqdm/tqdm/pull/1235
Converts (CLI default) native Torque walltime and memory specifications to the DRMAA implementation (currently only Slurm is supported)
172
-
173
-
:param specs: Native Torque walltime and memory specifications, e.g. '-l walltime=00:10:00,mem=2gb'
174
-
:param session: The DRMAA session
175
-
:return: The converted native specifications
176
-
"""
177
-
178
-
jobmanager: str=session.drmaaImplementation
179
-
180
-
if'-l 'inspecsand'pbs'notinjobmanager.lower():
181
-
182
-
if'slurm'injobmanager.lower():
183
-
specs= (specs.replace('-l ', '')
184
-
.replace(',', ' ')
185
-
.replace('walltime', '--time')
186
-
.replace('mem', '--mem')
187
-
.replace('gb','000'))
188
-
else:
189
-
LOGGER.warning(f"Default `--cluster` native specifications are not (yet) provided for {jobmanager}. Please add them to your command if you get DRMAA errors")
LOGGER.error(f"{len(failedjobs)} HPC jobs failed to run:\n{failedjobs}\nThis may well be due to an underspecified `--cluster` input option (e.g. not enough memory)")
0 commit comments