Skip to content

Commit

Permalink
Remove square brackets from job name in LSF executor (#4799) [ci fast]
Browse files Browse the repository at this point in the history

Signed-off-by: Brian Fulton-Howard <fultonh1@gmail.com>
Signed-off-by: Brian Fulton-Howard <brian.fulton-howard@mssm.edu>
Co-authored-by: Brian Fulton-Howard <brian.fulton-howard@mssm.edu>
Co-authored-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
3 people committed Mar 10, 2024
1 parent baf2911 commit 6e0ac72
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Expand Up @@ -112,6 +112,13 @@ class LsfExecutor extends AbstractGridExecutor {
return result
}

@Override
String sanitizeJobName( String name ) {
// LSF does not allow square brackets in job names except for job arrays
name = name.replace('[','').replace(']','')
// Old LSF versions do not allow job names longer than 511 chars
name.size()>511 ? name.substring(0,511) : name
}

/**
* The command line to submit this job
Expand Down
Expand Up @@ -25,6 +25,8 @@ import nextflow.processor.TaskConfig
import nextflow.processor.TaskProcessor
import nextflow.processor.TaskRun
import spock.lang.Specification
import spock.lang.Unroll

/**
*
* @author Paolo Di Tommaso <paolo.ditommaso@gmail.com>
Expand Down Expand Up @@ -699,4 +701,25 @@ class LsfExecutorTest extends Specification {
config.RESOURCE_RESERVE_PER_TASK == 'Y'
}

// Adapted from PbsExecutorTest.groovy
@Unroll
def 'should return valid job name given #name'() {
given:
def executor = [:] as LsfExecutor
def task = Mock(TaskRun)
task.getName() >> name

expect:
executor.getJobNameFor(task) == expected
executor.getJobNameFor(task).size() <= 4094

where:
name | expected
'hello' | 'nf-hello'
'12 45' | 'nf-12_45'
'hello[123]-[xyz]' | 'nf-hello123-xyz'
'a'.repeat(509) | 'nf-'.concat("a".repeat(508))
}

}

0 comments on commit 6e0ac72

Please sign in to comment.