- Notifications
You must be signed in to change notification settings - Fork2
A key-value model for HPC resources in CEMC
License
NotificationsYou must be signed in to change notification settings
cemc-oper/hpc-model-go
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A key-value model for HPC resources in CEMC/CMA.Including models for:
- Slurm
Usego get
to install the latest version.
go get github.com/cemc-oper/hpc-model-go
The following example useshpc-model-go
to extract job id and job owner from asqueue -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", }, }, },}
Getsqueue -o %all
output.
cmd:=exec.Command("sinfo",params...)//fmt.Println(cmd.Args)varout bytes.Buffercmd.Stdout=&outerr:=cmd.Run()iferr!=nil {returnnil,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.
Usego test
to run all tests.
Copyright © 2019-2023, developers at cemc-oper.
hpc-model-go
is licensed underThe MIT License.