Documentation
¶
Overview ¶
Copyright 2024 The Aibrix Team.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func AddLabel(labels map[string]string, labelKey, labelValue string) map[string]string
- func CheckUser(ctx context.Context, u User, redisClient *redis.Client) bool
- func CloneAndAddLabel(labels map[string]string, labelKey, labelValue string) map[string]string
- func CloneAndRemoveLabel(labels map[string]string, labelKey string) map[string]string
- func CloneSelectorAndAddLabel(selector *metav1.LabelSelector, labelKey, labelValue string) *metav1.LabelSelector
- func CountReadyPods(podList *v1.PodList) (int64, error)
- func CountRoutablePods(pods []*v1.Pod) (cnt int)
- func DelUser(ctx context.Context, u User, redisClient *redis.Client) error
- func DetokenizeText(tokenIds []int) (string, error)
- func FilterActivePods(pods []v1.Pod) []v1.Pod
- func FilterPodByName(podname string, pods []*v1.Pod) (*v1.Pod, bool)
- func FilterPods(pods []v1.Pod, filterFn filterPod) []v1.Pod
- func FilterReadyPod(pod *v1.Pod) bool
- func FilterRoutablePods(pods []*v1.Pod) []*v1.Pod
- func FilterRoutablePodsInPlace(pods []*v1.Pod) []*v1.Pod
- func GeneratePodKey(podNamespace, podName string) string
- func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)
- func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)
- func GetPodListByLabelSelector(ctx context.Context, podLister client.Client, namespace string, ...) (*v1.PodList, error)
- func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition
- func GetPortAnnotationOrDefault(annotations map[string]string, key string, defaultValue int) int
- func GetPositiveIntAnnotationOrDefault(annotations map[string]string, key string, defaultValue int) int
- func GetRedisClient() *redis.Client
- func GetStringAnnotationOrDefault(annotations map[string]string, key string, defaultValue string) string
- func IsPodReady(pod *v1.Pod) bool
- func IsPodReadyConditionTrue(status v1.PodStatus) bool
- func IsPodTerminating(pod *v1.Pod) bool
- func IsRayClusterAvailable(cluster *rayclusterv1.RayCluster, minReadySeconds int32, now metav1.Time) bool
- func IsRayClusterReady(cluster *rayclusterv1.RayCluster) bool
- func IsRayClusterStateReady(status rayclusterv1.RayClusterStatus) bool
- func LoadEnv(key, defaultValue string) string
- func LoadEnvFloat(key string, defaultValue float64) float64
- func LoadEnvInt(key string, defaultValue int) int
- func LookupEnv(key string) (string, bool)
- func ParsePodKey(key string) (string, string, bool)
- func SelectRandomPod(pods []*v1.Pod, randomFn func(int) int) (*v1.Pod, error)
- func SetConditionInList(inputList []metav1.Condition, conditionType string, ...) []metav1.Condition
- func SetUser(ctx context.Context, u User, redisClient *redis.Client) error
- func TokenizeInputText(text string) ([]int, error)
- func TrimMessage(message string) string
- func ValidateArtifactURL(artifactURL string) error
- type CustomizedRegistry
- type Message
- type PodArray
- type Registry
- type SyncMap
- func (sm *SyncMap[K, V]) CompareAndDelete(key K, old V) (deleted bool)
- func (sm *SyncMap[K, V]) CompareAndSwap(key K, old V, new V) bool
- func (sm *SyncMap[K, V]) Delete(key K)
- func (sm *SyncMap[K, V]) Keys() []K
- func (sm *SyncMap[K, V]) Len() int
- func (sm *SyncMap[K, V]) Load(key K) (typedVal V, ok bool)
- func (sm *SyncMap[K, V]) LoadAndDelete(key K) (typedVal V, loaded bool)
- func (sm *SyncMap[K, V]) LoadOrStore(key K, value V) (V, bool)
- func (sm *SyncMap[K, V]) Range(f func(key K, value V) bool)
- func (sm *SyncMap[K, V]) Store(key K, value V)
- func (sm *SyncMap[K, V]) Swap(key K, value V) (V, bool)
- func (sm *SyncMap[K, V]) Values() []V
- type User
Constants ¶
const (
DeploymentIdentifier string = "app.kubernetes.io/name"
)
const (
NAMESPACE = "aibrix-system"
)
Variables ¶
var AllowedSchemas = []string{"s3://", "gcs://", "huggingface://", "hf://", "/"}
Functions ¶
func CloneAndAddLabel ¶
Clones the given map and returns a new map with the given key and value added. Returns the given map, if labelKey is empty.
func CloneAndRemoveLabel ¶
CloneAndRemoveLabel clones the given map and returns a new map with the given key removed. Returns the given map, if labelKey is empty.
func CloneSelectorAndAddLabel ¶
func CloneSelectorAndAddLabel(selector *metav1.LabelSelector, labelKey, labelValue string) *metav1.LabelSelector
Clones the given selector and returns a new selector with the given key and value added. Returns the given selector, if labelKey is empty.
func CountRoutablePods ¶
CountRoutablePods filters and returns the number of pods that are routable. A pod is routable if it have a valid PodIP and not in terminating state.
func DetokenizeText ¶
func FilterActivePods ¶
FilterActivePods returns active pods.
func FilterPods ¶
FilterPods returns replica sets that are filtered by filterFn (all returned ones should match filterFn).
func FilterReadyPod ¶
func FilterRoutablePods ¶
FilterRoutablePods filters and returns a list of pods that are routable. A pod is routable if it have a valid PodIP and not in terminating state.
func FilterRoutablePodsInPlace ¶
FilterRoutablePodsInPlace filters a list of pods that are routable. A pod is routable if it have a valid PodIP and not in terminating state.
func GeneratePodKey ¶
GeneratePodKey generates a key in the format "namespace/name" for a given pod.
func GetPodCondition ¶
func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)
GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.
func GetPodConditionFromList ¶
func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)
GetPodConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.
func GetPodReadyCondition ¶
func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition
GetPodReadyCondition extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.
func GetRedisClient ¶
func GetRedisClient() *redis.Client
func IsPodReady ¶
IsPodReady returns true if a pod is ready; false otherwise.
func IsPodReadyConditionTrue ¶
IsPodReadyConditionTrue returns true if a pod is ready; false otherwise.
func IsPodTerminating ¶
IsPodTerminating check if pod is in terminating status via whether the deletion timestamp is set
func IsRayClusterAvailable ¶
func IsRayClusterAvailable(cluster *rayclusterv1.RayCluster, minReadySeconds int32, now metav1.Time) bool
func IsRayClusterReady ¶
func IsRayClusterReady(cluster *rayclusterv1.RayCluster) bool
IsRayClusterReady returns true if a RayCluster is ready; false otherwise.
func IsRayClusterStateReady ¶
func IsRayClusterStateReady(status rayclusterv1.RayClusterStatus) bool
func LoadEnvFloat ¶
func LoadEnvInt ¶
func LookupEnv ¶
LookupEnv retrieves an environment variable and returns whether it exists. It returns the value and a boolean indicating its existence.
func ParsePodKey ¶
ParsePodKey parses a key in the format "namespace/podName". Returns (namespace, podName, success).
func SelectRandomPod ¶
SelectRandomPod selects a random pod from the provided list, ensuring it's routable. It returns an error if no ready pods are available.
func SetConditionInList ¶
func SetConditionInList(inputList []metav1.Condition, conditionType string, status metav1.ConditionStatus, reason, message string, args ...interface{}) []metav1.Condition
SetConditionInList sets the specific condition type on the given PodAutoscaler to the specified value with the given reason and message. The message and args are treated like a format string. The condition will be added if it is not present. The new list will be returned.
func TokenizeInputText ¶
func TrimMessage ¶
func ValidateArtifactURL ¶
ValidateArtifactURL checks if the ArtifactURL has a valid schema (s3://, gcs://, huggingface://, https://, /)
Types ¶
type CustomizedRegistry ¶
type CustomizedRegistry[V any, A comparable] struct { Registry[V] // contains filtered or unexported fields }
CustomizedRegistry extends Registry to provide a customized array provider.
func NewRegistryWithArrayProvider ¶
func NewRegistryWithArrayProvider[V any, A comparable](provider func([]V) A) *CustomizedRegistry[V, A]
func (*CustomizedRegistry[V, A]) Array ¶
func (reg *CustomizedRegistry[V, A]) Array() (arr A)
func (*CustomizedRegistry[V, A]) Delete ¶
func (reg *CustomizedRegistry[V, A]) Delete(key string)
func (*CustomizedRegistry[V, A]) Len ¶
func (reg *CustomizedRegistry[V, A]) Len() int
func (*CustomizedRegistry[V, A]) Store ¶
func (reg *CustomizedRegistry[V, A]) Store(key string, value V)
type Registry ¶
type Registry[V any] struct { // contains filtered or unexported fields }
Registry is a generic hash set focus on storing values with string keys. Array output is optimized by offering a cached copy.