Skip to content

Commit 33cf281

Browse files
author
hpratt
committed
add local singularity image parameter
1 parent d6d11b8 commit 33cf281

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ plugins {
1313
}
1414

1515
group = "io.krews"
16-
version = "0.14.15"
16+
version = "0.15.0"
1717

1818
repositories {
1919
maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") }

src/main/kotlin/krews/config/BaseConfig.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package krews.config
22

3+
data class SingularityConfig (
4+
val localImage: String? = null
5+
)
6+
37
data class TaskConfig (
48
// Task level input parameters
59
val params: Map<String, Any> = mapOf(),
@@ -14,7 +18,9 @@ data class TaskConfig (
1418
// The number of tasks "executions" that will be run with the same job / vm.
1519
val grouping: Int = 1,
1620
// Docker image; defaults to one provided by task
17-
val dockerImage: String? = null
21+
val dockerImage: String? = null,
22+
// optional Singularity config
23+
val singularity: SingularityConfig? = null
1824
)
1925

2026
data class WorkflowConfig (

src/main/kotlin/krews/executor/bsub/BsubExecutor.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,11 @@ class BsubExecutor(private val workflowConfig: WorkflowConfig) : LocallyDirected
191191
bsubScript.append("export SINGULARITY_BIND=\"$binds\"\n")
192192

193193
// Add running the task to script
194-
val remoteImage = !taskRunContext.dockerImage.endsWith(".sif")
194+
val trueImage = taskConfig.singularity?.localImage ?: taskRunContext.dockerImage
195+
val remoteImage = !trueImage.endsWith(".sif")
195196
bsubScript.append("\n")
196197
bsubScript.append("# Run task command.\n")
197-
bsubScript.append("singularity exec --containall ${if (remoteImage) "docker://" else ""}${taskRunContext.dockerImage} $containerCommand")
198+
bsubScript.append("singularity exec --containall ${if (remoteImage) "docker://" else ""}${trueImage} $containerCommand")
198199
bsubScript.append("\n")
199200

200201
// Add copying output files into output dir to script

src/main/kotlin/krews/executor/slurm/SlurmExecutor.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,11 @@ class SlurmExecutor(private val workflowConfig: WorkflowConfig) : LocallyDirecte
195195
sbatchScript.append("export SINGULARITY_BIND=\"$binds\"\n")
196196

197197
// Add running the task to script
198+
val trueImage = taskConfig.singularity?.localImage ?: taskRunContext.dockerImage
199+
val remoteImage = !trueImage.endsWith(".sif")
198200
sbatchScript.append("\n")
199201
sbatchScript.append("# Run task command.\n")
200-
sbatchScript.append("singularity exec --containall docker://${taskRunContext.dockerImage} $containerCommand")
202+
sbatchScript.append("singularity exec --containall ${if (remoteImage) "docker://" else ""}${trueImage} $containerCommand")
201203
sbatchScript.append("\n")
202204

203205
// Add copying output files into output dir to script

0 commit comments

Comments
 (0)