-
Notifications
You must be signed in to change notification settings - Fork 3
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 <[email protected]>
- Loading branch information
Showing
7 changed files
with
408 additions
and
124 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
plugins/nf-nomad/src/main/nextflow/nomad/config/ConstraintAttrSpec.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,38 @@ | ||
package nextflow.nomad.config | ||
|
||
class ConstraintAttrSpec { | ||
|
||
private String arch = null | ||
private Integer numcores= null | ||
private Integer reservablecores= null | ||
private Double totalcompute= null | ||
|
||
String getArch() { | ||
return arch | ||
} | ||
|
||
Integer getNumcores() { | ||
return numcores | ||
} | ||
|
||
Integer getReservablecores() { | ||
return reservablecores | ||
} | ||
|
||
Double getTotalcompute() { | ||
return totalcompute | ||
} | ||
|
||
ConstraintAttrSpec setCpu(Map map){ | ||
cpu(map) | ||
} | ||
|
||
ConstraintAttrSpec cpu(Map map){ | ||
this.arch = map.containsKey("arch") ? map["arch"].toString() : null | ||
this.numcores = map.containsKey("numcores") ? map["numcores"] as int : null | ||
this.reservablecores = map.containsKey("reservablecores") ? map["reservablecores"] as int : null | ||
this.totalcompute = map.containsKey("totalcompute") ? map["totalcompute"] as double : null | ||
this | ||
} | ||
|
||
} |
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
97 changes: 97 additions & 0 deletions
97
plugins/nf-nomad/src/main/nextflow/nomad/executor/ConstraintsBuilder.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,97 @@ | ||
package nextflow.nomad.executor | ||
|
||
import io.nomadproject.client.model.Constraint | ||
import nextflow.nomad.config.ConstraintAttrSpec | ||
import nextflow.nomad.config.ConstraintNodeSpec | ||
import nextflow.nomad.config.ConstraintsSpec | ||
|
||
class ConstraintsBuilder { | ||
|
||
protected static List<Constraint> constraintsSpecToList(ConstraintsSpec spec){ | ||
def constraints = [] as List<Constraint> | ||
if( spec?.nodeSpecs ){ | ||
def nodes = spec.nodeSpecs | ||
?.collect({ nodeConstraints(it)}) | ||
?.flatten() as List<Constraint> | ||
constraints.addAll(nodes) | ||
} | ||
if( spec?.attrSpecs ){ | ||
def nodes = spec.attrSpecs | ||
?.collect({ attrConstraints(it)}) | ||
?.flatten() as List<Constraint> | ||
constraints.addAll(nodes) | ||
} | ||
return constraints | ||
} | ||
|
||
protected static List<Constraint> nodeConstraints(ConstraintNodeSpec nodeSpec){ | ||
def ret = [] as List<Constraint> | ||
if( nodeSpec.id ){ | ||
ret.add new Constraint() | ||
.ltarget('${node.unique.id}') | ||
.operand("=") | ||
.rtarget(nodeSpec.id) | ||
} | ||
if( nodeSpec.name ){ | ||
ret.add new Constraint() | ||
.ltarget('${node.unique.name}') | ||
.operand("=") | ||
.rtarget(nodeSpec.name) | ||
} | ||
if( nodeSpec.clientClass ){ | ||
ret.add new Constraint() | ||
.ltarget('${node.class}') | ||
.operand("=") | ||
.rtarget(nodeSpec.clientClass) | ||
} | ||
if( nodeSpec.dataCenter ){ | ||
ret.add new Constraint() | ||
.ltarget('${node.datacenter}') | ||
.operand("=") | ||
.rtarget(nodeSpec.dataCenter) | ||
} | ||
if( nodeSpec.region ){ | ||
ret.add new Constraint() | ||
.ltarget('${node.region}') | ||
.operand("=") | ||
.rtarget(nodeSpec.region) | ||
} | ||
if( nodeSpec.pool ){ | ||
ret.add new Constraint() | ||
.ltarget('${node.pool}') | ||
.operand("=") | ||
.rtarget(nodeSpec.pool) | ||
} | ||
ret | ||
} | ||
|
||
protected static List<Constraint> attrConstraints(ConstraintAttrSpec nodeSpec) { | ||
def ret = [] as List<Constraint> | ||
if (nodeSpec.arch) { | ||
ret.add new Constraint() | ||
.ltarget('${attr.cpu.arch}') | ||
.operand("=") | ||
.rtarget(nodeSpec.arch) | ||
} | ||
if (nodeSpec.numcores) { | ||
ret.add new Constraint() | ||
.ltarget('${attr.cpu.numcores}') | ||
.operand("=") | ||
.rtarget("$nodeSpec.numcores") | ||
} | ||
if (nodeSpec.reservablecores) { | ||
ret.add new Constraint() | ||
.ltarget('${attr.cpu.reservablecores}') | ||
.operand("=") | ||
.rtarget("$nodeSpec.reservablecores") | ||
} | ||
if (nodeSpec.totalcompute) { | ||
ret.add new Constraint() | ||
.ltarget('${attr.cpu.totalcompute}') | ||
.operand("=") | ||
.rtarget("$nodeSpec.totalcompute") | ||
} | ||
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
Oops, something went wrong.