Skip to content

Commit

Permalink
Minor tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelzwiers committed Jun 24, 2024
1 parent 4ad917d commit 73b1892
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions bidscoin/bcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ def update_to(self, b=1, bsize=1, tsize=None):

def drmaa_nativespec(specs: str, session) -> str:
"""
Converts native Torque walltime and memory specifications to the DRMAA implementation (currently only Slurm is supported)
Converts (CLI default) native Torque walltime and memory specifications to the DRMAA implementation (currently only Slurm is supported)
:param specs: Native Torque walltime and memory specifications, e.g. '-l walltime=00:10:00,mem=2gb'
:param specs: Native Torque walltime and memory specifications, e.g. '-l walltime=00:10:00,mem=2gb' from argparse CLI
:param session: The DRMAA session
:return: The converted native specifications
"""

jobmanager: str = session.drmaaImplementation

if '-l ' in specs and 'torque' not in jobmanager.lower():
if '-l ' in specs and 'pbs' not in jobmanager.lower():

if 'slurm' in jobmanager.lower():
specs = (specs.replace('-l ', '')
Expand Down
7 changes: 2 additions & 5 deletions bidscoin/bidsapps/slicereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,17 @@ def slicer_append(inputimage: Path, operations: str, outlineimage: Path, mainopt
f"slicer {'mathsimg' if mathsimg else inputimage} {outlineimage if outlineimage.name else ''} {mainopts} {outputopts}\n" \
f"pngappend {sliceroutput} {montage.name}\n" \
f"mv {montage.name} {montage.parent}\n" \
+ (f"cd {workdir.parent}; rm -r {workdir}" if not DEBUG else '')
+ (f"rm -r {workdir}" if not DEBUG else '')

# Run the command on the HPC cluster or directly in the shell
if cluster:
from drmaa import Session as drmaasession # Lazy import to avoid import error on non-HPC systems
from bidscoin.bcoin import drmaa_nativespec

script = workdir/'slicereport.sh'
script.write_text('#!/bin/bash\n' + command)
script.chmod(0o744)
with drmaasession() as pbatch:
jt = pbatch.createJobTemplate()
jt.jobEnvironment = os.environ
jt.remoteCommand = str(script)
jt.remoteCommand = '#!/bin/bash\n' + command
jt.nativeSpecification = drmaa_nativespec(cluster, pbatch)
jt.joinFiles = True
jt.jobName = 'slicereport'
Expand Down

0 comments on commit 73b1892

Please sign in to comment.