database

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SQLiteCustomDriverName = "sqlite3_custom_driver"
)

Variables

View Source
var DB *gorm.DB

DB is a global gorm.DB reference

Functions

func NewLoggerAdaptor added in v0.3.1

func NewLoggerAdaptor(l *logrus.Logger, cfg LoggerAdaptorConfig) logger.Interface

NewLoggerAdaptor creates a new logger adaptor.

func NewUUID

func NewUUID() string

Types

type AlembicVersion

type AlembicVersion struct {
	Version string `gorm:"column:version_num;type:varchar(32);not null;primaryKey"`
}

func (AlembicVersion) TableName

func (AlembicVersion) TableName() string

type App

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

type AppState

type AppState map[string]any

func (AppState) GormDataType

func (s AppState) GormDataType() string

func (*AppState) Scan

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

func (AppState) Value

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

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:"-"`
}

func (*Base) BeforeCreate

func (b *Base) BeforeCreate(tx *gorm.DB) error

type DBInstance added in v0.3.0

type DBInstance struct {
	*gorm.DB
	// contains filtered or unexported fields
}

DBInstance is the base concrete type for DbProvider.

func (*DBInstance) Close added in v0.3.0

func (db *DBInstance) Close() error

Close will invoke the closers.

func (*DBInstance) Dsn added in v0.3.0

func (db *DBInstance) Dsn() string

Dsn will return the dsn string.

func (*DBInstance) GormDB added in v0.3.0

func (db *DBInstance) GormDB() *gorm.DB

Db will return the gorm DB.

type DBProvider added in v0.3.0

type DBProvider interface {
	GormDB() *gorm.DB
	Dsn() string
	Close() error
	Reset() error
}

DBProvider is the interface to access the DB.

func MakeDBProvider added in v0.3.0

func MakeDBProvider(
	dsn string, slowThreshold time.Duration, poolMax int, reset bool, migrate bool, defaultArtifactRoot string,
) (db DBProvider, err error)

MakeDBProvider will create a DbProvider of the correct type from the parameters.

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:"-"`
}

func (Dashboard) MarshalJSON

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

type Experiment

type Experiment struct {
	ID               *int32          `gorm:"column:experiment_id;not null;primaryKey"`
	Name             string          `gorm:"type:varchar(256);not null;unique"`
	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"`
	Tags             []ExperimentTag `gorm:"constraint:OnDelete:CASCADE"`
	Runs             []Run           `gorm:"constraint:OnDelete:CASCADE"`
}

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"`
}

type Importer added in v0.3.0

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

Importer will handle transport of data from source to destination db.

func NewImporter added in v0.3.0

func NewImporter(input, output DBProvider) *Importer

NewImporter initializes an Importer.

func (*Importer) Import added in v0.3.0

func (s *Importer) Import() error

Import will copy the contents of input db to output db.

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
}

type LifecycleStage

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

type LoggerAdaptorConfig added in v0.3.1

type LoggerAdaptorConfig struct {
	SlowThreshold             time.Duration
	IgnoreRecordNotFoundError bool
	ParameterizedQueries      bool
}

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"`
}

type Param

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

type PostgresDBInstance added in v0.3.0

type PostgresDBInstance struct {
	DBInstance
}

PostgresDBInstance is the Postgres-specific DbInstance variant.

func NewPostgresDBInstance added in v0.3.0

func NewPostgresDBInstance(
	dsnURL url.URL, slowThreshold time.Duration, poolMax int, reset bool,
) (*PostgresDBInstance, error)

NewPostgresDBInstance will construct a Postgres DbInstance.

func (PostgresDBInstance) Reset added in v0.3.0

func (pgdb PostgresDBInstance) Reset() error

Reset implementation for this type.

type RowNum

type RowNum int64

func (RowNum) GormDataType

func (rn RowNum) GormDataType() string

func (RowNum) GormValue

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

func (*RowNum) Scan

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

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"`
}

type SchemaVersion

type SchemaVersion struct {
	Version string `gorm:"not null;primaryKey"`
}

func (SchemaVersion) TableName

func (SchemaVersion) TableName() string

type SqliteDBInstance added in v0.3.0

type SqliteDBInstance struct {
	DBInstance
}

SqliteDBInstance is the sqlite specific variant of DbInstance.

func NewSqliteDBInstance added in v0.3.0

func NewSqliteDBInstance(
	dsnURL url.URL, slowThreshold time.Duration, poolMax int, reset bool,
) (*SqliteDBInstance, error)

NewSqliteDBInstance will create a Sqlite DbInstance.

func (SqliteDBInstance) Reset added in v0.3.0

func (f SqliteDBInstance) Reset() error

Reset implementation for this type.

type Status

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

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"`
}

Jump to

Keyboard shortcuts

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