repository

package
v1.24.4 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceKindHuggingface = "huggingface"
	SourceKindOpenMMLab   = "openmmlab"
	SourceKindModelx      = "modelx"
)
View Source
const AnnotationRequieToken = "modelx.kubegems.io/token-required"

Variables

View Source
var InitSources = []any{
	Source{
		Name:    SourceKindHuggingface,
		BuiltIn: true,
		Online:  true,
		Enabled: true,
		Kind:    SourceKindHuggingface,
		Images:  []string{},
	},
	Source{
		Name:    SourceKindOpenMMLab,
		BuiltIn: true,
		Online:  true,
		Enabled: true,
		Kind:    SourceKindOpenMMLab,
		Images: []string{
			"kubegems/mlserver-mmlab",
		},
	},
}

Functions

This section is empty.

Types

type Authorization

type Authorization struct {
	Username    string
	Permissions []string
}

type AuthorizationRepository

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

func NewAuthorizationRepository

func NewAuthorizationRepository(ctx context.Context, db *mongo.Database) *AuthorizationRepository

func (*AuthorizationRepository) Add

func (a *AuthorizationRepository) Add(ctx context.Context, authorization *Authorization) error

func (*AuthorizationRepository) Get

func (*AuthorizationRepository) InitSchema

func (a *AuthorizationRepository) InitSchema(ctx context.Context) error

func (*AuthorizationRepository) List

func (*AuthorizationRepository) Set

func (a *AuthorizationRepository) Set(ctx context.Context, authorization *Authorization) error

type Comment

type Comment struct {
	// nolint: tagliatelle
	ID           string    `json:"id,omitempty" bson:"_id,omitempty"` // id
	Username     string    `json:"username"`                          // user's id (username)
	PostID       string    `json:"postID"`                            // post id
	Content      string    `json:"content"`                           // comment's content
	ReplyTo      *ReplyTo  `json:"replyTo" `                          // comment's content(some section) reply to
	Rating       int       `json:"rating"`                            // rating value (1-5)
	CreationTime time.Time `json:"creationTime"`                      // comment's create time
	UpdationTime time.Time `json:"updationTime"`                      // comment's update time
}

type CommentWithAddtional

type CommentWithAddtional struct {
	Comment      `json:",inline" bson:",inline"`
	RepliesCount int64                  `json:"repliesCount,omitempty"`
	Replies      []CommentWithAddtional `json:"replies,omitempty"`
}

type CommentsRepository

type CommentsRepository struct {
	Collection *mongo.Collection
}

func NewCommentsRepository

func NewCommentsRepository(db *mongo.Database) *CommentsRepository

func (*CommentsRepository) Count

func (c *CommentsRepository) Count(ctx context.Context, listoptions ListCommentOptions) (int64, error)

func (*CommentsRepository) Create

func (c *CommentsRepository) Create(ctx context.Context, postID string, comment *Comment) error

func (*CommentsRepository) Delete

func (c *CommentsRepository) Delete(ctx context.Context, comment *Comment) error

func (*CommentsRepository) InitSchema

func (c *CommentsRepository) InitSchema(ctx context.Context) error

func (*CommentsRepository) List

func (*CommentsRepository) Rating

func (c *CommentsRepository) Rating(ctx context.Context, ids ...string) ([]Rating, error)

func (*CommentsRepository) Update

func (c *CommentsRepository) Update(ctx context.Context, comment *Comment) error

type CommonListOptions

type CommonListOptions struct {
	Page   int64  `json:"page,omitempty"`
	Size   int64  `json:"size,omitempty"`
	Search string `json:"search,omitempty"`

	// sort string, eg: "-name,-creationtime", "name,-creationtime"
	// the '-' prefix means descending,otherwise ascending
	Sort string `json:"sort,omitempty"`
}

type GetSourceOptions

type GetSourceOptions struct {
	WithDisabled bool
	WithCounts   bool
	WithAuth     bool
}

type ListCommentOptions

type ListCommentOptions struct {
	CommonListOptions
	PostID      string // find comments of this post
	ReplyToID   string // find all replies of this comment
	WithReplies bool   // include replies in the result
}

func (ListCommentOptions) ToConditionAndFindOptions

func (o ListCommentOptions) ToConditionAndFindOptions() (interface{}, *options.FindOptions)

type ListSourceOptions

type ListSourceOptions struct {
	WithDisabled    bool
	WithModelCounts bool
	WithAuth        bool
}

func (ListSourceOptions) ToConditionAndFindOptions

func (o ListSourceOptions) ToConditionAndFindOptions() (interface{}, *options.FindOptions)

type Model

type Model struct {
	ID               string            `json:"id,omitempty" bson:"_id,omitempty"`
	Source           string            `json:"source"` // source of model (huggingface, ...)
	Name             string            `json:"name"`
	Tags             []string          `json:"tags"`
	Author           string            `json:"author"`
	License          string            `json:"license"`
	Framework        string            `json:"framework"`
	Paper            map[string]string `json:"paper"`
	Downloads        int               `json:"downloads"`
	Task             string            `json:"task"`
	Likes            int               `json:"likes"`
	Versions         []ModelVersion    `json:"versions"`                         // versions of model
	Recomment        int               `json:"recomment"`                        // number of recomment votes
	RecommentContent string            `json:"recommentContent"`                 // content of recomment
	CreateAt         *time.Time        `json:"createAt" bson:"create_at"`        // original creation time
	UpdateAt         *time.Time        `json:"updateAt" bson:"update_at"`        // original updattion time
	LastModified     *time.Time        `json:"lastModified" bson:"lastModified"` // last time the model synced
	Enabled          bool              `json:"enabled"`                          // is model published
	Annotations      map[string]string `json:"annotations"`                      // additional infomations
}

model meta in models store nolint: tagliatelle

type ModelFile

type ModelFile struct {
	Filename string    `json:"filename"`
	Content  string    `json:"content"`
	Size     int64     `json:"size"`
	ModTime  time.Time `json:"modTime,omitempty"`
}

type ModelListOptions

type ModelListOptions struct {
	CommonListOptions
	Source       string
	Tags         []string
	License      string
	Framework    string
	Task         string
	WithRating   bool
	WithDisabled bool
	WithVersions bool
}

func (*ModelListOptions) ToConditionAndFindOptions

func (o *ModelListOptions) ToConditionAndFindOptions() (interface{}, *options.FindOptions)

type ModelVersion

type ModelVersion struct {
	Name         string      `json:"name"`
	Files        []ModelFile `json:"files"`
	Intro        string      `json:"intro"`
	CreationTime time.Time   `json:"creationTime"` // original creation time
	UpdationTime time.Time   `json:"updationTime"` // original updattion time
}

type ModelWithAddtional

type ModelWithAddtional struct {
	Model  `bson:",inline" json:",inline"`
	Rating *Rating `bson:"rating" json:"rating"`
}

type ModelsRepository

type ModelsRepository struct {
	Collection *mongo.Collection
}

func NewModelsRepository

func NewModelsRepository(db *mongo.Database) *ModelsRepository

func (*ModelsRepository) Count

func (*ModelsRepository) Create

func (m *ModelsRepository) Create(ctx context.Context, model Model) error

func (*ModelsRepository) CreateOrUpdateFromSync added in v1.23.8

func (m *ModelsRepository) CreateOrUpdateFromSync(ctx context.Context, model *Model) error

func (*ModelsRepository) Delete

func (m *ModelsRepository) Delete(ctx context.Context, source, name string) error

func (*ModelsRepository) Get

func (m *ModelsRepository) Get(ctx context.Context, source, name string, includedisabled bool) (ModelWithAddtional, error)

func (*ModelsRepository) GetVersion

func (r *ModelsRepository) GetVersion(ctx context.Context, source, model, version string) (ModelVersion, error)

func (*ModelsRepository) InitSchema

func (m *ModelsRepository) InitSchema(ctx context.Context) error

func (*ModelsRepository) List

nolint: funlen

func (*ModelsRepository) ListSelectors

func (m *ModelsRepository) ListSelectors(ctx context.Context, listopts ModelListOptions) (*Selectors, error)

func (*ModelsRepository) ListVersions

func (r *ModelsRepository) ListVersions(ctx context.Context, source, model string) ([]ModelVersion, error)

func (*ModelsRepository) Update

func (m *ModelsRepository) Update(ctx context.Context, model *Model) error

func (*ModelsRepository) Upsert added in v1.23.12

func (r *ModelsRepository) Upsert(ctx context.Context, model Model) (Model, error)

type Rating

type Rating struct {
	ID     string  `json:"id,omitempty" bson:"_id,omitempty"`
	Rating float64 `json:"rating"`
	Count  int64   `json:"count"`
	Total  int64   `json:"total"`
}

nolint: tagliatelle

type ReplyTo

type ReplyTo struct {
	// nolint: tagliatelle
	ID           string    `json:"id,omitempty" bson:"_id,omitempty"` // id of the comment that this comment reply to
	RootID       string    `json:"rootID"`                            // id of the top level comment, if this comment is a reply to a reply
	Content      string    `json:"content"`                           // comment's content
	Username     string    `json:"username"`                          // user's id (username)
	CreationTime time.Time `json:"creationTime"`                      // comment's create time
}

type Selectors

type Selectors struct {
	Tags       []string `json:"tags"`
	Frameworks []string `json:"frameworks"`
	Licenses   []string `json:"licenses"`
	Tasks      []string `json:"tasks"`
}

type Source

type Source struct {
	// nolint: tagliatelle
	ID           string            `json:"id,omitempty" bson:"_id,omitempty"`
	Name         string            `json:"name"`
	BuiltIn      bool              `json:"builtIn"`
	Online       bool              `json:"online"`
	Images       []string          `json:"images"`
	CreationTime time.Time         `json:"creationTime"`
	UpdationTime time.Time         `json:"updationTime"`
	Enabled      bool              `json:"enabled"`
	InitImage    string            `json:"initImage"` // storage initialize image
	Kind         string            `json:"kind"`      // kind of source (huggingface, openmmlab, modelx...)
	Address      string            `json:"address"`   // address of source
	Auth         SourceAuth        `json:"auth"`      // auth of source
	Annotations  map[string]string `json:"annotations"`
}

type SourceAuth

type SourceAuth struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Token    string `json:"token"`
}

type SourceWithAddtional

type SourceWithAddtional struct {
	Source     `bson:",inline" json:",inline"`
	ModelCount int64 `bson:"modelsCount" json:"modelsCount"`
}

type SourcesRepository

type SourcesRepository struct {
	Collection *mongo.Collection
}

func NewSourcesRepository

func NewSourcesRepository(db *mongo.Database) *SourcesRepository

func (*SourcesRepository) Count

func (*SourcesRepository) Create

func (s *SourcesRepository) Create(ctx context.Context, source *Source) error

func (SourcesRepository) Delete

func (r SourcesRepository) Delete(ctx context.Context, source *Source) error

func (*SourcesRepository) Get

func (*SourcesRepository) InitSchema

func (r *SourcesRepository) InitSchema(ctx context.Context) error

func (*SourcesRepository) List

func (*SourcesRepository) Update

func (s *SourcesRepository) Update(ctx context.Context, source *Source) error

Jump to

Keyboard shortcuts

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