utils

package
v0.0.0-...-58c3220 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogFlushSize = 32
)
View Source
const PublicSSHKeyName = "ssh_known_hosts"

Variables

View Source
var (
	ErrMalformedJWT    = errors.New("malformed JWT")
	ErrClaimExtraction = errors.New("claim extraction failed")
)

Errors

View Source
var (
	SSHURLRegexp = regexp.MustCompile(`(?P<Users>.+)@(?P<Host>[\w.]+)[/:].*`)
)

Functions

func BuildNodeAffinity

func BuildNodeAffinity(nodePools []config.NodePool) *corev1.Affinity

Build affinity that matches all nodes from nodePools list

func CalculateHelperContainerResources

func CalculateHelperContainerResources(
	res corev1.ResourceRequirements, gpuResourceName string,
) corev1.ResourceRequirements

Resources of helper containers are copy of main trainer/packager resources, but limit doesn't contain GPU part and all requests res are zeroes. If core limit resources is nill then defaultHelperLimits will be used.

func EvaluatePublicKey

func EvaluatePublicKey(sshURL string) (string, error)

TODO: Need to find a better solution. The best way is use standard library.

func ExtractHost

func ExtractHost(gitURL string) (string, error)

TODO: Need to find a better solution. url.Parse can't find a host url.Parse with git+ssh://url does not evaluate a valid host.

func ExtractUserInfoFromToken

func ExtractUserInfoFromToken(token string, config config.Claims) (*user.UserInfo, error)

func NewClient

func NewClient(cache cache.Cache, config *rest.Config, options client.Options) (client.Client, error)

func NewManager

func NewManager(opts ctrl.Options) (manager.Manager, error)

func SetupLogger

func SetupLogger()

SetupLogger setups global logger

func StreamLogs

func StreamLogs(
	k8sConfig *rest.Config, namespace string, podName string,
	containerName string, writer Writer, follow bool, logFlushSize int64,
) error

Stream logs from the pod to the writer object k8sConfig - kubernetes config namespace - namespace where pod is located podName - kubernetes pod name containerName - container name of the pod writer - logs will be streamed into this writer follow - specify if the logs should be streamed logFlushSize - size of the flushed logs per chunk

func TektonContainerName

func TektonContainerName(stepName string) string

Generate tekton container name base on the step name

func Unzip

func Unzip(src string, dest string) error

func ZipDir

func ZipDir(source, target string) error

Types

type Writer

type Writer interface {
	http.Flusher
	http.CloseNotifier
	io.Writer
}

Directories

Path Synopsis
model_registry
objectstorage
Package object_storage provides API to fetch model files and metadata from s3/azureblob/gcs with minimum requirements to model files.
Package object_storage provides API to fetch model files and metadata from s3/azureblob/gcs with minimum requirements to model files.

Jump to

Keyboard shortcuts

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