Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wave cli v1alpha2 #4906

Merged
merged 6 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ class TestHelper {
file.text
}

static String decodeBase64(String encoded) {
byte[] decodedBytes = Base64.getDecoder().decode(encoded);
// Convert the decoded bytes into a string
return new String(decodedBytes);
}
}
5 changes: 3 additions & 2 deletions plugins/nf-wave/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ dependencies {
compileOnly project(':nextflow')
compileOnly 'org.slf4j:slf4j-api:2.0.7'
compileOnly 'org.pf4j:pf4j:3.10.0'
api 'org.apache.commons:commons-compress:1.21'
api 'org.apache.commons:commons-compress:1.26.1'
api 'org.apache.commons:commons-lang3:3.12.0'
api 'com.google.code.gson:gson:2.10.1'
api 'org.yaml:snakeyaml:2.2'
api 'io.seqera:wave-utils:0.8.1'
api 'io.seqera:wave-api:0.9.1'
api 'io.seqera:wave-utils:0.12.1'

testImplementation(testFixtures(project(":nextflow")))
testImplementation "org.apache.groovy:groovy:4.0.21"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ package io.seqera.wave.plugin
import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
import io.seqera.wave.api.PackagesSpec

/**
* Model a request for an augmented container
*
Expand Down Expand Up @@ -51,11 +53,6 @@ class SubmitContainerTokenRequest {
*/
String towerEndpoint

/**
* The ID of the workflow that submitted this container request
*/
String workflowId

/**
* Container image to be pulled
*/
Expand All @@ -74,11 +71,13 @@ class SubmitContainerTokenRequest {
/**
* Conda recipe file used to build the container
*/
@Deprecated
String condaFile

/**
* Spack recipe file used to build the container
*/
@Deprecated
String spackFile

/**
Expand Down Expand Up @@ -121,4 +120,19 @@ class SubmitContainerTokenRequest {
*/
Boolean dryRun

/**
* Id of compute workflow environment in tower
*/
String workflowId

/**
* One or more container should be included in upstream container request
*/
List<String> containerIncludes

/**
* Defines the packages to be included in this container request
*/
PackagesSpec packages

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ class SubmitContainerTokenResponse {
*/
String buildId

/**
* Whenever it's a cached build image. Only supported by API version v1alpha2
*/
Boolean cached

/**
* When the result is a freeze container. Version v1alpha2 as later.
*/
Boolean freeze;

}
34 changes: 16 additions & 18 deletions plugins/nf-wave/src/main/io/seqera/wave/plugin/WaveAssets.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@

package io.seqera.wave.plugin

import java.nio.file.Path

import groovy.transform.Canonical
import groovy.transform.CompileStatic
import groovy.transform.Memoized
import io.seqera.wave.api.PackagesSpec
import nextflow.script.bundle.ResourcesBundle
import nextflow.util.CacheHelper
import nextflow.util.StringUtils

/**
* Hold assets required to fulfill wave container image build
*
Expand All @@ -39,8 +38,7 @@ class WaveAssets {
final ResourcesBundle moduleResources
final ContainerConfig containerConfig
final String containerFile
final Path condaFile
final Path spackFile
final PackagesSpec packagesSpec
final ResourcesBundle projectResources
final boolean singularity

Expand All @@ -58,32 +56,32 @@ class WaveAssets {
: null
}

String condaFileEncoded() {
return condaFile
? condaFile.text.bytes.encodeBase64()
: null
}

String spackFileEncoded() {
return spackFile
? spackFile.text.bytes.encodeBase64()
: null
}

@Memoized
String fingerprint() {
final allMeta = new ArrayList(10)
allMeta.add( this.containerImage )
allMeta.add( this.moduleResources?.fingerprint() )
allMeta.add( this.containerConfig?.fingerprint() )
allMeta.add( this.containerFile )
allMeta.add( this.condaFile?.text )
allMeta.add( this.spackFile?.text )
allMeta.add( this.packagesSpec ? fingerprint(this.packagesSpec) : null )
allMeta.add( this.projectResources?.fingerprint() )
allMeta.add( this.containerPlatform )
return CacheHelper.hasher(allMeta).hash().toString()
}

protected String fingerprint(PackagesSpec spec) {
final allMeta = new ArrayList(10)
allMeta.add( spec.type.toString() )
allMeta.add( spec.environment )
allMeta.add( spec.entries )
allMeta.add( spec.condaOpts?.mambaImage )
allMeta.add( spec.condaOpts?.commands )
allMeta.add( spec.condaOpts?.basePackages )
allMeta.add( spec.spackOpts?.commands )
allMeta.add( spec.spackOpts?.basePackages )
allMeta.add( spec.channels )
return CacheHelper.hasher(allMeta).hash().toString()
}

static void validateContainerName(String name) {
if( !name )
Expand Down