util

package
v0.6.1-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1 << (10 * iota)
	MB
	GB
	TB
)
View Source
const DEFAULT_GCP_SERVICE_ACCOUNT_FILE = "https://artifacts.instill.tech/default-service-account.json"
View Source
const MaxBatchSize int = 32
View Source
const MaxImageSizeBytes int = 4 * MB

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 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 GitHubCloneWLargeFile

func GitHubCloneWLargeFile(dir string, instanceConfig datamodel.GitHubModelInstanceConfiguration) error

func GitHubCloneWOLargeFile

func GitHubCloneWOLargeFile(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 UpdateConfigModelName

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

func UpdateModelConfig

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

func ValidateFilePath

func ValidateFilePath(filePath string) error

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

Types

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 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