Skip to content

Commit

Permalink
Wave does not support 'null' container engine
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso committed Sep 27, 2023
1 parent e4a878b commit f3eba3d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
17 changes: 12 additions & 5 deletions modules/nextflow/src/main/groovy/nextflow/Session.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1201,23 +1201,30 @@ class Session implements ISession {
return new ContainerConfig(result)
}

final enabled = allEngines.findAll { it.enabled?.toString() == 'true' }
final enabled = allEngines.findAll(it -> it.enabled?.toString() == 'true')
if( enabled.size() > 1 ) {
def names = enabled.collect { it.engine }
final names = enabled.collect(it -> it.engine)
throw new IllegalConfigException("Cannot enable more than one container engine -- Choose either one of: ${names.join(', ')}")
}

(enabled ? enabled.get(0) : ( allEngines ? allEngines.get(0) : [engine:'docker'] )) as ContainerConfig
if( enabled ) {
return new ContainerConfig(enabled.get(0))
}
if( allEngines ) {
return new ContainerConfig(allEngines.get(0))
}
return new ContainerConfig(engine:'docker')
}

ContainerConfig getContainerConfig() {
return getContainerConfig(null)
}

private void getContainerConfig0(String engine, List<Map> drivers) {
assert engine
final entry = this.config?.get(engine)
if( entry instanceof Map ) {
final config0 = new LinkedHashMap((Map)entry)
final config0 = new LinkedHashMap()
config0.putAll((Map)entry)
config0.put('engine', engine)
drivers.add(config0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ class WorkflowMetadata {
this.nextflow = NextflowMeta.instance
this.workDir = session.workDir
this.launchDir = Paths.get('.').complete()
this.profile = session.profile ?: ConfigBuilder.DEFAULT_PROFILE
this.profile = session.profile ?: ConfigBuilder.DEFAULT_PROFILE
this.sessionId = session.uniqueId
this.resume = session.resumeMode
this.stubRun = session.stubRun
this.runName = session.runName
this.containerEngine = session.containerConfig.with { isEnabled() ? getEngine() : null }
this.containerEngine = containerEngine0(session)
this.configFiles = session.configFiles?.collect { it.toAbsolutePath() }
this.stats = new WorkflowStats()
this.userName = System.getProperty('user.name')
Expand All @@ -252,6 +252,11 @@ class WorkflowMetadata {
session.onError( this.&invokeOnError )
}

private String containerEngine0(Session session) {
final config = session.getContainerConfig()
return config.isEnabled() ? config.getEngine() : null
}

/**
* Only for testing purpose -- do not use
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,23 @@ class WaveContainerResolver implements ContainerResolver {
return client0 = new WaveClient( Global.session as Session )
}

private String getContainerEngine0(TaskRun task) {
final config = task.getContainerConfig()
final result = config.getEngine()
if( result )
return result
// fallback to docker by default
log.warn "Missing engine in container config - offending value: $config"
return 'docker'
}

@Override
ContainerInfo resolveImage(TaskRun task, String imageName) {
if( !client().enabled() )
return defaultResolver.resolveImage(task, imageName)

final freeze = client().config().freezeMode()
final engine= task.getContainerConfig().getEngine()
final engine = getContainerEngine0(task)
final nativeSingularityBuild = freeze && engine in SINGULARITY_LIKE
if( !imageName ) {
// when no image name is provided the module bundle should include a
Expand Down

0 comments on commit f3eba3d

Please sign in to comment.