Skip to content

Commit

Permalink
add local singularity image parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
hpratt committed Oct 23, 2023
1 parent d6d11b8 commit 33cf281
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {
}

group = "io.krews"
version = "0.14.15"
version = "0.15.0"

repositories {
maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") }
Expand Down
8 changes: 7 additions & 1 deletion src/main/kotlin/krews/config/BaseConfig.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package krews.config

data class SingularityConfig (
val localImage: String? = null
)

data class TaskConfig (
// Task level input parameters
val params: Map<String, Any> = mapOf(),
Expand All @@ -14,7 +18,9 @@ data class TaskConfig (
// The number of tasks "executions" that will be run with the same job / vm.
val grouping: Int = 1,
// Docker image; defaults to one provided by task
val dockerImage: String? = null
val dockerImage: String? = null,
// optional Singularity config
val singularity: SingularityConfig? = null
)

data class WorkflowConfig (
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/krews/executor/bsub/BsubExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,11 @@ class BsubExecutor(private val workflowConfig: WorkflowConfig) : LocallyDirected
bsubScript.append("export SINGULARITY_BIND=\"$binds\"\n")

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

// Add copying output files into output dir to script
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/krews/executor/slurm/SlurmExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ class SlurmExecutor(private val workflowConfig: WorkflowConfig) : LocallyDirecte
sbatchScript.append("export SINGULARITY_BIND=\"$binds\"\n")

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

// Add copying output files into output dir to script
Expand Down

0 comments on commit 33cf281

Please sign in to comment.