store

package
v0.91.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConcurrentUpdate is returned when there is a concurrent update.
	ErrConcurrentUpdate = fmt.Errorf("store: concurrent update")
)

Functions

This section is empty.

Types

type Job

type Job struct {
	gorm.Model

	JobID string `gorm:"uniqueIndex:idx_job_job_id"`

	// Message is the marshaled proto message of v1.Job.
	Message []byte

	// Suffix is a string that will be added to a fine-tuned model name.
	Suffix string

	State    JobState `gorm:"index:idx_job_state_tenant_id"`
	TenantID string   `gorm:"index:idx_job_state_tenant_id"`

	OrganizationID      string
	ProjectID           string
	KubernetesNamespace string

	// OutputModelID is the ID of a generated model.
	OutputModelID string

	Version int
}

Job represents a job.

func (*Job) MutateMessage added in v0.14.0

func (j *Job) MutateMessage(mutateFn func(j *v1.Job)) error

MutateMessage mutates the message field of a job.

func (*Job) V1Job added in v0.14.0

func (j *Job) V1Job() (*v1.Job, error)

V1Job converts a job to v1.Job.

type JobState

type JobState string

JobState represents the state of a job.

const (
	// JobStateQueued represents the pending state.
	JobStateQueued JobState = "queued"
	// JobStateRunning represents the running state.
	JobStateRunning JobState = "running"
	// JobStatusFailed represents the failed state.
	JobStatusFailed JobState = "failed"
	// JobStateSucceeded represents the succeeded state.
	JobStateSucceeded JobState = "succeeded"
	// JobStateCancelled represents the cancelled state.
	JobStateCancelled JobState = "cancelled"
)

type Notebook added in v0.91.0

type Notebook struct {
	gorm.Model

	NotebookID string `gorm:"uniqueIndex"`

	Image string

	// Message is the marshalled JSON of the v1.Notebook.
	Message []byte

	State NotebookState

	TenantID            string
	OrganizationID      string
	ProjectID           string
	KubernetesNamespace string

	Version int
}

Notebook is a model of notebook.

type NotebookState added in v0.91.0

type NotebookState string

NotebookState is the state of a notebook.

const (
	// NotebookStateQueued is the state of a notebook that is waiting to be scheduled.
	NotebookStateQueued NotebookState = "queued"
	// NotebookStateRunning is the state of a notebook that is currently running.
	NotebookStateRunning NotebookState = "running"
	// NotebookStateStopped is the state of a notebook that has been stopped.
	NotebookStateStopped NotebookState = "stopped"
	// NotebookStateFailed is the state of a notebook that has failed.
	NotebookStateFailed NotebookState = "failed"
)

type S

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

S represents the data store.

func New

func New(db *gorm.DB) *S

New creates a new store instance.

func NewTest

func NewTest(t *testing.T) (*S, func())

NewTest returns a new test store.

func (*S) AutoMigrate

func (s *S) AutoMigrate() error

AutoMigrate sets up the auto-migration task of the database.

func (*S) CreateJob

func (s *S) CreateJob(job *Job) error

CreateJob creates a new job.

func (*S) CreateNotebook added in v0.91.0

func (s *S) CreateNotebook(nb *Notebook) error

CreateNotebook creates a new notebook.

func (*S) GetJobByJobID

func (s *S) GetJobByJobID(jobID string) (*Job, error)

GetJobByJobID gets a job.

func (*S) GetJobByJobIDAndTenantID added in v0.76.0

func (s *S) GetJobByJobIDAndTenantID(jobID, tenantID string) (*Job, error)

GetJobByJobIDAndTenantID gets a job by its job ID and tenant ID.

func (*S) ListJobsByTenantID

func (s *S) ListJobsByTenantID(tenantID string) ([]*Job, error)

ListJobsByTenantID finds jobs.

func (*S) ListJobsByTenantIDWithPagination added in v0.82.0

func (s *S) ListJobsByTenantIDWithPagination(tenantID string, afterID uint, limit int) ([]*Job, bool, error)

ListJobsByTenantIDWithPagination finds jobs with pagination. Jobs are returned with a descending order of ID.

func (*S) ListQueuedJobs added in v0.11.0

func (s *S) ListQueuedJobs() ([]*Job, error)

ListQueuedJobs finds queued jobs.

func (*S) ListQueuedJobsByTenantID added in v0.11.0

func (s *S) ListQueuedJobsByTenantID(tenantID string) ([]*Job, error)

ListQueuedJobsByTenantID finds queued jobs.

func (*S) UpdateJobState

func (s *S) UpdateJobState(jobID string, currentVersion int, newState JobState) error

UpdateJobState updates a job.

func (*S) UpdateJobStateAndMessage added in v0.14.0

func (s *S) UpdateJobStateAndMessage(jobID string, currentVersion int, newState JobState, message []byte) error

UpdateJobStateAndMessage updates a job state and message.

func (*S) UpdateOutputModelID added in v0.3.0

func (s *S) UpdateOutputModelID(jobID string, currentVersion int, outputModelID string) error

UpdateOutputModelID updates the output model ID.

Jump to

Keyboard shortcuts

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