utils

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InferenceModeCustomTemplate kaitov1alpha1.ModelImageAccessMode = "customTemplate"

	ExampleDatasetURL = "" /* 140-byte string literal not displayed */
)
View Source
const (
	E2eNamespace = "kaito-e2e"
)

Variables

View Source
var (
	// PollInterval defines the interval time for a poll operation.
	PollInterval = 2 * time.Second
	// PollTimeout defines the time after which the poll operation times out.
	PollTimeout = 120 * time.Second
)
View Source
var (
	TestingCluster = NewCluster(scheme)
)

Functions

func CompareSecrets

func CompareSecrets(refs []corev1.LocalObjectReference, secrets []string) bool

func CopySecret

func CopySecret(original *corev1.Secret, targetNamespace string) *corev1.Secret

func ExecSync added in v0.4.1

func ExecSync(ctx context.Context, config *rest.Config, coreClient *kubernetes.Clientset, namespace, podName string, options corev1.PodExecOptions) (string, error)

func ExtractModelVersion

func ExtractModelVersion(configs map[string]interface{}) (map[string]string, error)

func GenerateE2ETuningConfigMapManifest

func GenerateE2ETuningConfigMapManifest(namespace string) *corev1.ConfigMap

GenerateE2ETuningConfigMapManifest generates a ConfigMap manifest for E2E tuning.

func GenerateE2ETuningWorkspaceManifest

func GenerateE2ETuningWorkspaceManifest(name, namespace, imageName, datasetImageName, outputRegistry string,
	resourceCount int, instanceType string, labelSelector *metav1.LabelSelector,
	preferredNodes []string, presetName kaitov1alpha1.ModelName, accessMode kaitov1alpha1.ModelImageAccessMode,
	imagePullSecret []string, customConfigMapName string) *kaitov1alpha1.Workspace

func GenerateInferenceWorkspaceManifest

func GenerateInferenceWorkspaceManifest(name, namespace, imageName string, resourceCount int, instanceType string,
	labelSelector *metav1.LabelSelector, preferredNodes []string, presetName kaitov1alpha1.ModelName,
	accessMode kaitov1alpha1.ModelImageAccessMode, imagePullSecret []string,
	podTemplate *corev1.PodTemplateSpec, adapters []kaitov1alpha1.AdapterSpec) *kaitov1alpha1.Workspace

func GenerateInferenceWorkspaceManifestWithVLLM

func GenerateInferenceWorkspaceManifestWithVLLM(name, namespace, imageName string, resourceCount int, instanceType string,
	labelSelector *metav1.LabelSelector, preferredNodes []string, presetName kaitov1alpha1.ModelName,
	accessMode kaitov1alpha1.ModelImageAccessMode, imagePullSecret []string,
	podTemplate *corev1.PodTemplateSpec, adapters []kaitov1alpha1.AdapterSpec) *kaitov1alpha1.Workspace

func GeneratePodTemplate

func GeneratePodTemplate(name, namespace, image string, labels map[string]string) *corev1.PodTemplateSpec

func GenerateRandomString

func GenerateRandomString() string

GenerateRandomString generates a random number between 0 and 1000 and returns it as a string.

func GenerateTuningWorkspaceManifest

func GenerateTuningWorkspaceManifest(name, namespace, imageName string, resourceCount int, instanceType string,
	labelSelector *metav1.LabelSelector, preferredNodes []string, input *kaitov1alpha1.DataSource,
	output *kaitov1alpha1.DataDestination, preset *kaitov1alpha1.PresetSpec, method kaitov1alpha1.TuningMethod) *kaitov1alpha1.Workspace

func GetAllValidNodeClaims

func GetAllValidNodeClaims(ctx context.Context, workspaceObj *v1alpha1.Workspace) (*karpenterv1.NodeClaimList, error)

GetAllValidNodeClaims get all valid nodeClaims.

func GetClusterClient

func GetClusterClient(cluster *Cluster)

GetClusterClient returns a Cluster client for the cluster.

func GetEnv

func GetEnv(envVar string) string

func GetK8sClientset added in v0.4.1

func GetK8sClientset() (*kubernetes.Clientset, error)

func GetK8sConfig

func GetK8sConfig() (*rest.Config, error)

func GetModelConfigInfo

func GetModelConfigInfo(configFilePath string) (map[string]interface{}, error)

func GetPodLogs

func GetPodLogs(coreClient *kubernetes.Clientset, namespace, podName, containerName string) (string, error)

func GetPodNameForDeployment

func GetPodNameForDeployment(coreClient *kubernetes.Clientset, namespace, deploymentName string) (string, error)

func GetPodNameForJob

func GetPodNameForJob(coreClient *kubernetes.Clientset, namespace, jobName string) (string, error)

func PrintPodLogsOnFailure

func PrintPodLogsOnFailure(namespace, labelSelector string)

func ValidateNodeClaimCreation

func ValidateNodeClaimCreation(ctx context.Context, workspaceObj *v1alpha1.Workspace, expectedCount int)

ValidateNodeClaimCreation Logic to validate the nodeClaim creation.

Types

type Cluster

type Cluster struct {
	Scheme        *runtime.Scheme
	KubeClient    client.Client
	DynamicClient dynamic.Interface
}

Cluster object defines the required clients of the test cluster.

func NewCluster

func NewCluster(scheme *runtime.Scheme) *Cluster

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳