Skip to content

Commit

Permalink
Add support for Wave native build for singularity
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Aug 20, 2023
1 parent c30d521 commit 8a43489
Show file tree
Hide file tree
Showing 21 changed files with 296 additions and 1,276 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ allprojects {
mavenCentral()
maven { url 'https://repo.eclipse.org/content/groups/releases' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url = "https://s3-eu-west-1.amazonaws.com/maven.seqera.io/releases" }
maven { url = "https://s3-eu-west-1.amazonaws.com/maven.seqera.io/snapshots" }
}

configurations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ class ResourcesBundle {
private Path root
private LinkedHashMap<String,Path> content = new LinkedHashMap<>(100)
private Path dockerfile
private Path singularityfile
private MemoryUnit maxFileSize = MAX_FILE_SIZE
private MemoryUnit maxBundleSize = MAX_BUNDLE_SIZE
private String baseDirectory

ResourcesBundle(Path root) {
this.root = root
this.dockerfile = dockefile0(root.resolveSibling('Dockerfile'))
this.dockerfile = pathIfExists0(root.resolveSibling('Dockerfile'))
this.singularityfile = pathIfExists0(root.resolveSibling('Singularityfile'))
}

ResourcesBundle withMaxFileSize(MemoryUnit mem) {
Expand All @@ -68,7 +70,7 @@ class ResourcesBundle {

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

static private Path dockefile0(Path path) {
static private Path pathIfExists0(Path path) {
return path?.exists() ? path : null
}

Expand Down Expand Up @@ -100,6 +102,10 @@ class ResourcesBundle {
return dockerfile
}

Path getSingularityfile() {
return singularityfile
}

Set<Path> getPaths() {
return new HashSet<Path>(content.values())
}
Expand All @@ -125,7 +131,7 @@ class ResourcesBundle {
}

boolean asBoolean() {
return content.size() || dockerfile
return content.size() || dockerfile || singularityfile
}

/**
Expand Down Expand Up @@ -189,6 +195,9 @@ class ResourcesBundle {
if( dockerfile ) {
allMeta.add(fileMeta(dockerfile.name, dockerfile))
}
if( singularityfile ) {
allMeta.add(fileMeta(singularityfile.name, singularityfile))
}

return CacheHelper.hasher(allMeta).hash().toString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,31 @@ class ResourcesBundleTest extends Specification {
then:
bundle.fingerprint() == '7b2200ff24230f76cea22e5eb15b1701'

}

def 'should get singularityfile' () {
given:
def singularPath = folder.resolve('Singularityfile'); singularPath.text = "I'm the main file"
def bundlePath = folder.resolve('bundle')
and:
singularPath.setLastModified(LAST_MODIFIED)
singularPath.setPermissions(6,4,4)
when:
// changing the last modified time, change the fingerprint
dockerPath.setLastModified(LAST_MODIFIED +100)
def bundle = ResourcesBundle.scan(bundlePath)
then:
bundle.fingerprint() == '7b2200ff24230f76cea22e5eb15b1701'

bundle.getSingularityfile() == singularPath
and:
bundle
!bundle.hasEntries()
and:
bundle.fingerprint() == '6933e9238f3363c8e013a35715fa0540'

when:
// changing file permissions, change the fingerprint
singularPath.setPermissions(6,0,0)
then:
bundle.fingerprint() == '3ffe7f16cd5ae17e6ba7485e01972b20'

}

def 'should check max file size'() {
Expand Down
1 change: 1 addition & 0 deletions plugins/nf-wave/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
api 'org.apache.commons:commons-lang3:3.12.0'
api 'com.google.code.gson:gson:2.10.1'
api 'org.yaml:snakeyaml:2.0'
api 'io.seqera:wave-utils:0.6.2'

testImplementation(testFixtures(project(":nextflow")))
testImplementation "org.codehaus.groovy:groovy:3.0.18"
Expand Down
41 changes: 0 additions & 41 deletions plugins/nf-wave/src/main/io/seqera/wave/config/CondaOpts.java

This file was deleted.

48 changes: 0 additions & 48 deletions plugins/nf-wave/src/main/io/seqera/wave/config/SpackOpts.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,9 @@ class SubmitContainerTokenRequest {
*/
boolean freeze

/**
* Specify the format of the container file
*/
String format

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ class WaveAssets {
final String containerPlatform
final ResourcesBundle moduleResources
final ContainerConfig containerConfig
final String dockerFileContent
final String containerFile
final Path condaFile
final Path spackFile
final ResourcesBundle projectResources
final boolean singularity

static fromImage(String containerImage,String containerPlatform=null) {
new WaveAssets(containerImage, containerPlatform)
Expand All @@ -50,8 +51,8 @@ class WaveAssets {
}

String dockerFileEncoded() {
return dockerFileContent
? dockerFileContent.bytes.encodeBase64()
return containerFile
? containerFile.bytes.encodeBase64()
: null
}

Expand All @@ -73,7 +74,7 @@ class WaveAssets {
allMeta.add( this.containerImage )
allMeta.add( this.moduleResources?.fingerprint() )
allMeta.add( this.containerConfig?.fingerprint() )
allMeta.add( this.dockerFileContent )
allMeta.add( this.containerFile )
allMeta.add( this.condaFile?.text )
allMeta.add( this.spackFile?.text )
allMeta.add( this.projectResources?.fingerprint() )
Expand Down
Loading

0 comments on commit 8a43489

Please sign in to comment.