diff --git a/modules/nextflow/src/main/groovy/nextflow/executor/LsfExecutor.groovy b/modules/nextflow/src/main/groovy/nextflow/executor/LsfExecutor.groovy index 51becbbb65..4f3b1cbeb2 100644 --- a/modules/nextflow/src/main/groovy/nextflow/executor/LsfExecutor.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/executor/LsfExecutor.groovy @@ -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 diff --git a/modules/nextflow/src/test/groovy/nextflow/executor/LsfExecutorTest.groovy b/modules/nextflow/src/test/groovy/nextflow/executor/LsfExecutorTest.groovy index eb60818c59..d7fae2fa77 100644 --- a/modules/nextflow/src/test/groovy/nextflow/executor/LsfExecutorTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/executor/LsfExecutorTest.groovy @@ -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 @@ -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)) + } + } +