Skip to content

Commit cc11597

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

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
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
@@ -102,10 +102,11 @@ class SeqeraTaskHandler extends TaskHandler implements FusionAwareTask {
102102
if( accelerator.type )
103103
resourceReq.acceleratorName(accelerator.type)
104104
}
105-
// build machine requirement merging config settings with task arch
105+
// build machine requirement merging config settings with task arch and snapshot settings
106106
final machineReq = MapperUtil.toMachineRequirement(
107107
executor.getSeqeraConfig().machineRequirement,
108-
task.getContainerPlatform()
108+
task.getContainerPlatform(),
109+
fusionConfig().snapshotsEnabled()
109110
)
110111
final schedTask = new Task()
111112
.name(task.lazyName())

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,32 @@ class MapperUtil {
5959
* @return the MachineRequirement API object, or null if no settings
6060
*/
6161
static MachineRequirement toMachineRequirement(MachineRequirementOpts opts, String taskArch) {
62+
return toMachineRequirement(opts, taskArch, false)
63+
}
64+
65+
/**
66+
* Maps MachineRequirementOpts to MachineRequirement API object, merging with task arch
67+
* and snapshot settings.
68+
*
69+
* @param opts the config options (can be null)
70+
* @param taskArch the task container platform/arch (can be null)
71+
* @param snapshotEnabled whether Fusion snapshots are enabled
72+
* @return the MachineRequirement API object, or null if no settings
73+
*/
74+
static MachineRequirement toMachineRequirement(MachineRequirementOpts opts, String taskArch, boolean snapshotEnabled) {
6275
final arch = taskArch ?: opts?.arch
6376
final provisioning = opts?.provisioning
6477
final maxSpotAttempts = opts?.maxSpotAttempts
6578
final machineFamilies = opts?.machineFamilies
6679
// return null if no settings
67-
if (!arch && !provisioning && !maxSpotAttempts && !machineFamilies)
80+
if (!arch && !provisioning && !maxSpotAttempts && !machineFamilies && !snapshotEnabled)
6881
return null
6982
new MachineRequirement()
7083
.arch(arch)
7184
.provisioning(toProvisioningModel(provisioning))
7285
.maxSpotAttempts(maxSpotAttempts)
7386
.machineFamilies(machineFamilies)
87+
.snapshotEnabled(snapshotEnabled ? Boolean.TRUE : null)
7488
}
7589

7690
/**

0 commit comments

Comments
 (0)