Skip to content

Commit ccdd519

Browse files
edmundmillerclaude
andcommitted
feat: Add Wave integration for unified package management
Extends Wave client to support the new package directive: - WaveClient: Adds support for 'package' attribute in container resolution, with automatic conversion from PackageSpec to Wave's PackagesSpec format - convertToWavePackagesSpec(): Maps unified package specs to Wave-compatible format - mapProviderToWaveType(): Maps package providers to Wave types This enables seamless container building with the new package directive while maintaining existing conda functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Edmund Miller <[email protected]>
1 parent 36161d5 commit ccdd519

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ class WaveClient {
493493
def attrs = new HashMap<String,String>()
494494
attrs.container = containerImage
495495
attrs.conda = task.config.conda as String
496+
attrs.package = task.config.package
496497
if( bundle!=null && bundle.dockerfile ) {
497498
attrs.dockerfile = bundle.dockerfile.text
498499
}
@@ -556,6 +557,33 @@ class WaveClient {
556557
}
557558
}
558559

560+
/*
561+
* If 'package' directive is specified use it to create a container file
562+
* to assemble the target container
563+
*/
564+
if( attrs.package && !packagesSpec ) {
565+
import nextflow.packages.PackageManager
566+
import nextflow.packages.PackageSpec
567+
568+
if( containerScript )
569+
throw new IllegalArgumentException("Unexpected package and $scriptType conflict while resolving wave container")
570+
571+
// Check if new package system is enabled
572+
if( PackageManager.isEnabled(session) ) {
573+
try {
574+
def defaultProvider = session.config.navigate('packages.provider', 'conda') as String
575+
PackageSpec spec = PackageManager.parseSpec(attrs.package, defaultProvider)
576+
577+
if( spec ) {
578+
packagesSpec = convertToWavePackagesSpec(spec)
579+
}
580+
}
581+
catch( Exception e ) {
582+
log.warn "Failed to parse package specification for Wave: ${e.message}"
583+
}
584+
}
585+
}
586+
559587
/*
560588
* The process should declare at least a container image name via 'container' directive
561589
* or a dockerfile file to build, otherwise there's no job to be done by wave
@@ -853,4 +881,56 @@ class WaveClient {
853881
throw e.cause
854882
}
855883
}
884+
885+
/**
886+
* Convert a Nextflow PackageSpec to Wave PackagesSpec
887+
*/
888+
private PackagesSpec convertToWavePackagesSpec(nextflow.packages.PackageSpec spec) {
889+
def waveSpec = new PackagesSpec()
890+
891+
// Map provider to Wave PackagesSpec Type
892+
def waveType = mapProviderToWaveType(spec.provider)
893+
if (waveType) {
894+
waveSpec.withType(waveType)
895+
}
896+
897+
// Set entries or environment
898+
if (spec.hasEntries()) {
899+
waveSpec.withEntries(spec.entries)
900+
}
901+
902+
if (spec.hasEnvironmentFile()) {
903+
waveSpec.withEnvironment(spec.environment)
904+
}
905+
906+
// Set channels (conda-specific)
907+
if (spec.channels && !spec.channels.empty) {
908+
waveSpec.withChannels(spec.channels)
909+
}
910+
911+
// Set conda options if provider is conda
912+
if (spec.provider == 'conda' && config.condaOpts()) {
913+
waveSpec.withCondaOpts(config.condaOpts())
914+
}
915+
916+
return waveSpec
917+
}
918+
919+
/**
920+
* Map provider name to Wave PackagesSpec Type
921+
*/
922+
private PackagesSpec.Type mapProviderToWaveType(String provider) {
923+
switch (provider?.toLowerCase()) {
924+
case 'conda':
925+
case 'mamba':
926+
case 'micromamba':
927+
return PackagesSpec.Type.CONDA
928+
case 'pixi':
929+
// Wave doesn't support pixi yet, so we'll use conda for now
930+
return PackagesSpec.Type.CONDA
931+
default:
932+
log.warn "Unknown package provider for Wave: ${provider}, defaulting to CONDA"
933+
return PackagesSpec.Type.CONDA
934+
}
935+
}
856936
}

0 commit comments

Comments
 (0)