dcontext

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AMD_ROCM_VERSION = "amd.rocmVersion"
View Source
const ARCH_KEY = "hardware.architecture"
View Source
const CUDA_TOOLKIT_VERSION = "nvidia.cudaVersion"
View Source
const LIBC_VERSION = "os.libcVersion"
View Source
const NVIDIA_DRIVER_VERSION = "nvidia.driverVersion"
View Source
const PYTHON_BIN_PATH = "os.pythonBinPath"
View Source
const PYTHON_VERSION_KEY = "os.pythonVersion"

Variables

View Source
var DeployabilityEvaluators = make(map[string]DeployabilityEvaluator)

Functions

func AMDROCmVersion added in v0.2.0

func AMDROCmVersion(root string) (version string, err error)

func AMDROCmVersionEvaluator added in v0.2.0

func AMDROCmVersionEvaluator(specifier string, dc *DeployContext) (int, error)

func Arch

func Arch(root string) (arch string, err error)

Get system architure by reading "/var/lib/dpkg/status" and get package info of libc6 All possible archs includes: amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, riscv64, s390x

func ArchEvaluator

func ArchEvaluator(specifier string, dc *DeployContext) (int, error)

func CUDAToolkitVersionEvaluator

func CUDAToolkitVersionEvaluator(specifier string, dc *DeployContext) (int, error)

specifer is the CUDA toolkit Version, for example 12.6 or 11.5 value is the nvidia driver version

func EvaluatePythonVersion

func EvaluatePythonVersion(specifier string, pythonVersion string) (int, error)

func GetAptInstalled

func GetAptInstalled(root string) (installed map[string]string, err error)

func GetAptSources

func GetAptSources(root string) (srcs []string, err error)

Ref: https://wiki.debian.org/SourcesList

func LibCVersion

func LibCVersion(root string) (major int, minor int, err error)

Get system glibc version [major.minor] by reading "/var/lib/dpkg/status" and get package info of libc6

func NvidiaDriverVersion

func NvidiaDriverVersion(root string) (version string, err error)

func PythonBinPath

func PythonBinPath(root string) (binPath string, err error)

func PythonVersion

func PythonVersion(root string) (major int, minor int, err error)

Get python version [major.minor]

func PythonVersionEvaluator

func PythonVersionEvaluator(specifier string, dc *DeployContext) (int, error)

specifier should be like `>=3.5`, `< 3.11.3`, ` ~=3.0` minor version number is required patch version number is optional

Types

type DeployContext

type DeployContext map[string]any

func ParseDeployContext

func ParseDeployContext(jsonStr string) (d *DeployContext, err error)

func (*DeployContext) Evaluate

func (dc *DeployContext) Evaluate(deployability *Deployability) (result int, err error)

The evaluated deployability is an integer between 0 and 255 0 indicates not deployable 127 is the default result 255 indicates perfect match

func (*DeployContext) Get

func (d *DeployContext) Get(key string) (data any, exists bool)

func (DeployContext) Has

func (d DeployContext) Has(key string) bool

func (*DeployContext) MapGet

func (d *DeployContext) MapGet(key string, mapKey string) (value any, err error)

func (*DeployContext) MapSet

func (d *DeployContext) MapSet(key string, mapKey string, mapValue any) error

func (*DeployContext) Merge

func (d *DeployContext) Merge(newContext *DeployContext) (err error)

func (*DeployContext) Set

func (d *DeployContext) Set(key string, value any) (err error)

for a given key, if the key doesn't exist in the context, directly add the value to the context if the key exists in the context, switch the current value to the new value

func (*DeployContext) SetAMDROCmVersion added in v0.2.0

func (d *DeployContext) SetAMDROCmVersion(root string) (err error)

func (*DeployContext) SetArch

func (d *DeployContext) SetArch(root string) (err error)

func (*DeployContext) SetLibCVersion

func (d *DeployContext) SetLibCVersion(root string) (err error)

func (*DeployContext) SetNvidiaDriverVersion

func (d *DeployContext) SetNvidiaDriverVersion(root string) (err error)

func (*DeployContext) SetPythonBinPath

func (d *DeployContext) SetPythonBinPath(root string) (err error)

func (*DeployContext) SetPythonVersion

func (d *DeployContext) SetPythonVersion(root string) (err error)

func (*DeployContext) SliceAppend

func (d *DeployContext) SliceAppend(key string, newItem any) error

func (*DeployContext) SliceContains

func (d *DeployContext) SliceContains(key string, query any) (exist bool, err error)

Works for slice and array

func (DeployContext) String

func (d DeployContext) String() string

type Deployability

type Deployability map[string]string

func ParseDeployability

func ParseDeployability(jsonStr string) (*Deployability, error)

func (*Deployability) Add

func (d *Deployability) Add(key string, value string)

func (*Deployability) String

func (d *Deployability) String() string

type DeployabilityEvaluator

type DeployabilityEvaluator func(string, *DeployContext) (int, error)

type NvidiaMap

type NvidiaMap struct {
	CUDAVersion int
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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