store

package
v0.200.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 8 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 BatchJob added in v0.175.0

type BatchJob struct {
	gorm.Model

	JobID string `gorm:"uniqueIndex"`

	Image string
	// Message is the marshaled message of the v1.BatchJob.
	Message []byte

	State BatchJobState
	// QueuedAction is the action of the batch job. This field is only used when
	// the state is BatchJobStateQueued, and processed by the dispatcher.
	QueuedAction BatchJobQueuedAction

	TenantID            string
	OrganizationID      string
	ProjectID           string
	KubernetesNamespace string

	Version int
}

BatchJob is a model of a batch job.

func (*BatchJob) MutateMessage added in v0.175.0

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

MutateMessage mutates the message of the batch job.

func (*BatchJob) V1BatchJob added in v0.175.0

func (j *BatchJob) V1BatchJob() (*v1.BatchJob, error)

V1BatchJob returns the v1.BatchJob of the batch job.

func (*BatchJob) V1InternalBatchJob added in v0.179.0

func (j *BatchJob) V1InternalBatchJob() (*v1.InternalBatchJob, error)

V1InternalBatchJob converts a notebook to a v1.InternalBatchJob.

type BatchJobQueuedAction added in v0.175.0

type BatchJobQueuedAction string

BatchJobQueuedAction is the action of a queue batch job.

const (
	// BatchJobQueuedActionCreate is the action to create a batch job.
	BatchJobQueuedActionCreate BatchJobQueuedAction = "creating"
	// BatchJobQueuedActionCancel is the action to cancel a batch job.
	BatchJobQueuedActionCancel BatchJobQueuedAction = "canceling"
	// BatchJobQueuedActionDelete is the action to delete a batch job.
	BatchJobQueuedActionDelete BatchJobQueuedAction = "deleting"
)

type BatchJobState added in v0.175.0

type BatchJobState string

BatchJobState is the state of a batch job.

const (
	// BatchJobStateQueued is the state of a notebook that is waiting to be processed.
	BatchJobStateQueued BatchJobState = "queued"
	// BatchJobStateRunning is the state of a batch job that is currently running.
	BatchJobStateRunning BatchJobState = "running"
	// BatchJobStateSucceeded is the state of a batch job that has completed successfully.
	BatchJobStateSucceeded BatchJobState = "succeeded"
	// BatchJobStateFailed is the state of a batch job that has completed with an error.
	BatchJobStateFailed BatchJobState = "failed"
	// BatchJobStateCanceled is the state of a batch job that has been canceled.
	BatchJobStateCanceled BatchJobState = "canceled"
	// BatchJobStateDeleted is the state of a batch job that has been deleted.
	BatchJobStateDeleted BatchJobState = "deleted"
)

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

	// QueuedAction is the action of a queue job.
	// This field is only used when the state is JobStateQueued.
	QueuedAction JobQueuedAction

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

	OrganizationID      string
	ProjectID           string `gorm:"index"`
	KubernetesNamespace string

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

	Version int
}

Job represents a job.

func (*Job) MutateMessage

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

MutateMessage mutates the message field of a job.

func (*Job) V1InternalJob

func (j *Job) V1InternalJob() (*v1.InternalJob, error)

V1InternalJob converts a job to v1.InternalJob.

func (*Job) V1Job

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

V1Job converts a job to v1.Job.

type JobQueuedAction added in v0.185.0

type JobQueuedAction string

JobQueuedAction is the action of a queue job.

const (
	// JobQueuedActionCreate represents the creating action.
	JobQueuedActionCreate JobQueuedAction = "creating"
	// JobQueuedActionCancel represents the canceling action.
	JobQueuedActionCancel JobQueuedAction = "canceling"
)

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"
	// JobStateFailed represents the failed state.
	JobStateFailed JobState = "failed"
	// JobStateSucceeded represents the succeeded state.
	JobStateSucceeded JobState = "succeeded"
	// JobStateCanceled represents the canceled state.
	JobStateCanceled JobState = "canceled"
)

type Notebook

type Notebook struct {
	gorm.Model

	NotebookID string `gorm:"uniqueIndex"`

	Image string

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

	State NotebookState
	// QueuedAction is the action of the queued notebook. This field is only used when
	// the state is NotebookStateQueued, and processed by the dispatcher.
	QueuedAction NotebookQueuedAction

	TenantID            string
	OrganizationID      string
	ProjectID           string `gorm:"index:idx_notebook_project_id_name"`
	KubernetesNamespace string
	// ClusterID is the ID of the cluster where the job runs.
	ClusterID string

	// We do not use a unique index here since the same notebook name can be used if there is only one active noteobook.
	Name string `gorm:"index:idx_notebook_project_id_name"`

	Version int
}

Notebook is a model of notebook.

func (*Notebook) MutateMessage

func (n *Notebook) MutateMessage(mutateFn func(nb *v1.Notebook)) error

MutateMessage mutates the message field of a notebook.

func (*Notebook) V1InternalNotebook

func (n *Notebook) V1InternalNotebook() (*v1.InternalNotebook, error)

V1InternalNotebook converts a notebook to a v1.InternalNotebook.

func (*Notebook) V1Notebook

func (n *Notebook) V1Notebook() (*v1.Notebook, error)

V1Notebook converts a notebook to a v1.Notebook.

type NotebookQueuedAction

type NotebookQueuedAction string

NotebookQueuedAction is the action of a queued notebook.

const (
	// NotebookQueuedActionStart is the action to start a notebook.
	NotebookQueuedActionStart NotebookQueuedAction = "starting"
	// NotebookQueuedActionStop is the action to stop a notebook.
	NotebookQueuedActionStop NotebookQueuedAction = "stopping"
	// NotebookQueuedActionDelete is the action to delete a notebook.
	NotebookQueuedActionDelete NotebookQueuedAction = "deleting"
)

type NotebookState

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"
	// NotebookStateInitializing is the state of a notebook that is initializing.
	NotebookStateInitializing NotebookState = "initializing"
	// 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"
	// NotebookStateDeleted is the state of a notebook that has been deleted.
	NotebookStateDeleted NotebookState = "deleted"
)

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) CreateBatchJob added in v0.175.0

func (s *S) CreateBatchJob(job *BatchJob) error

CreateBatchJob creates a batch job.

func (*S) CreateJob

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

CreateJob creates a new job.

func (*S) CreateNotebook

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

CreateNotebook creates a new notebook.

func (*S) GetActiveBatchJobByIDAndProjectID added in v0.183.0

func (s *S) GetActiveBatchJobByIDAndProjectID(id, projectID string) (*BatchJob, error)

GetActiveBatchJobByIDAndProjectID gets a batch job by its job ID and project ID.

func (*S) GetActiveNotebookByNameAndProjectID added in v0.159.0

func (s *S) GetActiveNotebookByNameAndProjectID(name, projectID string) (*Notebook, error)

GetActiveNotebookByNameAndProjectID gets an active notebook by its name and project ID.

func (*S) GetBatchJobByID added in v0.179.0

func (s *S) GetBatchJobByID(id string) (*BatchJob, error)

GetBatchJobByID gets a batch job by its job ID.

func (*S) GetJobByJobID

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

GetJobByJobID gets a job.

func (*S) GetJobByJobIDAndProjectID

func (s *S) GetJobByJobIDAndProjectID(jobID, projectID string) (*Job, error)

GetJobByJobIDAndProjectID gets a job by its job ID and project ID.

func (*S) GetNotebookByID

func (s *S) GetNotebookByID(id string) (*Notebook, error)

GetNotebookByID gets a notebook by its notebook ID.

func (*S) GetNotebookByIDAndProjectID

func (s *S) GetNotebookByIDAndProjectID(id, projectID string) (*Notebook, error)

GetNotebookByIDAndProjectID gets a notebook by its notebook ID and project ID.

func (*S) ListActiveBatchJobsByProjectIDWithPagination added in v0.183.0

func (s *S) ListActiveBatchJobsByProjectIDWithPagination(projectID string, afterID uint, limit int) ([]BatchJob, bool, error)

ListActiveBatchJobsByProjectIDWithPagination lists batch jobs by project ID with pagination.

func (*S) ListActiveNotebooksByProjectIDWithPagination

func (s *S) ListActiveNotebooksByProjectIDWithPagination(projectID string, afterID uint, limit int) ([]*Notebook, bool, error)

ListActiveNotebooksByProjectIDWithPagination finds active notebooks with pagination. Notebooks are returned with a descending order of ID.

func (*S) ListJobsByProjectIDWithPagination

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

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

func (*S) ListJobsByTenantID

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

ListJobsByTenantID finds jobs.

func (*S) ListQueuedBatchJobsByTenantID added in v0.179.0

func (s *S) ListQueuedBatchJobsByTenantID(tenantID string) ([]BatchJob, error)

ListQueuedBatchJobsByTenantID finds queued batch jobs by tenant ID.

func (*S) ListQueuedJobs

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

ListQueuedJobs finds queued jobs.

func (*S) ListQueuedJobsByTenantID

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

ListQueuedJobsByTenantID finds queued jobs.

func (*S) ListQueuedNotebooksByTenantID

func (s *S) ListQueuedNotebooksByTenantID(tenantID string) ([]*Notebook, error)

ListQueuedNotebooksByTenantID finds queued notebooks by tenant ID.

func (*S) SetBatchJobQueuedAction added in v0.175.0

func (s *S) SetBatchJobQueuedAction(id string, currentVersion int, newActionn BatchJobQueuedAction) (*BatchJob, error)

SetBatchJobQueuedAction sets the queued action of a batch job.

func (*S) SetBatchJobState added in v0.179.0

func (s *S) SetBatchJobState(id string, currentVersion int, newState BatchJobState) error

SetBatchJobState sets the state of a batch job.

func (*S) SetNonQueuedBatchJobStateAndMessage added in v0.179.0

func (s *S) SetNonQueuedBatchJobStateAndMessage(id string, currentVersion int, newState BatchJobState, message []byte) error

SetNonQueuedBatchJobStateAndMessage sets the state and message of a batch job.

func (*S) SetNonQueuedStateAndMessage

func (s *S) SetNonQueuedStateAndMessage(id string, currentVersion int, newState NotebookState, message []byte) error

SetNonQueuedStateAndMessage sets a non-queued state and message.

func (*S) SetNotebookQueuedAction

func (s *S) SetNotebookQueuedAction(id string, currentVersion int, newAction NotebookQueuedAction) (*Notebook, error)

SetNotebookQueuedAction sets a notebook queued action.

func (*S) SetState added in v0.170.0

func (s *S) SetState(id string, currentVersion int, newState NotebookState) error

SetState sets a state.

func (*S) UpdateJobState

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

UpdateJobState updates a job state and queued action.

func (*S) UpdateJobStateAndMessage

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

UpdateJobStateAndMessage updates a job state and message.

func (*S) UpdateOutputModelID

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