Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelzwiers committed Jun 24, 2024
1 parent 7ed6564 commit ee81082
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
14 changes: 6 additions & 8 deletions bidscoin/bcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,18 @@ def update_to(self, b=1, bsize=1, tsize=None):
self.update(b * bsize - self.n) # will also set self.n = b * bsize


def drmaa_nativespec(specs: str) -> str:
def drmaa_nativespec(specs: str, session) -> str:
"""
Converts 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'
:return: The converted native specifications
:param specs: Native Torque walltime and memory specifications, e.g. '-l walltime=00:10:00,mem=2gb'
:param session: The DRMAA session
:return: The converted native specifications
"""

import drmaa # Lazy import to avoid import error on non-HPC systems
jobmanager = session.drmaaImplementation

with drmaa.Session() as session:
implementation = session.drmaaImplementation

if 'Slurm' in implementation and '-l ' in specs:
if 'Slurm' in jobmanager and '-l ' in specs:
specs = (specs.replace('-l ', '')
.replace(',', ' ')
.replace('walltime', '--time')
Expand Down
2 changes: 1 addition & 1 deletion bidscoin/bidsapps/deface.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def deface(bidsfolder: str, pattern: str, participant: list, force: bool, output
jt = pbatch.createJobTemplate()
jt.jobEnvironment = os.environ
jt.remoteCommand = shutil.which('pydeface')
jt.nativeSpecification = drmaa_nativespec(cluster)
jt.nativeSpecification = drmaa_nativespec(cluster, pbatch)
jt.joinFiles = True

# Loop over bids subject/session-directories
Expand Down
2 changes: 1 addition & 1 deletion bidscoin/bidsapps/medeface.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def medeface(bidsfolder: str, pattern: str, maskpattern: str, participant: list,
jt = pbatch.createJobTemplate()
jt.jobEnvironment = os.environ
jt.remoteCommand = shutil.which('pydeface')
jt.nativeSpecification = drmaa_nativespec(cluster)
jt.nativeSpecification = drmaa_nativespec(cluster, pbatch)
jt.joinFiles = True

# Loop over bids subject/session-directories to first get all the echo-combined deface masks
Expand Down
2 changes: 1 addition & 1 deletion bidscoin/bidsapps/skullstrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def skullstrip(bidsfolder: str, pattern: str, participant: list, masked: str, ou
jt = pbatch.createJobTemplate()
jt.jobEnvironment = os.environ
jt.remoteCommand = shutil.which('mri_synthstrip')
jt.nativeSpecification = drmaa_nativespec(cluster)
jt.nativeSpecification = drmaa_nativespec(cluster, pbatch)
jt.joinFiles = True

# Loop over bids subject/session-directories
Expand Down
6 changes: 3 additions & 3 deletions bidscoin/bidsapps/slicereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ def slicer_append(inputimage: Path, operations: str, outlineimage: Path, mainopt
jt = pbatch.createJobTemplate()
jt.jobEnvironment = os.environ
jt.remoteCommand = str(script)
jt.nativeSpecification = drmaa_nativespec(cluster)
jt.nativeSpecification = drmaa_nativespec(cluster, pbatch)
jt.joinFiles = True
jt.jobName = 'slicereport'
jt.outputPath = f"{os.getenv('HOSTNAME')}:{workdir}/{jt.jobName}.out"
jobid = pbatch.runJob(jt)
pbatch.deleteJobTemplate(jt)
LOGGER.info(f"Your slicereport job has been submitted with ID: {jobid}")
pbatch.deleteJobTemplate(jt)
LOGGER.info(f"Your slicereport job has been submitted with ID: {jobid}")

else:
LOGGER.bcdebug(f"Command: {command}")
Expand Down
2 changes: 1 addition & 1 deletion bidscoin/bidscoiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def bidscoiner(sourcefolder: str, bidsfolder: str, participant: list=(), force:
jt = pbatch.createJobTemplate()
jt.jobEnvironment = os.environ
jt.remoteCommand = shutil.which('bidscoiner') or __file__
jt.nativeSpecification = drmaa_nativespec(cluster)
jt.nativeSpecification = drmaa_nativespec(cluster, pbatch)
jt.joinFiles = True
jobids = []

Expand Down

0 comments on commit ee81082

Please sign in to comment.