A key-value model for HPC resources in CEMC/CMA. Including models for:
- Slurm
Use go get
to install the latest version.
go get github.com/cemc-oper/hpc-model-go
The following example uses hpc-model-go
to extract job id and job owner from a squeue -o %all
query.
Create category list:
categoryList := slurm.QueryCategoryList{
QueryCategoryList: hpcmodel.QueryCategoryList{
CategoryList: []*hpcmodel.QueryCategory{
{
ID: "sinfo.partition",
DisplayName: "Partition",
Label: "PARTITION",
PropertyClass: "StringProperty",
PropertyCreateArguments: []string{},
RecordParserClass: "TokenRecordParser",
},
{
ID: "sinfo.avail",
DisplayName: "Avail",
Label: "AVAIL",
PropertyClass: "StringProperty",
PropertyCreateArguments: []string{},
RecordParserClass: "TokenRecordParser",
},
{
ID: "sinfo.nodes",
DisplayName: "Nodes(A/I/O/T)",
Label: "NODES(A/I/O/T)",
PropertyClass: "StringProperty",
PropertyCreateArguments: []string{},
RecordParserClass: "TokenRecordParser",
},
{
ID: "sinfo.cpus",
DisplayName: "CPUs(A/I/O/T)",
Label: "CPUS(A/I/O/T)",
PropertyClass: "StringProperty",
PropertyCreateArguments: []string{},
RecordParserClass: "TokenRecordParser",
},
},
},
}
Get squeue -o %all
output.
cmd := exec.Command("sinfo", params...)
//fmt.Println(cmd.Args)
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return nil, fmt.Errorf("command ran error: %v", err)
}
s := out.String()
lines := strings.Split(s, "\n")
Build model from category list.
model, err := slurm.BuildModel(lines, categoryList, " ")
model
contains data of all categories.
Use go test
to run all tests.
Copyright © 2019-2023, developers at cemc-oper.
hpc-model-go
is licensed under The MIT License.