-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jorge Aguilera <jorge@edn.es>
- Loading branch information
Showing
9 changed files
with
284 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
plugins/nf-nomad/src/main/nextflow/nomad/models/JobSpreads.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2023-, Stellenbosch University, South Africa | ||
* Copyright 2024, Evaluacion y Desarrollo de Negocios, Spain | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
package nextflow.nomad.models | ||
|
||
import org.apache.commons.lang3.tuple.Pair | ||
import org.apache.commons.lang3.tuple.Triple | ||
|
||
/** | ||
* Nomad Job Spread Spec | ||
* | ||
* @author Jorge Aguilera <jorge@edn.es> | ||
*/ | ||
|
||
class JobSpreads { | ||
|
||
private List<Triple<String, Integer, List<Pair<String, Integer>>>> raws= [] | ||
|
||
List<Triple<String, Integer, List<Pair<String, Integer>>>> getRaws() { | ||
return raws | ||
} | ||
|
||
JobSpreads setSpread(Map map){ | ||
spread(map) | ||
} | ||
|
||
JobSpreads spread(Map map){ | ||
if( map.containsKey("name") && map.containsKey("weight")){ | ||
def name = map.name as String | ||
def weight = map.weight as int | ||
def targets = [] as List<Pair> | ||
if( map.containsKey("targets") && map.targets instanceof Map){ | ||
(map.targets as Map).entrySet().each{entry-> | ||
def target = entry.key as String | ||
if( entry.value.toString().isNumber() ){ | ||
def targetW = entry.value as int | ||
targets.add( Pair.of(target, targetW)) | ||
} | ||
} | ||
} | ||
raws.add Triple.of(name, weight, targets) | ||
} | ||
this | ||
} | ||
|
||
void validate(){ | ||
|
||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
plugins/nf-nomad/src/main/nextflow/nomad/models/SpreadsBuilder.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package nextflow.nomad.models | ||
|
||
import groovy.transform.CompileStatic | ||
import io.nomadproject.client.model.Spread | ||
import io.nomadproject.client.model.SpreadTarget | ||
|
||
/** | ||
* Nomad Job Spread Spec Builder | ||
* | ||
* @author Jorge Aguilera <jorge@edn.es> | ||
*/ | ||
|
||
@CompileStatic | ||
class SpreadsBuilder { | ||
|
||
static List<Spread> spreadsSpecToList(JobSpreads spreads){ | ||
def ret = [] as List<Spread> | ||
|
||
spreads.raws.each{raw-> | ||
def targets = [] as List<SpreadTarget> | ||
raw.right.each { | ||
targets.add( new SpreadTarget(value: it.left, percent: it.right) ) | ||
} | ||
ret.add new Spread(attribute: raw.left, weight: raw.middle, spreadTarget: targets) | ||
} | ||
|
||
return ret | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env nextflow | ||
|
||
process sayHello { | ||
container 'ubuntu:20.04' | ||
|
||
input: | ||
val x | ||
output: | ||
stdout | ||
script: | ||
""" | ||
echo '$x world!' | ||
""" | ||
} | ||
|
||
workflow { | ||
Channel.of('Bonjour', 'Ciao', 'Hello', 'Hola') | sayHello | view | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
plugins { | ||
id "nf-nomad@${System.getenv("NOMAD_PLUGIN_VERSION") ?: "latest"}" | ||
} | ||
|
||
process { | ||
executor = "nomad" | ||
} | ||
|
||
nomad { | ||
|
||
client { | ||
address = "http://localhost:4646" | ||
} | ||
|
||
jobs { | ||
deleteOnCompletion = false | ||
volume = { type "host" name "scratchdir" } | ||
|
||
spreads = { | ||
spread = [ name:'node.datacenter', weight: 50 ] | ||
} | ||
} | ||
|
||
} | ||
|
||
profiles{ | ||
localnomad{ | ||
process { | ||
withName: sayHello { | ||
datacenters = ['test-datacenter', 'demo-datacenter'] | ||
spread = [ name:'node.datacenter', weight: 50, targets : ['us-east1':70, 'us-east2':30] ] | ||
} | ||
} | ||
} | ||
} |