Skip to content

Commit fc8c086

Browse files
committed
Add snapshots support to nf-seqera
Signed-off-by: Lorenzo Fontana <fontanalorenz@gmail.com>
1 parent de4bab1 commit fc8c086

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

plugins/nf-seqera/src/main/io/seqera/executor/SeqeraTaskHandler.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,12 @@ class SeqeraTaskHandler extends TaskHandler implements FusionAwareTask {
103103
if( accelerator.type )
104104
resourceReq.acceleratorName(accelerator.type)
105105
}
106-
// build machine requirement merging config settings with task arch and disk
106+
// build machine requirement merging config settings with task arch, disk, and snapshot settings
107107
final machineReq = MapperUtil.toMachineRequirement(
108108
executor.getSeqeraConfig().machineRequirement,
109109
task.getContainerPlatform(),
110-
task.config.getDisk()
110+
task.config.getDisk(),
111+
fusionConfig().snapshotsEnabled()
111112
)
112113
final schedTask = new Task()
113114
.name(task.lazyName())

plugins/nf-seqera/src/main/io/seqera/util/MapperUtil.groovy

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,35 @@ class MapperUtil {
7878
* @return the MachineRequirement API object, or null if no settings
7979
*/
8080
static MachineRequirement toMachineRequirement(MachineRequirementOpts opts, String taskArch) {
81-
return toMachineRequirement(opts, taskArch, null)
81+
return toMachineRequirement(opts, taskArch, null, false)
8282
}
8383

8484
/**
85-
* Maps MachineRequirementOpts to MachineRequirement API object, merging with task arch and disk.
85+
* Maps MachineRequirementOpts to MachineRequirement API object, merging with task arch, disk, and snapshots.
8686
* Task arch overrides config arch if specified.
8787
*
8888
* @param opts the config options (can be null)
8989
* @param taskArch the task container platform/arch (can be null)
9090
* @param diskSize the disk size from task config (can be null)
91+
* @param snapshotEnabled whether Fusion snapshots are enabled
9192
* @return the MachineRequirement API object, or null if no settings
9293
*/
93-
static MachineRequirement toMachineRequirement(MachineRequirementOpts opts, String taskArch, MemoryUnit diskSize) {
94+
static MachineRequirement toMachineRequirement(MachineRequirementOpts opts, String taskArch, MemoryUnit diskSize, boolean snapshotEnabled) {
9495
final arch = taskArch ?: opts?.arch
9596
final provisioning = opts?.provisioning
9697
final maxSpotAttempts = opts?.maxSpotAttempts
9798
final machineFamilies = opts?.machineFamilies
9899
final diskReq = toDiskRequirement(diskSize, opts)
99100
// return null if no settings
100-
if (!arch && !provisioning && !maxSpotAttempts && !machineFamilies && !diskReq)
101+
if (!arch && !provisioning && !maxSpotAttempts && !machineFamilies && !diskReq && !snapshotEnabled)
101102
return null
102103
new MachineRequirement()
103104
.arch(arch)
104105
.provisioning(toProvisioningModel(provisioning))
105106
.maxSpotAttempts(maxSpotAttempts)
106107
.machineFamilies(machineFamilies)
107108
.disk(diskReq)
109+
.snapshotEnabled(snapshotEnabled ? Boolean.TRUE : null)
108110
}
109111

110112
/**

0 commit comments

Comments
 (0)