Skip to content

Commit e1d7e7f

Browse files
committed
allow for per-task driver variation [ci skip]
1 parent e97f337 commit e1d7e7f

3 files changed

Lines changed: 35 additions & 8 deletions

File tree

modules/nextflow/src/main/groovy/nextflow/executor/Executor.groovy

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,19 @@ abstract class Executor {
170170
return false
171171
}
172172

173+
/**
174+
* Task-aware variant of {@link #isContainerNative()}.
175+
* Executors that support per-task driver selection (e.g. mixed docker + HPC)
176+
* can override this to return different values per task.
177+
* Defaults to the task-agnostic {@link #isContainerNative()}.
178+
*
179+
* @param task The task being evaluated
180+
* @return {@code true} when the executor manages containers natively for this specific task
181+
*/
182+
boolean isContainerNative(TaskRun task) {
183+
return isContainerNative()
184+
}
185+
173186
/**
174187
* Determines which container engine settings in the nextflow config file
175188
* will be used by this executor e.g. {@code 'docker'}, {@code 'singularity'}, etc.
@@ -184,6 +197,19 @@ abstract class Executor {
184197
return null
185198
}
186199

200+
/**
201+
* Task-aware variant of {@link #containerConfigEngine()}.
202+
* Executors that support per-task driver selection can override this
203+
* to return different container engine configs per task.
204+
* Defaults to the task-agnostic {@link #containerConfigEngine()}.
205+
*
206+
* @param task The task being evaluated
207+
* @return The container engine name for this specific task, or null
208+
*/
209+
String containerConfigEngine(TaskRun task) {
210+
return containerConfigEngine()
211+
}
212+
187213
/**
188214
* @return {@code true} whenever the secrets handling is managed by the executing platform itself
189215
*/

modules/nextflow/src/main/groovy/nextflow/processor/TaskRun.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,13 +767,14 @@ class TaskRun implements Cloneable {
767767
// get the container engine expected to be used by this executor
768768
final sess = this.getProcessor().getSession()
769769
final exe = this.getProcessor().getExecutor()
770-
final eng = exe.containerConfigEngine()
770+
// use task-aware methods to allow per-task driver resolution
771+
final eng = exe.containerConfigEngine(this)
771772
// when 'eng' is null the setting for the current engine marked as 'enabled' will be used
772773
final result
773774
= sess.getContainerConfig(eng)
774775
?: new DockerConfig([:])
775776
// if a configuration is found is expected to enabled by default
776-
if( exe.isContainerNative() ) {
777+
if( exe.isContainerNative(this) ) {
777778
result.setEnabled(true)
778779
}
779780
return result
@@ -788,7 +789,7 @@ class TaskRun implements Cloneable {
788789
}
789790

790791
boolean isContainerNative() {
791-
return processor.executor?.isContainerNative() ?: false
792+
return processor.executor?.isContainerNative(this) ?: false
792793
}
793794

794795
boolean isArray() {

modules/nextflow/src/test/groovy/nextflow/processor/TaskRunTest.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ class TaskRunTest extends Specification {
575575
isNative = task.isContainerNative()
576576
then:
577577
1 * task.processor.getExecutor() >> executor
578-
1 * executor.isContainerNative() >> true
578+
1 * executor.isContainerNative(task) >> true
579579
isNative
580580
}
581581

@@ -843,8 +843,8 @@ class TaskRunTest extends Specification {
843843
when:
844844
def config = task.getContainerConfig()
845845
then:
846-
1 * executor.containerConfigEngine() >> null
847-
1 * executor.isContainerNative() >> false
846+
1 * executor.containerConfigEngine(task) >> null
847+
1 * executor.isContainerNative(task) >> false
848848
and:
849849
session.getContainerConfig(null) >> null
850850
and:
@@ -853,8 +853,8 @@ class TaskRunTest extends Specification {
853853
when:
854854
config = task.getContainerConfig()
855855
then:
856-
1 * executor.containerConfigEngine() >> null
857-
1 * executor.isContainerNative() >> false
856+
1 * executor.containerConfigEngine(task) >> null
857+
1 * executor.isContainerNative(task) >> false
858858
and:
859859
session.getContainerConfig(null) >> new PodmanConfig(registry:'xyz')
860860
and:

0 commit comments

Comments
 (0)