schema

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 15 Imported by: 2

Documentation

Overview

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	MonitoringStatusDisabled            int32 = 0
	MonitoringStatusRunningOrArchiving  int32 = 1
	MonitoringStatusArchivingFailed     int32 = 2
	MonitoringStatusArchivingSuccessful int32 = 3
)

Variables

This section is empty.

Functions

func ConvertFloatToFloat64

func ConvertFloatToFloat64(s []Float) []float64

func GetRoleString

func GetRoleString(roleInt Role) string

func GetValidRoles

func GetValidRoles(user *User) ([]string, error)

Called by API endpoint '/roles/' from frontend: Only required for admin config -> Check Admin Role

func GetValidRolesMap

func GetValidRolesMap(user *User) (map[string]Role, error)

Called by routerConfig web.page setup in backend: Only requires known user

func IsValidRole

func IsValidRole(role string) bool

func Validate

func Validate(k Kind, r io.Reader) error

Types

type Accelerator

type Accelerator struct {
	ID    string `json:"id"`
	Type  string `json:"type"`
	Model string `json:"model"`
}

type AuthSource

type AuthSource int
const (
	AuthViaLocalPassword AuthSource = iota
	AuthViaLDAP
	AuthViaToken
	AuthViaOIDC
	AuthViaAll
)

type AuthType

type AuthType int
const (
	AuthToken AuthType = iota
	AuthSession
)

type Cluster

type Cluster struct {
	Name         string          `json:"name"`
	MetricConfig []*MetricConfig `json:"metricConfig"`
	SubClusters  []*SubCluster   `json:"subClusters"`
}

type ClusterSupport

type ClusterSupport struct {
	Cluster     string   `json:"cluster"`
	SubClusters []string `json:"subclusters"`
}

type Float

type Float float64

A custom float type is used so that (Un)MarshalJSON and (Un)MarshalGQL can be overloaded and NaN/null can be used. The default behaviour of putting every nullable value behind a pointer has a bigger overhead.

var (
	NaN Float = Float(math.NaN())
)

func ConvertToFloat added in v0.8.0

func ConvertToFloat(input float64) Float

func GetFloat64ToFloat

func GetFloat64ToFloat(s []float64) []Float

func (Float) Double added in v0.8.0

func (f Float) Double() float64

func (Float) IsNaN

func (f Float) IsNaN() bool

func (Float) MarshalGQL

func (f Float) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface. NaN will be serialized to `null`.

func (Float) MarshalJSON

func (f Float) MarshalJSON() ([]byte, error)

NaN will be serialized to `null`.

func (*Float) UnmarshalGQL

func (f *Float) UnmarshalGQL(v any) error

UnmarshalGQL implements the graphql.Unmarshaler interface.

func (*Float) UnmarshalJSON

func (f *Float) UnmarshalJSON(input []byte) error

`null` will be unserialized to NaN.

type FloatArray added in v0.8.0

type FloatArray []Float

Same as `[]Float`, but can be marshaled to JSON with less allocations.

type GlobalMetricListItem

type GlobalMetricListItem struct {
	Name         string           `json:"name"`
	Unit         Unit             `json:"unit"`
	Scope        MetricScope      `json:"scope"`
	Footprint    string           `json:"footprint,omitempty"`
	Availability []ClusterSupport `json:"availability"`
}

type Job

type Job struct {
	Cluster            string                   `json:"cluster" db:"hpc_cluster" example:"fritz"`
	SubCluster         string                   `json:"subCluster" db:"subcluster" example:"main"`
	Partition          string                   `json:"partition,omitempty" db:"cluster_partition" example:"main"`
	Project            string                   `json:"project" db:"project" example:"abcd200"`
	User               string                   `json:"user" db:"hpc_user" example:"abcd100h"`
	Shared             string                   `json:"shared" db:"shared" enums:"none,single_user,multi_user"`
	State              JobState                 `` /* 172-byte string literal not displayed */
	Tags               []*Tag                   `json:"tags,omitempty"`
	RawEnergyFootprint []byte                   `json:"-" db:"energy_footprint"`
	RawFootprint       []byte                   `json:"-" db:"footprint"`
	RawMetaData        []byte                   `json:"-" db:"meta_data"`
	RawResources       []byte                   `json:"-" db:"resources"`
	Resources          []*Resource              `json:"resources"`
	EnergyFootprint    map[string]float64       `json:"energyFootprint"`
	Footprint          map[string]float64       `json:"footprint"`
	MetaData           map[string]string        `json:"metaData"`
	ConcurrentJobs     JobLinkResultList        `json:"concurrentJobs"`
	Energy             float64                  `json:"energy" db:"energy"`
	ArrayJobId         int64                    `json:"arrayJobId,omitempty" db:"array_job_id" example:"123000"`
	Walltime           int64                    `json:"walltime,omitempty" db:"walltime" example:"86400" minimum:"1"`
	RequestedMemory    int64                    `json:"requestedMemory,omitempty" db:"requested_memory" example:"128000" minimum:"1"` // in MB
	JobID              int64                    `json:"jobId" db:"job_id" example:"123000"`
	Duration           int32                    `json:"duration" db:"duration" example:"43200" minimum:"1"`
	SMT                int32                    `json:"smt,omitempty" db:"smt" example:"4"`
	MonitoringStatus   int32                    `json:"monitoringStatus,omitempty" db:"monitoring_status" example:"1" minimum:"0" maximum:"3"`
	NumAcc             int32                    `json:"numAcc,omitempty" db:"num_acc" example:"2" minimum:"1"`
	NumHWThreads       int32                    `json:"numHwthreads,omitempty" db:"num_hwthreads" example:"20" minimum:"1"`
	NumNodes           int32                    `json:"numNodes" db:"num_nodes" example:"2" minimum:"1"`
	Statistics         map[string]JobStatistics `json:"statistics"`
	ID                 *int64                   `json:"id,omitempty" db:"id"`
	SubmitTime         int64                    `json:"submitTime,omitempty" db:"submit_time" example:"1649723812"`
	StartTime          int64                    `json:"startTime" db:"start_time" example:"1649723812"`
}

func (Job) GoString added in v0.3.0

func (j Job) GoString() string

type JobData

type JobData map[string]map[MetricScope]*JobMetric

func (*JobData) AddNodeScope

func (jd *JobData) AddNodeScope(metric string) bool

func (*JobData) RoundMetricStats added in v0.3.0

func (jd *JobData) RoundMetricStats()

func (*JobData) Size

func (jd *JobData) Size() int
type JobLink struct {
	ID    int64 `json:"id"`
	JobID int64 `json:"jobId"`
}

type JobLinkResultList

type JobLinkResultList struct {
	Items []*JobLink `json:"items"`
	Count int        `json:"count"`
}

type JobMetric

type JobMetric struct {
	StatisticsSeries *StatsSeries `json:"statisticsSeries,omitempty"`
	Unit             Unit         `json:"unit"`
	Series           []Series     `json:"series"`
	Timestep         int          `json:"timestep"`
}

func (*JobMetric) AddPercentiles

func (jm *JobMetric) AddPercentiles(ps []int) bool

func (*JobMetric) AddStatisticsSeries

func (jm *JobMetric) AddStatisticsSeries()

type JobState

type JobState string
const (
	JobStateBootFail    JobState = "boot_fail"
	JobStateCancelled   JobState = "cancelled"
	JobStateCompleted   JobState = "completed"
	JobStateDeadline    JobState = "deadline"
	JobStateFailed      JobState = "failed"
	JobStateNodeFail    JobState = "node_fail"
	JobStateOutOfMemory JobState = "out_of_memory"
	JobStatePending     JobState = "pending"
	JobStatePreempted   JobState = "preempted"
	JobStateRunning     JobState = "running"
	JobStateSuspended   JobState = "suspended"
	JobStateTimeout     JobState = "timeout"
)

func (JobState) MarshalGQL

func (e JobState) MarshalGQL(w io.Writer)

func (*JobState) UnmarshalGQL

func (e *JobState) UnmarshalGQL(v any) error

func (JobState) Valid

func (e JobState) Valid() bool

type JobStatistics

type JobStatistics struct {
	Unit Unit    `json:"unit"`
	Avg  float64 `json:"avg" example:"2500" minimum:"0"` // Job metric average
	Min  float64 `json:"min" example:"2000" minimum:"0"` // Job metric minimum
	Max  float64 `json:"max" example:"3000" minimum:"0"` // Job metric maximum
}

JobStatistics model @Description Specification for job metric statistics.

type Kind

type Kind int
const (
	Meta Kind = iota + 1
	Data
	ClusterCfg
)

type Metric added in v0.3.0

type Metric struct {
	Name    string  `json:"name"`
	Unit    Unit    `json:"unit"`
	Peak    float64 `json:"peak"`
	Normal  float64 `json:"normal"`
	Caution float64 `json:"caution"`
	Alert   float64 `json:"alert"`
}

type MetricConfig

type MetricConfig struct {
	Metric
	Energy        string              `json:"energy"`
	Scope         MetricScope         `json:"scope"`
	Aggregation   string              `json:"aggregation"`
	Footprint     string              `json:"footprint,omitempty"`
	SubClusters   []*SubClusterConfig `json:"subClusters,omitempty"`
	Timestep      int                 `json:"timestep"`
	LowerIsBetter bool                `json:"lowerIsBetter"`
}

type MetricScope

type MetricScope string
const (
	MetricScopeInvalid MetricScope = "invalid_scope"

	MetricScopeNode         MetricScope = "node"
	MetricScopeSocket       MetricScope = "socket"
	MetricScopeMemoryDomain MetricScope = "memoryDomain"
	MetricScopeCore         MetricScope = "core"
	MetricScopeHWThread     MetricScope = "hwthread"

	MetricScopeAccelerator MetricScope = "accelerator"
)

func (*MetricScope) LT

func (e *MetricScope) LT(other MetricScope) bool

func (*MetricScope) LTE

func (e *MetricScope) LTE(other MetricScope) bool

func (MetricScope) MarshalGQL

func (e MetricScope) MarshalGQL(w io.Writer)

func (*MetricScope) Max

func (e *MetricScope) Max(other MetricScope) MetricScope

func (*MetricScope) UnmarshalGQL

func (e *MetricScope) UnmarshalGQL(v any) error

func (MetricScope) Valid

func (e MetricScope) Valid() bool

type MetricStatistics

type MetricStatistics struct {
	Avg float64 `json:"avg"`
	Min float64 `json:"min"`
	Max float64 `json:"max"`
}

type MetricValue

type MetricValue struct {
	Unit  Unit    `json:"unit"`
	Value float64 `json:"value"`
}

type MonitoringState added in v0.3.0

type MonitoringState string
const (
	MonitoringStateFull    MonitoringState = "full"
	MonitoringStatePartial MonitoringState = "partial"
	MonitoringStateFailed  MonitoringState = "failed"
)

type Node added in v0.3.0

type Node struct {
	ID              int64             `json:"id" db:"id"`
	TimeStamp       int64             `json:"timeStamp" db:"time_stamp" example:"1649723812"`
	Hostname        string            `json:"hostname" db:"hostname" example:"fritz"`
	Cluster         string            `json:"cluster" db:"cluster" example:"fritz"`
	SubCluster      string            `json:"subCluster" db:"subcluster" example:"main"`
	NodeState       NodeState         `json:"nodeState" db:"node_state" example:"completed" enums:"completed,failed,cancelled,stopped,timeout,out_of_memory"`
	HealthState     MonitoringState   `json:"healthState" db:"health_state" example:"completed" enums:"completed,failed,cancelled,stopped,timeout,out_of_memory"`
	CpusAllocated   int               `json:"cpusAllocated" db:"cpus_allocated"`
	CpusTotal       int               `json:"cpusTotal" db:"cpus_total"`
	MemoryAllocated int               `json:"memoryAllocated" db:"memory_allocated"`
	MemoryTotal     int               `json:"memoryTotal" db:"memory_total"`
	GpusAllocated   int               `json:"gpusAllocated" db:"gpus_allocated"`
	GpusTotal       int               `json:"gpusTotal" db:"gpus_total"`
	JobsRunning     int64             `json:"jobsRunning" db:"jobs_running" example:"12"`
	RawMetaData     []byte            `json:"-" db:"meta_data"`
	MetaData        map[string]string `json:"metaData"`
}

type NodeState added in v0.3.0

type NodeState string
const (
	NodeStateAllocated NodeState = "allocated"
	NodeStateReserved  NodeState = "reserved"
	NodeStateIdle      NodeState = "idle"
	NodeStateMixed     NodeState = "mixed"
	NodeStateDown      NodeState = "down"
	NodeStateUnknown   NodeState = "unknown"
)

type Resource

type Resource struct {
	Hostname      string   `json:"hostname"`
	Configuration string   `json:"configuration,omitempty"`
	HWThreads     []int    `json:"hwthreads,omitempty"`
	Accelerators  []string `json:"accelerators,omitempty"`
}

Resource model @Description A resource used by a job

type Role

type Role int
const (
	RoleAnonymous Role = iota
	RoleApi
	RoleUser
	RoleManager
	RoleSupport
	RoleAdmin
	RoleError
)

type ScopedJobStats added in v0.3.0

type ScopedJobStats map[string]map[MetricScope][]*ScopedStats

type ScopedStats added in v0.3.0

type ScopedStats struct {
	Hostname string            `json:"hostname"`
	Id       *string           `json:"id,omitempty"`
	Data     *MetricStatistics `json:"data"`
}

type Series

type Series struct {
	Id         *string          `json:"id,omitempty"`
	Hostname   string           `json:"hostname"`
	Data       []Float          `json:"data"`
	Statistics MetricStatistics `json:"statistics"`
}

func (*Series) MarshalJSON

func (s *Series) MarshalJSON() ([]byte, error)

Only used via REST-API, not via GraphQL. This uses a lot less allocations per series, but it turns out that the performance increase from using this is not that big.

type StatsSeries

type StatsSeries struct {
	Percentiles map[int][]Float `json:"percentiles,omitempty"`
	Mean        []Float         `json:"mean"`
	Median      []Float         `json:"median"`
	Min         []Float         `json:"min"`
	Max         []Float         `json:"max"`
}

type SubCluster

type SubCluster struct {
	Name            string         `json:"name"`
	Nodes           string         `json:"nodes"`
	ProcessorType   string         `json:"processorType"`
	Topology        Topology       `json:"topology"`
	FlopRateScalar  MetricValue    `json:"flopRateScalar"`
	FlopRateSimd    MetricValue    `json:"flopRateSimd"`
	MemoryBandwidth MetricValue    `json:"memoryBandwidth"`
	MetricConfig    []MetricConfig `json:"metricConfig,omitempty"`
	Footprint       []string       `json:"footprint,omitempty"`
	EnergyFootprint []string       `json:"energyFootprint,omitempty"`
	SocketsPerNode  int            `json:"socketsPerNode"`
	CoresPerSocket  int            `json:"coresPerSocket"`
	ThreadsPerCore  int            `json:"threadsPerCore"`
}

type SubClusterConfig

type SubClusterConfig struct {
	Metric
	Footprint     string `json:"footprint,omitempty"`
	Energy        string `json:"energy"`
	Remove        bool   `json:"remove"`
	LowerIsBetter bool   `json:"lowerIsBetter"`
}

type Tag

type Tag struct {
	Type  string `json:"type" db:"tag_type" example:"Debug"`
	Name  string `json:"name" db:"tag_name" example:"Testjob"`
	Scope string `json:"scope" db:"tag_scope" example:"global"`
	ID    int64  `json:"id" db:"id"`
}

Tag model @Description Defines a tag using name and type.

type Topology

type Topology struct {
	Node         []int          `json:"node"`
	Socket       [][]int        `json:"socket"`
	MemoryDomain [][]int        `json:"memoryDomain"`
	Die          [][]*int       `json:"die,omitempty"`
	Core         [][]int        `json:"core"`
	Accelerators []*Accelerator `json:"accelerators,omitempty"`
}

func (*Topology) GetAcceleratorID

func (topo *Topology) GetAcceleratorID(id int) (string, error)

Temporary fix to convert back from int id to string id for accelerators

func (*Topology) GetAcceleratorIDs

func (topo *Topology) GetAcceleratorIDs() []string

Return list of hardware (string) accelerator IDs

func (*Topology) GetAcceleratorIDsAsInt

func (topo *Topology) GetAcceleratorIDsAsInt() ([]int, error)

Outdated? Or: Return indices of accelerators in parent array?

func (*Topology) GetCoresFromHWThreads

func (topo *Topology) GetCoresFromHWThreads(
	hwthreads []int,
) (cores []int, exclusive bool)

Return a list of core IDs given a list of hwthread IDs. Even if just one hwthread is in that core, add it to the list. If no hwthreads other than those in the argument list are assigned to one of the cores in the first return value, return true as the second value. TODO: Optimize this, there must be a more efficient way/algorithm.

func (*Topology) GetMemoryDomainsFromHWThreads

func (topo *Topology) GetMemoryDomainsFromHWThreads(
	hwthreads []int,
) (memDoms []int, exclusive bool)

Return a list of memory domain IDs given a list of hwthread IDs. Even if just one hwthread is in that memory domain, add it to the list. If no hwthreads other than those in the argument list are assigned to one of the memory domains in the first return value, return true as the second value. TODO: Optimize this, there must be a more efficient way/algorithm.

func (*Topology) GetSocketsFromCores added in v0.3.0

func (topo *Topology) GetSocketsFromCores(
	cores []int,
) (sockets []int, exclusive bool)

Return a list of socket IDs given a list of core IDs. Even if just one core is in that socket, add it to the list. If no cores other than those in the argument list are assigned to one of the sockets in the first return value, return true as the second value. TODO: Optimize this, there must be a more efficient way/algorithm.

func (*Topology) GetSocketsFromHWThreads

func (topo *Topology) GetSocketsFromHWThreads(
	hwthreads []int,
) (sockets []int, exclusive bool)

Return a list of socket IDs given a list of hwthread IDs. Even if just one hwthread is in that socket, add it to the list. If no hwthreads other than those in the argument list are assigned to one of the sockets in the first return value, return true as the second value. TODO: Optimize this, there must be a more efficient way/algorithm.

type Unit

type Unit struct {
	Base   string `json:"base"`
	Prefix string `json:"prefix,omitempty"`
}

type User

type User struct {
	Username   string     `json:"username"`
	Password   string     `json:"-"`
	Name       string     `json:"name"`
	Email      string     `json:"email"`
	Roles      []string   `json:"roles"`
	Projects   []string   `json:"projects"`
	AuthType   AuthType   `json:"authType"`
	AuthSource AuthSource `json:"authSource"`
}

func (*User) GetAuthLevel

func (u *User) GetAuthLevel() Role

Find highest role

func (*User) HasAllRoles

func (u *User) HasAllRoles(queryroles []Role) bool

Check if User has ALL of the listed roles

func (*User) HasAnyRole

func (u *User) HasAnyRole(queryroles []Role) bool

Check if User has ANY of the listed roles

func (*User) HasNotRoles

func (u *User) HasNotRoles(queryroles []Role) bool

Check if User has NONE of the listed roles

func (*User) HasProject

func (u *User) HasProject(project string) bool

func (*User) HasRole

func (u *User) HasRole(role Role) bool

Check if User has SPECIFIED role

func (*User) HasValidRole

func (u *User) HasValidRole(role string) (hasRole bool, isValid bool)

Check if User has SPECIFIED role AND role is VALID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL