models

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllModels

func AllModels() []any

AllModels returns all registered models for AutoMigrate.

func AutoMigrate

func AutoMigrate(db *gorm.DB) error

AutoMigrate runs migrations for all registered models.

func RegisterModel

func RegisterModel(model any)

RegisterModel adds a model to the migration registry. Call this in init() of each model file.

Types

type APIKey

type APIKey struct {
	RowID     uint64    `gorm:"column:row_id;primaryKey;autoIncrement"`
	ID        string    `gorm:"column:id;size:36;not null;uniqueIndex:uniq_api_keys_id"`
	Name      string    `gorm:"column:name;size:255;not null;default:'';index:idx_api_keys_name"`
	KeyHash   string    `gorm:"column:key_hash;size:255;not null;default:''"`
	KeyPrefix string    `gorm:"column:key_prefix;size:255;not null;default:''"`
	Deleted   bool      `gorm:"column:deleted;not null;default:false;index"`
	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
}

APIKey maps api_keys table.

func (*APIKey) FromPB

func (a *APIKey) FromPB(src *pb.APIKey) error

FromPB converts a pb.APIKey to APIKey.

func (APIKey) TableName

func (APIKey) TableName() string

func (*APIKey) ToPB

func (a *APIKey) ToPB() (*pb.APIKey, error)

ToPB converts APIKey to pb.APIKey.

type Deployment

type Deployment struct {
	RowID            uint64         `gorm:"column:row_id;primaryKey;autoIncrement"`
	ID               string         `gorm:"column:id;size:36;not null;uniqueIndex:uniq_deployments_id"`
	Name             string         `gorm:"column:name;size:255;not null;default:'';index:idx_deployments_name"`
	DeploymentID     string         `gorm:"column:deployment_id;size:255;not null;default:''"`
	BaseModel        string         `gorm:"column:base_model;size:255;not null;default:'';index:idx_deployments_base_model"`
	BaseModelID      string         `gorm:"column:base_model_id;size:255;not null;default:''"`
	MinReplicas      int32          `gorm:"column:min_replicas;not null;default:1"`
	MaxReplicas      int32          `gorm:"column:max_replicas;not null;default:1"`
	GpusPerReplica   int32          `gorm:"column:gpus_per_replica;not null;default:0"`
	GpuType          string         `gorm:"column:gpu_type;size:255;not null;default:''"`
	Region           string         `gorm:"column:region;size:255;not null;default:''"`
	CreatedBy        string         `gorm:"column:created_by;size:255;not null;default:'';index:idx_deployments_created_by"`
	Status           string         `gorm:"column:status;size:255;not null;default:'Deploying';index:idx_deployments_status"`
	ModelSource      string         `gorm:"column:model_source;size:255;not null;default:''"`
	ModelArtifactURL string         `gorm:"column:model_artifact_url;size:1000;not null;default:''"`
	Engine           string         `gorm:"column:engine;size:255;not null;default:''"`
	StartupCommand   string         `gorm:"column:startup_command;type:text"`
	EnvVars          datatypes.JSON `gorm:"column:env_vars"`
	ExtraArgs        datatypes.JSON `gorm:"column:extra_args"`
	Namespace        string         `gorm:"column:namespace;size:255;not null;default:'default'"`
	K8sResourceName  string         `gorm:"column:k8s_resource_name;size:255;not null;default:''"`
	Deleted          bool           `gorm:"column:deleted;not null;default:false;index"`
	CreatedAt        time.Time      `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt        time.Time      `gorm:"column:updated_at;autoUpdateTime"`
}

Deployment maps to deployments table.

func (*Deployment) FromPB

func (d *Deployment) FromPB(src *pb.Deployment) error

FromPB converts a pb.Deployment to Deployment.

func (Deployment) TableName

func (Deployment) TableName() string

func (*Deployment) ToPB

func (d *Deployment) ToPB() (*pb.Deployment, error)

ToPB converts Deployment to pb.Deployment.

type Job

type Job struct {
	RowID                uint64         `gorm:"column:row_id;primaryKey;autoIncrement"`
	ID                   string         `gorm:"column:id;size:64;not null;uniqueIndex:uniq_jobs_id"`
	Endpoint             string         `gorm:"column:endpoint;size:255;not null;default:''"`
	Model                string         `gorm:"column:model;size:255;not null;default:'';index:idx_jobs_model"`
	InputDataset         string         `gorm:"column:input_dataset;size:255;not null;default:''"`
	CompletionWindow     string         `gorm:"column:completion_window;size:64;not null;default:''"`
	Status               string         `gorm:"column:status;size:64;not null;default:'';index:idx_jobs_status"`
	OutputDataset        string         `gorm:"column:output_dataset;size:255;not null;default:''"`
	ErrorDataset         string         `gorm:"column:error_dataset;size:255;not null;default:''"`
	BatchCreatedAt       *time.Time     `gorm:"column:batch_created_at"`
	InProgressAt         *time.Time     `gorm:"column:in_progress_at"`
	ExpiresAt            *time.Time     `gorm:"column:expires_at"`
	FinalizingAt         *time.Time     `gorm:"column:finalizing_at"`
	CompletedAt          *time.Time     `gorm:"column:completed_at"`
	FailedAt             *time.Time     `gorm:"column:failed_at"`
	ExpiredAt            *time.Time     `gorm:"column:expired_at"`
	CancellingAt         *time.Time     `gorm:"column:cancelling_at"`
	CancelledAt          *time.Time     `gorm:"column:cancelled_at"`
	RequestCounts        datatypes.JSON `gorm:"column:request_counts"`
	Usage                datatypes.JSON `gorm:"column:usage_stats"`
	Metadata             datatypes.JSON `gorm:"column:metadata"`
	Name                 string         `gorm:"column:name;size:255;not null;default:''"`
	CreatedBy            string         `gorm:"column:created_by;size:255;not null;default:''"`
	ModelTemplateName    string         `gorm:"column:model_template_name;size:255;not null;default:''"`
	ModelTemplateVersion string         `gorm:"column:model_template_version;size:64;not null;default:''"`
	BatchID              string         `gorm:"column:batch_id;size:64;not null;default:'';index:idx_jobs_batch_id"`
	ProvisionID          string         `gorm:"column:provision_id;size:36;not null;default:''"`
	QueuedAt             *time.Time     `gorm:"column:queued_at"`
	ResourcePreparingAt  *time.Time     `gorm:"column:resource_preparing_at"`
	SubmittingAt         *time.Time     `gorm:"column:submitting_at"`
	ResourceFailedAt     *time.Time     `gorm:"column:resource_failed_at"`
	SubmitFailedAt       *time.Time     `gorm:"column:submit_failed_at"`
	CancelRequestedAt    *time.Time     `gorm:"column:cancel_requested_at"`
	ErrorMessage         string         `gorm:"column:error_msg;type:TEXT"`
	Deleted              bool           `gorm:"column:deleted;not null;default:false;index:idx_jobs_deleted"`
	CreatedAt            time.Time      `gorm:"column:created_at;autoCreateTime;index:idx_jobs_created_at"`
	UpdatedAt            time.Time      `gorm:"column:updated_at;autoUpdateTime"`
}

Job stores full batch job records including metadata-service owned fields.

func (*Job) FromPB

func (j *Job) FromPB(src *pb.Job) error

FromPB converts a pb.Job to Job.

func (Job) TableName

func (Job) TableName() string

func (*Job) ToPB

func (j *Job) ToPB() (*pb.Job, error)

ToPB converts Job to pb.Job.

type Model

type Model struct {
	RowID         uint64         `gorm:"column:row_id;primaryKey;autoIncrement"`
	ID            string         `gorm:"column:id;size:36;not null;uniqueIndex:uniq_models_id"`
	Name          string         `gorm:"column:name;size:255;not null;default:'';index:idx_models_name"`
	Provider      string         `gorm:"column:provider;size:255;not null;default:'';index:idx_models_provider"`
	IconBg        string         `gorm:"column:icon_bg;size:255;not null;default:''"`
	IconText      string         `gorm:"column:icon_text;size:255;not null;default:''"`
	IconTextColor string         `gorm:"column:icon_text_color;size:255;not null;default:''"`
	Categories    datatypes.JSON `gorm:"column:categories"`
	IsNew         bool           `gorm:"column:is_new;not null;default:false"`
	Pricing       datatypes.JSON `gorm:"column:pricing"`
	ContextLength string         `gorm:"column:context_length;size:255;not null;default:''"`
	Description   string         `gorm:"column:description;type:text"`
	Metadata      datatypes.JSON `gorm:"column:metadata"`
	Specification datatypes.JSON `gorm:"column:specification"`
	Tags          datatypes.JSON `gorm:"column:tags"`
	ServingName   string         `gorm:"column:serving_name;size:255;not null;default:''"`
	Deleted       bool           `gorm:"column:deleted;not null;default:false;index"`
	CreatedAt     time.Time      `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt     time.Time      `gorm:"column:updated_at;autoUpdateTime"`
}

Model maps model catalog table.

func (*Model) FromPB

func (m *Model) FromPB(src *pb.Model) error

FromPB converts a pb.Model to Model. Returns error if JSON marshaling fails.

func (Model) TableName

func (Model) TableName() string

func (*Model) ToPB

func (m *Model) ToPB() (*pb.Model, error)

ToPB converts Model to pb.Model.

type ModelDeploymentTemplate

type ModelDeploymentTemplate struct {
	RowID     uint64         `gorm:"column:row_id;primaryKey;autoIncrement"`
	ID        string         `gorm:"column:id;size:36;not null;uniqueIndex:uniq_model_tpl_id"`
	Name      string         `gorm:"column:name;size:255;not null;default:'';uniqueIndex:uniq_model_tpl_name_ver,priority:2"`
	Version   string         `gorm:"column:version;size:64;not null;default:'';uniqueIndex:uniq_model_tpl_name_ver,priority:3"`
	Status    string         `gorm:"column:status;size:64;not null;default:'active';index:idx_model_tpl_status"`
	ModelID   string         `gorm:"column:model_id;size:36;not null;default:'';index:idx_model_tpl_status;uniqueIndex:uniq_model_tpl_name_ver,priority:1"`
	Spec      datatypes.JSON `gorm:"column:spec"`
	Deleted   bool           `gorm:"column:deleted;not null;default:false;index:idx_model_tpl_deleted"`
	CreatedAt time.Time      `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt time.Time      `gorm:"column:updated_at;autoUpdateTime"`
}

ModelDeploymentTemplate maps model_deployment_templates table.

func (*ModelDeploymentTemplate) FromPB

FromPB converts a pb.ModelDeploymentTemplate to ModelDeploymentTemplate.

func (ModelDeploymentTemplate) TableName

func (ModelDeploymentTemplate) TableName() string

func (*ModelDeploymentTemplate) ToPB

ToPB converts ModelDeploymentTemplate to pb.ModelDeploymentTemplate.

type ProvisionResult

type ProvisionResult struct {
	RowID          uint64         `gorm:"column:row_id;primaryKey;autoIncrement"`
	IdempotencyKey string         `gorm:"column:idempotency_key;size:255;not null;default:'';uniqueIndex:uniq_provision_results_idempotency_key"`
	ProvisionID    string         `gorm:"column:provision_id;size:36;not null;default:'';uniqueIndex:uniq_provision_results_provision_id"`
	Provider       string         `gorm:"column:provider;size:32;not null;default:'kubernetes';index:idx_provision_results_provider"`
	Region         string         `gorm:"column:region;size:255;not null;default:'';index:idx_provision_results_region"`
	Status         string         `gorm:"column:status;size:64;not null;index:idx_provision_results_status_deleted,priority:1"`
	Payload        datatypes.JSON `gorm:"column:payload"`
	CreatedAt      time.Time      `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt      time.Time      `gorm:"column:updated_at;autoUpdateTime"`
	Deleted        bool           `gorm:"column:deleted;not null;default:false;index:idx_provision_results_status_deleted,priority:2"`
}

ProvisionResult maps provision_results table.

func (ProvisionResult) TableName

func (ProvisionResult) TableName() string

type Quota

type Quota struct {
	RowID        uint64    `gorm:"column:row_id;primaryKey;autoIncrement"`
	ID           string    `gorm:"column:id;size:36;not null;uniqueIndex:uniq_quotas_id"`
	Name         string    `gorm:"column:name;size:255;not null;default:'';index:idx_quotas_name"`
	QuotaID      string    `gorm:"column:quota_id;size:255;not null;default:'';uniqueIndex:uniq_quotas_quota_id"`
	CurrentUsage int32     `gorm:"column:current_usage;not null;default:0"`
	Quota        int32     `gorm:"column:quota;not null;default:0"`
	Deleted      bool      `gorm:"column:deleted;not null;default:false;index"`
	CreatedAt    time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt    time.Time `gorm:"column:updated_at;autoUpdateTime"`
}

Quota maps quotas table.

func (*Quota) FromPB

func (q *Quota) FromPB(src *pb.Quota) error

FromPB converts a pb.Quota to Quota.

func (Quota) TableName

func (Quota) TableName() string

func (*Quota) ToPB

func (q *Quota) ToPB() (*pb.Quota, error)

ToPB converts Quota to pb.Quota.

type Secret

type Secret struct {
	RowID          uint64    `gorm:"column:row_id;primaryKey;autoIncrement"`
	ID             string    `gorm:"column:id;size:36;not null;uniqueIndex:uniq_secrets_id"`
	Name           string    `gorm:"column:name;size:255;not null;default:'';index:idx_secrets_name"`
	EncryptedValue string    `gorm:"column:encrypted_value;type:text"`
	Deleted        bool      `gorm:"column:deleted;not null;default:false;index"`
	CreatedAt      time.Time `gorm:"column:created_at;autoCreateTime"`
}

Secret maps secrets table.

func (*Secret) FromPB

func (s *Secret) FromPB(src *pb.Secret) error

FromPB converts a pb.Secret to Secret.

func (Secret) TableName

func (Secret) TableName() string

func (*Secret) ToPB

func (s *Secret) ToPB() (*pb.Secret, error)

ToPB converts Secret to pb.Secret.

Jump to

Keyboard shortcuts

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