Skip to content

Commit ad07555

Browse files
committed
Can't run gradle on the train so I'm just gonna send it
Signed-off-by: adamrtalbot <[email protected]>
1 parent 7838c1e commit ad07555

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

plugins/nf-azure/src/main/nextflow/cloud/azure/batch/AzBatchService.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,8 @@ class AzBatchService implements Closeable {
392392
throw new IllegalArgumentException("Missing Azure Blob storage SAS token")
393393

394394
final container = task.getContainer()
395-
if( !container )
396-
log.warn "Missing container image for process: $task.name"
395+
if( !container && config.batch().requireContainer )
396+
throw new IllegalArgumentException("Missing container image for process: $task.name\nYou can disable this behaviour setting `azure.batch.requireContainer=false` in the nextflow config file")
397397
final taskId = "nf-${task.hash.toString()}"
398398
// get the pool config
399399
final pool = getPoolSpec(poolId)

plugins/nf-azure/src/main/nextflow/cloud/azure/batch/AzBatchTaskHandler.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class AzBatchTaskHandler extends TaskHandler implements FusionAwareTask {
6060
this.outputFile = task.workDir.resolve(TaskRun.CMD_OUTFILE)
6161
this.errorFile = task.workDir.resolve(TaskRun.CMD_ERRFILE)
6262
this.exitFile = task.workDir.resolve(TaskRun.CMD_EXIT)
63+
validateConfiguration()
6364
}
6465

6566
/** only for testing purpose - DO NOT USE */
@@ -69,6 +70,12 @@ class AzBatchTaskHandler extends TaskHandler implements FusionAwareTask {
6970
return executor.batchService
7071
}
7172

73+
void validateConfiguration() {
74+
if (!task.container && config.batch().requireContainer ) {
75+
throw new ProcessUnrecoverableException("No container image specified for process $task.name -- Either specify the container to use in the process definition or with 'process.container' value in your config. You can disable this behaviour setting `azure.batch.requireContainer=false` in the nextflow config file")
76+
}
77+
}
78+
7279
protected BashWrapperBuilder createBashWrapper() {
7380
fusionEnabled()
7481
? fusionLauncher()

plugins/nf-azure/src/main/nextflow/cloud/azure/config/AzBatchOpts.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class AzBatchOpts implements CloudTransferOptions {
5454
Boolean deleteJobsOnCompletion
5555
Boolean deletePoolsOnCompletion
5656
Boolean deleteTasksOnCompletion
57+
Boolean requireContainer
5758
CopyToolInstallMode copyToolInstallMode
5859

5960
Map<String,AzPoolOpts> pools
@@ -67,6 +68,7 @@ class AzBatchOpts implements CloudTransferOptions {
6768
location = config.location
6869
autoPoolMode = config.autoPoolMode
6970
allowPoolCreation = config.allowPoolCreation
71+
requireContainer = config.requireContainer ?: true
7072
terminateJobsOnCompletion = config.terminateJobsOnCompletion != Boolean.FALSE
7173
deleteJobsOnCompletion = config.deleteJobsOnCompletion
7274
deletePoolsOnCompletion = config.deletePoolsOnCompletion

plugins/nf-azure/src/test/nextflow/cloud/azure/batch/AzBatchTaskHandlerTest.groovy

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,45 @@ import spock.lang.Specification
1818
*/
1919
class AzBatchTaskHandlerTest extends Specification {
2020

21+
def 'should validate config' () {
22+
when:
23+
def task = Mock(TaskRun) { getName() >> 'foo'; }
24+
and:
25+
new AzBatchTaskHandler(task: task)
26+
.validateConfiguration()
27+
then:
28+
def e = thrown(ProcessUnrecoverableException)
29+
e.message.startsWith('No container image specified for process foo')
30+
31+
32+
when:
33+
task = Mock(TaskRun) { getName() >> 'foo'; getContainer() >> 'ubuntu' }
34+
and:
35+
new AzBatchTaskHandler(task: task)
36+
.validateConfiguration()
37+
then:
38+
noExceptionThrown()
39+
}
40+
41+
def 'should ignore missing container if disabled' () {
42+
when:
43+
def task = Mock(TaskRun) { getName() >> 'foo'; }
44+
and:
45+
new AzBatchTaskHandler(task: task, config: new AzConfig([batch: [requireContainer: false]]))
46+
.validateConfiguration()
47+
then:
48+
noExceptionThrown()
49+
50+
51+
when:
52+
task = Mock(TaskRun) { getName() >> 'foo'; getContainer() >> 'ubuntu' }
53+
and:
54+
new AzBatchTaskHandler(task: task)
55+
.validateConfiguration()
56+
then:
57+
noExceptionThrown()
58+
}
59+
2160
def 'should submit task' () {
2261
given:
2362
def builder = Mock(BashWrapperBuilder)

0 commit comments

Comments
 (0)