models

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultNamespaceCode = "default"

DefaultNamespaceCode represents default Namespace code.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlignedMetric

type AlignedMetric struct {
	Metric
	Context datatypes.JSON `gorm:"column:context_json"`
}

AlignedMetric represents model to work with `metrics` table.

func (AlignedMetric) TableName

func (m AlignedMetric) TableName() string

TableName returns current table name.

type App

type App struct {
	Base
	Type        string    `gorm:"not null" json:"type"`
	State       AppState  `json:"state"`
	Namespace   Namespace `json:"-"`
	NamespaceID uint      `gorm:"not null" json:"-"`
}

App represents model to work with `apps` table.

type AppState

type AppState map[string]any

AppState represents state of App entity.

func (AppState) GormDataType

func (s AppState) GormDataType() string

GormDataType implements Gorm interface.

func (*AppState) Scan

func (s *AppState) Scan(v interface{}) error

Scan implements Gorm interface.

func (AppState) Value

func (s AppState) Value() (driver.Value, error)

Value implements Gorm interface.

type Base

type Base struct {
	ID         uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	IsArchived bool      `json:"-"`
}

Base represents a base model which other models just inherited.

type Context

type Context struct {
	ID   uint        `gorm:"primaryKey;autoIncrement"`
	Json types.JSONB `gorm:"not null;unique;index"`
}

Context represents model to work with `contexts` table.

func (Context) GetJsonHash

func (c Context) GetJsonHash() string

GetJsonHash returns hash of the Context.Json

type Dashboard

type Dashboard struct {
	Base
	Name        string     `json:"name"`
	Description string     `json:"description"`
	AppID       *uuid.UUID `gorm:"type:uuid" json:"app_id"`
	App         App        `json:"-"`
}

Dashboard represents the dashboard model.

func (Dashboard) MarshalJSON

func (d Dashboard) MarshalJSON() ([]byte, error)

MarshalJSON marshals the dashboard model to json.

type Experiment

type Experiment struct {
	ID               *int32         `gorm:"column:experiment_id;not null;primaryKey"`
	Name             string         `gorm:"type:varchar(256);not null;index:,unique,composite:name"`
	ArtifactLocation string         `gorm:"type:varchar(256)"`
	LifecycleStage   LifecycleStage `gorm:"type:varchar(32);check:lifecycle_stage IN ('active', 'deleted')"`
	CreationTime     sql.NullInt64  `gorm:"type:bigint"`
	LastUpdateTime   sql.NullInt64  `gorm:"type:bigint"`
	NamespaceID      uint           `gorm:"index:,unique,composite:name"`
	Namespace        Namespace
	Tags             []ExperimentTag `gorm:"constraint:OnDelete:CASCADE"`
	Runs             []Run           `gorm:"constraint:OnDelete:CASCADE"`
}

Experiment represents model to work with `experiments` table.

func (Experiment) IsDefault

func (e Experiment) IsDefault(namespaceDefaultExperimentID *int32) bool

IsDefault makes check that Experiment is default.

type ExperimentActivity

type ExperimentActivity struct {
	NumRuns         int            `json:"num_runs"`
	ActivityMap     map[string]int `json:"activity_map"`
	NumActiveRuns   int            `json:"num_active_runs"`
	NumArchivedRuns int            `json:"num_archived_runs"`
}

ExperimentActivity represents model to hold experiment activity information.

type ExperimentExtended

type ExperimentExtended struct {
	Experiment
	RunCount    int    `gorm:"column:run_count"`
	Description string `gorm:"column:description"`
}

ExperimentExtended represents model to work with `experiments` table and hold extended information.

func (ExperimentExtended) TableName

func (a ExperimentExtended) TableName() string

TableName returns table name.

type ExperimentTag

type ExperimentTag struct {
	Key          string `gorm:"type:varchar(250);not null;primaryKey"`
	Value        string `gorm:"type:varchar(5000)"`
	ExperimentID int32  `gorm:"not null;primaryKey"`
}

ExperimentTag represents model to work with `experiment_tags` table.

type LatestMetric

type LatestMetric struct {
	Key       string  `gorm:"type:varchar(250);not null;primaryKey"`
	Value     float64 `gorm:"type:double precision;not null"`
	Timestamp int64
	Step      int64  `gorm:"not null"`
	IsNan     bool   `gorm:"not null"`
	RunID     string `gorm:"column:run_uuid;not null;primaryKey;index"`
	LastIter  int64
	ContextID uint `gorm:"not null;primaryKey"`
	Context   Context
}

LatestMetric represents model to work with `last_metrics` table.

func (LatestMetric) UniqueKey

func (m LatestMetric) UniqueKey() string

UniqueKey is a compound unique key for this metric series.

type LifecycleStage

type LifecycleStage string

LifecycleStage represents entity stage

const (
	LifecycleStageActive  LifecycleStage = "active"
	LifecycleStageDeleted LifecycleStage = "deleted"
)

Supported list of stages.

type Metric

type Metric struct {
	Key       string  `gorm:"type:varchar(250);not null;primaryKey"`
	Value     float64 `gorm:"type:double precision;not null;primaryKey"`
	Timestamp int64   `gorm:"not null;primaryKey"`
	RunID     string  `gorm:"column:run_uuid;not null;primaryKey;index"`
	Step      int64   `gorm:"default:0;not null;primaryKey"`
	IsNan     bool    `gorm:"default:false;not null;primaryKey"`
	Iter      int64   `gorm:"index"`
	ContextID uint    `gorm:"not null;primaryKey"`
	Context   Context
}

Metric represents model to work with `metrics` table.

func (Metric) UniqueKey

func (m Metric) UniqueKey() string

UniqueKey is a compound unique key for this metric series.

type MetricKeysItem

type MetricKeysItem struct {
	Name    string
	Context string
}

MetricKeysItem represents object to build composite unique key for map.

type MetricKeysMap

type MetricKeysMap map[MetricKeysItem]any

MetricKeysMap represents map with composite keys.

type Namespace

type Namespace struct {
	ID                  uint           `gorm:"primaryKey;autoIncrement" json:"id"`
	Code                string         `gorm:"unique;index;not null" json:"code"`
	Description         string         `json:"description"`
	CreatedAt           time.Time      `json:"created_at"`
	UpdatedAt           time.Time      `json:"updated_at"`
	DeletedAt           gorm.DeletedAt `gorm:"index" json:"deleted_at"`
	DefaultExperimentID *int32         `gorm:"not null" json:"default_experiment_id"`
	Experiments         []Experiment   `gorm:"constraint:OnDelete:CASCADE" json:"experiments"`
}

Namespace represents model to work with `namespaces` table.

func (Namespace) DisplayName

func (ns Namespace) DisplayName() string

DisplayName returns Namespace display name.

func (Namespace) IsDefault

func (ns Namespace) IsDefault() bool

IsDefault makes check that Namespace is default.

type Param

type Param struct {
	Key        string   `gorm:"type:varchar(250);not null;primaryKey"`
	ValueStr   *string  `gorm:"type:varchar(500)"`
	ValueInt   *int64   `gorm:"type:bigint"`
	ValueFloat *float64 `gorm:"type:float"`
	RunID      string   `gorm:"column:run_uuid;not null;primaryKey;index"`
}

Param represents model to work with `params` table.

func (Param) ValueAny

func (p Param) ValueAny() any

ValueAny returns the value held by this Param as any with underlying type.

func (Param) ValueString

func (p Param) ValueString() string

Value returns the value held by this Param as a string.

type ProjectActivity

type ProjectActivity struct {
	NumRuns         int64          `json:"num_runs"`
	ActivityMap     map[string]int `json:"activity_map"`
	NumActiveRuns   int64          `json:"num_active_runs"`
	NumExperiments  int64          `json:"num_experiments"`
	NumArchivedRuns int64          `json:"num_archived_runs"`
}

ProjectActivity represents object to store and transfer project activity.

type ProjectParams

type ProjectParams struct {
	Metrics   []LatestMetric
	TagKeys   []string
	ParamKeys []string
}

ProjectParams represents object to store and transfer project parameters.

type RowNum

type RowNum int64

RowNum represents custom data type.

func (RowNum) GormDataType

func (rn RowNum) GormDataType() string

GormDataType implements Gorm interface for custom data types.

func (RowNum) GormValue

func (rn RowNum) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

GormValue implements Gorm interface for custom data types.

func (*RowNum) Scan

func (rn *RowNum) Scan(v interface{}) error

Scan implements Gorm interface for custom data types.

type Run

type Run struct {
	ID             string         `gorm:"<-:create;column:run_uuid;type:varchar(32);not null;primaryKey"`
	Name           string         `gorm:"type:varchar(250)"`
	SourceType     string         `gorm:"<-:create;type:varchar(20);check:source_type IN ('NOTEBOOK', 'JOB', 'LOCAL', 'UNKNOWN', 'PROJECT')"`
	SourceName     string         `gorm:"<-:create;type:varchar(500)"`
	EntryPointName string         `gorm:"<-:create;type:varchar(50)"`
	UserID         string         `gorm:"<-:create;type:varchar(256)"`
	Status         Status         `gorm:"type:varchar(9);check:status IN ('SCHEDULED', 'FAILED', 'FINISHED', 'RUNNING', 'KILLED')"`
	StartTime      sql.NullInt64  `gorm:"<-:create;type:bigint"`
	EndTime        sql.NullInt64  `gorm:"type:bigint"`
	SourceVersion  string         `gorm:"<-:create;type:varchar(50)"`
	LifecycleStage LifecycleStage `gorm:"type:varchar(20);check:lifecycle_stage IN ('active', 'deleted')"`
	ArtifactURI    string         `gorm:"<-:create;type:varchar(200)"`
	ExperimentID   int32
	Experiment     Experiment
	DeletedTime    sql.NullInt64  `gorm:"type:bigint"`
	RowNum         RowNum         `gorm:"<-:create;index"`
	Params         []Param        `gorm:"constraint:OnDelete:CASCADE"`
	Tags           []Tag          `gorm:"constraint:OnDelete:CASCADE"`
	Metrics        []Metric       `gorm:"constraint:OnDelete:CASCADE"`
	LatestMetrics  []LatestMetric `gorm:"constraint:OnDelete:CASCADE"`
}

Run represents model to work with `runs` table.

type Status

type Status string

Status represents Status type.

const (
	StatusRunning   Status = "RUNNING"
	StatusScheduled Status = "SCHEDULED"
	StatusFinished  Status = "FINISHED"
	StatusFailed    Status = "FAILED"
	StatusKilled    Status = "KILLED"
)

Supported list of statuses.

type Tag

type Tag struct {
	Key   string `gorm:"type:varchar(250);not null;primaryKey"`
	Value string `gorm:"type:varchar(5000)"`
	RunID string `gorm:"column:run_uuid;not null;primaryKey;index"`
}

Tag represents model to work with `tags` table.

Jump to

Keyboard shortcuts

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