utils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT license.

Index

Constants

View Source
const (
	DefaultVolumeMountPath    = "/dev/shm"
	DefaultConfigMapMountPath = "/mnt/config"
	DefaultDataVolumePath     = "/mnt/data"
	DefaultAdapterVolumePath  = "/mnt/adapter"
	DefaultWeightsVolumePath  = "/workspace/weights"

	DefaultORASToolImage = "mcr.microsoft.com/oss/v2/oras-project/oras:v1.2.3"
)

Variables

View Source
var (
	KarpenterSchemeBuilder = runtime.NewSchemeBuilder(func(scheme *runtime.Scheme) error {
		scheme.AddKnownTypes(karpenterSchemeGroupVersion,
			&karpenterv1.NodePool{},
			&karpenterv1.NodePoolList{},
			&karpenterv1.NodeClaim{},
			&karpenterv1.NodeClaimList{},
		)
		metav1.AddToGroupVersion(scheme, karpenterSchemeGroupVersion)
		return nil
	})
	AwsSchemeBuilder = runtime.NewSchemeBuilder(func(scheme *runtime.Scheme) error {
		scheme.AddKnownTypes(awsSchemeGroupVersion,
			&awsv1beta1.EC2NodeClass{},
			&awsv1beta1.EC2NodeClassList{},
		)
		metav1.AddToGroupVersion(scheme, awsSchemeGroupVersion)
		return nil
	})
)
View Source
var DefaultModelWeightsVolume = corev1.Volume{
	Name: "model-weights-volume",
	VolumeSource: corev1.VolumeSource{
		EmptyDir: &corev1.EmptyDirVolumeSource{},
	},
}
View Source
var DefaultModelWeightsVolumeMount = corev1.VolumeMount{
	Name:      "model-weights-volume",
	MountPath: DefaultWeightsVolumePath,
}

Functions

func BuildCmdStr

func BuildCmdStr(baseCommand string, runParams ...map[string]string) string

func BuildIfElseCmdStr added in v0.5.0

func BuildIfElseCmdStr(condition string, trueCmd string, trueCmdParams map[string]string, falseCmd string, falseCmdParams map[string]string) string

func ConfigAdapterVolume

func ConfigAdapterVolume() (corev1.Volume, corev1.VolumeMount)

func ConfigCMVolume

func ConfigCMVolume(cmName string) (corev1.Volume, corev1.VolumeMount)

func ConfigDataVolume

func ConfigDataVolume(inputVolumeSource *corev1.VolumeSource) (corev1.Volume, corev1.VolumeMount)

func ConfigImagePullSecretVolume added in v0.4.5

func ConfigImagePullSecretVolume(nameSuffix string, imagePullSecrets []string) (corev1.Volume, corev1.VolumeMount)

func ConfigImagePushSecretVolume

func ConfigImagePushSecretVolume(imagePushSecret string) (corev1.Volume, corev1.VolumeMount)

func ConfigResultsVolume

func ConfigResultsVolume(outputPath string, outputVolume *corev1.VolumeSource) (corev1.Volume, corev1.VolumeMount)

func ConfigSHMVolume

func ConfigSHMVolume() (corev1.Volume, corev1.VolumeMount)

func Contains

func Contains(s []string, e string) bool

func DedupVolumeMounts added in v0.5.0

func DedupVolumeMounts(mounts []v1.VolumeMount) []v1.VolumeMount

DedupVolumeMounts removes duplicate volume mounts by only keeping the first occurrence of each name

func ExtractAndValidateRepoName

func ExtractAndValidateRepoName(image string) error

func FetchGPUCountFromNodes

func FetchGPUCountFromNodes(ctx context.Context, kubeClient client.Client, nodeNames []string) (int, error)

FetchGPUCountFromNodes retrieves the GPU count from the given node names.

func GetGPUConfigBySKU added in v0.4.5

func GetGPUConfigBySKU(instanceType string) (*sku.GPUConfig, error)

func GetPerNodeGPUCountFromNodes

func GetPerNodeGPUCountFromNodes(nodeList *v1.NodeList) int

func GetPresetImageName added in v0.5.0

func GetPresetImageName(name, tag string) string

func GetRayLeaderHost added in v0.5.0

func GetRayLeaderHost(meta metav1.ObjectMeta) string

getRayLeaderHost constructs the leader host for the Ray cluster.

func GetReleaseNamespace

func GetReleaseNamespace() (string, error)

func GetSKUHandler

func GetSKUHandler() (sku.CloudSKUHandler, error)

func MergeConfigMaps

func MergeConfigMaps(baseMap, overrideMap map[string]string) map[string]string

func ParseHuggingFaceModelVersion added in v0.4.6

func ParseHuggingFaceModelVersion(version string) (repoId string, revision string, err error)

ParseHuggingFaceModelVersion parses the model version in the format of https://huggingface.co/<org>/<model>/commit/<revision> and returns the repoId and revision. If the commit is not specified, it returns an empty string for revision, and the main branch HEAD commit is used.

Example 1:

Version: "https://huggingface.co/tiiuae/falcon-7b/commit/ec89142b67d748a1865ea4451372db8313ada0d8"
RepoId: "tiiuae/falcon-7b"
Revision: "ec89142b67d748a1865ea4451372db8313ada0d8"

Example 2:

Version: https://huggingface.co/tiiuae/falcon-7b
RepoId: "tiiuae/falcon-7b"
Revision: "" (main branch HEAD commit is used)

func SearchMap

func SearchMap(m map[string]interface{}, key string) (value interface{}, exists bool)

SearchMap performs a search for a key in a map[string]interface{}.

func SearchRawExtension

func SearchRawExtension(raw runtime.RawExtension, key string) (interface{}, bool, error)

SearchRawExtension performs a search for a key within a runtime.RawExtension.

func SelectNodes

func SelectNodes(qualified []*v1.Node, preferred []string, previous []string, count int) []*v1.Node

func ShellCmd

func ShellCmd(command string) []string

func TryGetGPUConfigFromNode added in v0.4.5

func TryGetGPUConfigFromNode(ctx context.Context, kubeClient client.Client, workerNodes []string) (*sku.GPUConfig, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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