util

package
v0.14.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1 << (10 * iota)
	MB
	GB
	TB
)
View Source
const (
	TEXT_TO_IMAGE_STEPS     = int64(10)
	IMAGE_TO_TEXT_CFG_SCALE = float32(7)
	IMAGE_TO_TEXT_SEED      = int64(1024)
	IMAGE_TO_TEXT_SAMPLES   = int64(1)
)
View Source
const (
	TEXT_GENERATION_OUTPUT_LEN = int64(100)
	TEXT_GENERATION_TOP_K      = int64(1)
	TEXT_GENERATION_SEED       = int64(0)
)
View Source
const DEFAULT_GCP_SERVICE_ACCOUNT_FILE = "https://artifacts.instill.tech/default-service-account.json"
View Source
const DefaultPageSize = 10
View Source
const MaxBatchSize int = 32

Variables

View Source
var MarshalOptions protojson.MarshalOptions = protojson.MarshalOptions{
	UseProtoNames:   true,
	EmitUnpopulated: true,
	UseEnumNumbers:  false,
}
View Source
var UnmarshalOptions protojson.UnmarshalOptions = protojson.UnmarshalOptions{
	DiscardUnknown: true,
}

Functions

func AddMissingTritonModelFolder

func AddMissingTritonModelFolder(dir string)

func ArtiVCClone

func ArtiVCClone(dir string, modelConfig datamodel.ArtiVCModelConfiguration, instanceConfig datamodel.ArtiVCModelInstanceConfiguration, withLargeFiles bool) error

func ArtiVCGetTags

func ArtiVCGetTags(dir string, config datamodel.ArtiVCModelConfiguration) ([]string, error)

func ConvertAllJSONEnumValueToProtoStyle

func ConvertAllJSONEnumValueToProtoStyle(enumRegistry map[string]map[string]int32, i interface{})

ConvertAllJSONEnumValueToProtoStyle converts lowercase enum value to the Protobuf naming convention where the enum type is always prefixed and is UPPERCASE snake_case. For examples: - api in a Protobuf `Enum SourceType` type will be converted to SOURCE_TYPE_API - oauth2.0 in a Protobuf `Enum AuthFlowType` type will be converted to AUTH_FLOW_TYPE_OAUTH2_0

func ConvertAllJSONKeySnakeCase

func ConvertAllJSONKeySnakeCase(i interface{})

ConvertAllJSONKeySnakeCase traverses a JSON object to replace all keys to snake_case.

func CopyModelFileToModelRepository

func CopyModelFileToModelRepository(modelRepository string, dir string, tritonModels []datamodel.TritonModel) error

func DoSupportBatch

func DoSupportBatch(configFilePath string) (bool, error)

func GenerateHuggingFaceModel

func GenerateHuggingFaceModel(confDir string, dest string, modelID string) error

func GetMaxBatchSize

func GetMaxBatchSize(configFilePath string) (int, error)

func GetSupportedBatchSize

func GetSupportedBatchSize(task datamodel.ModelInstanceTask) int

func GitHubClone

func GitHubClone(isWithLargeFile bool, dir string, instanceConfig datamodel.GitHubModelInstanceConfiguration) error

func HasModelWeightFile

func HasModelWeightFile(modelRepository string, tritonModels []datamodel.TritonModel) bool

func HuggingFaceClone

func HuggingFaceClone(dir string, modelConfig datamodel.HuggingFaceModelConfiguration) error

func HuggingFaceExport

func HuggingFaceExport(dir string, modelConfig datamodel.HuggingFaceModelConfiguration, modelID string) error

func RemoveModelRepository

func RemoveModelRepository(modelRepositoryRoot string, namespace string, modelName string, instanceName string)

func SaveFile

func SaveFile(stream modelPB.ModelPublicService_CreateModelBinaryFileUploadServer) (outFile string, modelInfo *datamodel.Model, modelDefinitionID string, err error)

func Unzip

func Unzip(fPath string, dstDir string, owner string, uploadedModel *datamodel.Model) (string, string, error)

TODO: need to clean up this function

func UpdateConfigModelName

func UpdateConfigModelName(filePath string, oldModelName string, newModelName string) error

func UpdateModelConfig

func UpdateModelConfig(modelRepository string, tritonModels []datamodel.TritonModel) error

func UpdateModelName

func UpdateModelName(filePath string, oldModelName string, newModelName string) error

func UpdateModelPath

func UpdateModelPath(modelDir string, dstDir string, owner string, modelID string, modelInstance *datamodel.ModelInstance) (string, string, error)

modelDir and dstDir are absolute path

func ValidateFilePath

func ValidateFilePath(filePath string) error

validate to prevent security issue as https://codeql.github.com/codeql-query-help/go/go-path-injection/

func WriteToFp

func WriteToFp(fp *os.File, data []byte) error

writeToFp takes in a file pointer and byte array and writes the byte array into the file returns error if pointer is nil or error in writing to file

Types

type FileMeta

type FileMeta struct {
	// contains filtered or unexported fields
}

type GitHubInfo

type GitHubInfo struct {
	Description string `json:"description"`
	Visibility  string `json:"visibility"`
	Tags        []Tag
}

func GetGitHubRepoInfo

func GetGitHubRepoInfo(repo string) (*GitHubInfo, error)

type ModelMeta

type ModelMeta struct {
	Tags []string
	Task string
}

func GetModelMetaFromReadme

func GetModelMetaFromReadme(readmeFilePath string) (*ModelMeta, error)

type OperationType

type OperationType string
const (
	OperationTypeCreate      OperationType = "create"
	OperationTypeDeploy      OperationType = "deploy"
	OperationTypeUnDeploy    OperationType = "undeploy"
	OperationTypeHealthCheck OperationType = "healthcheck"
)

type Tag

type Tag struct {
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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