Skip to content

Commit 81f7cb7

Browse files
committed
Add support for Wave native build for singularity
Signed-off-by: Paolo Di Tommaso <[email protected]>
1 parent c30d521 commit 81f7cb7

21 files changed

+297
-1276
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ allprojects {
8282
mavenCentral()
8383
maven { url 'https://repo.eclipse.org/content/groups/releases' }
8484
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
85+
maven { url = "https://s3-eu-west-1.amazonaws.com/maven.seqera.io/releases" }
86+
maven { url = "https://s3-eu-west-1.amazonaws.com/maven.seqera.io/snapshots" }
8587
}
8688

8789
configurations {

modules/nextflow/src/main/groovy/nextflow/script/bundle/ResourcesBundle.groovy

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ class ResourcesBundle {
4545
private Path root
4646
private LinkedHashMap<String,Path> content = new LinkedHashMap<>(100)
4747
private Path dockerfile
48+
private Path singularityfile
4849
private MemoryUnit maxFileSize = MAX_FILE_SIZE
4950
private MemoryUnit maxBundleSize = MAX_BUNDLE_SIZE
5051
private String baseDirectory
5152

5253
ResourcesBundle(Path root) {
5354
this.root = root
54-
this.dockerfile = dockefile0(root.resolveSibling('Dockerfile'))
55+
this.dockerfile = pathIfExists0(root.resolveSibling('Dockerfile'))
56+
this.singularityfile = pathIfExists0(root.resolveSibling('Singularityfile'))
5557
}
5658

5759
ResourcesBundle withMaxFileSize(MemoryUnit mem) {
@@ -68,7 +70,7 @@ class ResourcesBundle {
6870

6971
Map<String,Path> content() { content }
7072

71-
static private Path dockefile0(Path path) {
73+
static private Path pathIfExists0(Path path) {
7274
return path?.exists() ? path : null
7375
}
7476

@@ -100,6 +102,10 @@ class ResourcesBundle {
100102
return dockerfile
101103
}
102104

105+
Path getSingularityfile() {
106+
return singularityfile
107+
}
108+
103109
Set<Path> getPaths() {
104110
return new HashSet<Path>(content.values())
105111
}
@@ -125,7 +131,7 @@ class ResourcesBundle {
125131
}
126132

127133
boolean asBoolean() {
128-
return content.size() || dockerfile
134+
return content.size() || dockerfile || singularityfile
129135
}
130136

131137
/**
@@ -189,6 +195,9 @@ class ResourcesBundle {
189195
if( dockerfile ) {
190196
allMeta.add(fileMeta(dockerfile.name, dockerfile))
191197
}
198+
if( singularityfile ) {
199+
allMeta.add(fileMeta(singularityfile.name, singularityfile))
200+
}
192201

193202
return CacheHelper.hasher(allMeta).hash().toString()
194203
}

modules/nextflow/src/test/groovy/nextflow/script/bundle/ResourcesBundleTest.groovy

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,31 @@ class ResourcesBundleTest extends Specification {
106106
then:
107107
bundle.fingerprint() == '7b2200ff24230f76cea22e5eb15b1701'
108108

109+
}
110+
111+
def 'should get singularityfile' () {
112+
given:
113+
def singularPath = folder.resolve('Singularityfile'); singularPath.text = "I'm the main file"
114+
def bundlePath = folder.resolve('bundle')
115+
and:
116+
singularPath.setLastModified(LAST_MODIFIED)
117+
singularPath.setPermissions(6,4,4)
109118
when:
110-
// changing the last modified time, change the fingerprint
111-
dockerPath.setLastModified(LAST_MODIFIED +100)
119+
def bundle = ResourcesBundle.scan(bundlePath)
112120
then:
113-
bundle.fingerprint() == '7b2200ff24230f76cea22e5eb15b1701'
114-
121+
bundle.getSingularityfile() == singularPath
122+
and:
123+
bundle
124+
!bundle.hasEntries()
125+
and:
126+
bundle.fingerprint() == '6933e9238f3363c8e013a35715fa0540'
127+
128+
when:
129+
// changing file permissions, change the fingerprint
130+
singularPath.setPermissions(6,0,0)
131+
then:
132+
bundle.fingerprint() == '3ffe7f16cd5ae17e6ba7485e01972b20'
133+
115134
}
116135

117136
def 'should check max file size'() {

plugins/nf-wave/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ dependencies {
3636
api 'org.apache.commons:commons-lang3:3.12.0'
3737
api 'com.google.code.gson:gson:2.10.1'
3838
api 'org.yaml:snakeyaml:2.0'
39+
api 'io.seqera:wave-api:0.4.0'
40+
api 'io.seqera:wave-utils:0.6.2'
3941

4042
testImplementation(testFixtures(project(":nextflow")))
4143
testImplementation "org.codehaus.groovy:groovy:3.0.18"

plugins/nf-wave/src/main/io/seqera/wave/config/CondaOpts.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

plugins/nf-wave/src/main/io/seqera/wave/config/SpackOpts.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

plugins/nf-wave/src/main/io/seqera/wave/plugin/SubmitContainerTokenRequest.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,9 @@ class SubmitContainerTokenRequest {
111111
*/
112112
boolean freeze
113113

114+
/**
115+
* Specify the format of the container file
116+
*/
117+
String format
118+
114119
}

plugins/nf-wave/src/main/io/seqera/wave/plugin/WaveAssets.groovy

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ class WaveAssets {
3636
final String containerPlatform
3737
final ResourcesBundle moduleResources
3838
final ContainerConfig containerConfig
39-
final String dockerFileContent
39+
final String containerFile
4040
final Path condaFile
4141
final Path spackFile
4242
final ResourcesBundle projectResources
43+
final boolean singularity
4344

4445
static fromImage(String containerImage,String containerPlatform=null) {
4546
new WaveAssets(containerImage, containerPlatform)
@@ -50,8 +51,8 @@ class WaveAssets {
5051
}
5152

5253
String dockerFileEncoded() {
53-
return dockerFileContent
54-
? dockerFileContent.bytes.encodeBase64()
54+
return containerFile
55+
? containerFile.bytes.encodeBase64()
5556
: null
5657
}
5758

@@ -73,7 +74,7 @@ class WaveAssets {
7374
allMeta.add( this.containerImage )
7475
allMeta.add( this.moduleResources?.fingerprint() )
7576
allMeta.add( this.containerConfig?.fingerprint() )
76-
allMeta.add( this.dockerFileContent )
77+
allMeta.add( this.containerFile )
7778
allMeta.add( this.condaFile?.text )
7879
allMeta.add( this.spackFile?.text )
7980
allMeta.add( this.projectResources?.fingerprint() )

0 commit comments

Comments
 (0)