File tree Expand file tree Collapse file tree 4 files changed +50
-2
lines changed
main/nextflow/cloud/azure
test/nextflow/cloud/azure/batch Expand file tree Collapse file tree 4 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -392,8 +392,8 @@ class AzBatchService implements Closeable {
392
392
throw new IllegalArgumentException (" Missing Azure Blob storage SAS token" )
393
393
394
394
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 \n You can disable this behaviour setting `azure.batch.requireContainer=false` in the nextflow config file " )
397
397
final taskId = " nf-${ task.hash.toString()} "
398
398
// get the pool config
399
399
final pool = getPoolSpec(poolId)
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ class AzBatchTaskHandler extends TaskHandler implements FusionAwareTask {
60
60
this . outputFile = task. workDir. resolve(TaskRun . CMD_OUTFILE )
61
61
this . errorFile = task. workDir. resolve(TaskRun . CMD_ERRFILE )
62
62
this . exitFile = task. workDir. resolve(TaskRun . CMD_EXIT )
63
+ validateConfiguration()
63
64
}
64
65
65
66
/* * only for testing purpose - DO NOT USE */
@@ -69,6 +70,12 @@ class AzBatchTaskHandler extends TaskHandler implements FusionAwareTask {
69
70
return executor. batchService
70
71
}
71
72
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
+
72
79
protected BashWrapperBuilder createBashWrapper () {
73
80
fusionEnabled()
74
81
? fusionLauncher()
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ class AzBatchOpts implements CloudTransferOptions {
54
54
Boolean deleteJobsOnCompletion
55
55
Boolean deletePoolsOnCompletion
56
56
Boolean deleteTasksOnCompletion
57
+ Boolean requireContainer
57
58
CopyToolInstallMode copyToolInstallMode
58
59
59
60
Map<String ,AzPoolOpts > pools
@@ -67,6 +68,7 @@ class AzBatchOpts implements CloudTransferOptions {
67
68
location = config. location
68
69
autoPoolMode = config. autoPoolMode
69
70
allowPoolCreation = config. allowPoolCreation
71
+ requireContainer = config. requireContainer ?: true
70
72
terminateJobsOnCompletion = config. terminateJobsOnCompletion != Boolean . FALSE
71
73
deleteJobsOnCompletion = config. deleteJobsOnCompletion
72
74
deletePoolsOnCompletion = config. deletePoolsOnCompletion
Original file line number Diff line number Diff line change @@ -18,6 +18,45 @@ import spock.lang.Specification
18
18
*/
19
19
class AzBatchTaskHandlerTest extends Specification {
20
20
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
+
21
60
def ' should submit task' () {
22
61
given :
23
62
def builder = Mock (BashWrapperBuilder )
You can’t perform that action at this time.
0 commit comments