Documentation
¶
Overview ¶
Package mlops provides interfaces for ML operations platforms. This package will expand to include experiment tracking, model registry, dataset versioning, and other MLOps capabilities.
Planned providers:
- MLflow
- Weights & Biases
- DVC
- Neptune
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Artifact ¶
type Artifact struct {
Path string `json:"path"`
IsDir bool `json:"is_dir"`
FileSize int64 `json:"file_size,omitempty"`
}
Artifact represents a stored artifact.
type ArtifactStore ¶
type ArtifactStore interface {
// LogArtifact uploads an artifact.
LogArtifact(ctx context.Context, runID string, localPath string, artifactPath string) error
// DownloadArtifact downloads an artifact.
DownloadArtifact(ctx context.Context, runID string, artifactPath string, destPath string) error
// ListArtifacts lists artifacts for a run.
ListArtifacts(ctx context.Context, runID string, path string) ([]*Artifact, error)
}
ArtifactStore handles artifact storage.
type Experiment ¶
type Experiment struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Experiment represents an ML experiment.
type ExperimentOption ¶
type ExperimentOption func(*experimentConfig)
ExperimentOption configures experiment creation.
func WithExperimentDescription ¶
func WithExperimentDescription(desc string) ExperimentOption
WithExperimentDescription sets the experiment description.
func WithExperimentTags ¶
func WithExperimentTags(tags map[string]string) ExperimentOption
WithExperimentTags sets experiment tags.
type ExperimentTracker ¶
type ExperimentTracker interface {
// CreateExperiment creates a new experiment.
CreateExperiment(ctx context.Context, name string, opts ...ExperimentOption) (*Experiment, error)
// GetExperiment retrieves an experiment by name.
GetExperiment(ctx context.Context, name string) (*Experiment, error)
// ListExperiments lists experiments.
ListExperiments(ctx context.Context, opts ...ListOption) ([]*Experiment, error)
// StartRun starts a new run within an experiment.
StartRun(ctx context.Context, experimentName string, opts ...RunOption) (*Run, error)
// LogMetric logs a metric value.
LogMetric(ctx context.Context, runID string, key string, value float64, step int) error
// LogParam logs a parameter.
LogParam(ctx context.Context, runID string, key string, value string) error
// EndRun ends a run.
EndRun(ctx context.Context, runID string, status RunStatus) error
}
ExperimentTracker handles ML experiment tracking.
type ListOption ¶
type ListOption func(*listConfig)
ListOption configures list operations.
func WithFilter ¶
func WithFilter(filter map[string]any) ListOption
WithFilter sets the filter criteria.
type Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Stage ModelStage `json:"stage"`
Description string `json:"description,omitempty"`
RunID string `json:"run_id,omitempty"`
Source string `json:"source,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Model represents a registered model.
type ModelOption ¶
type ModelOption func(*modelConfig)
ModelOption configures model registration.
func WithModelDescription ¶
func WithModelDescription(desc string) ModelOption
WithModelDescription sets the model description.
func WithModelRunID ¶
func WithModelRunID(runID string) ModelOption
WithModelRunID sets the source run ID.
func WithModelSource ¶
func WithModelSource(source string) ModelOption
WithModelSource sets the model source path.
func WithModelTags ¶
func WithModelTags(tags map[string]string) ModelOption
WithModelTags sets the model tags.
type ModelRegistry ¶
type ModelRegistry interface {
// RegisterModel registers a model version.
RegisterModel(ctx context.Context, name string, opts ...ModelOption) (*Model, error)
// GetModel retrieves a model by name.
GetModel(ctx context.Context, name string, version ...string) (*Model, error)
// ListModels lists registered models.
ListModels(ctx context.Context, opts ...ListOption) ([]*Model, error)
// TransitionModelStage transitions a model version to a new stage.
TransitionModelStage(ctx context.Context, name string, version string, stage ModelStage) error
}
ModelRegistry handles model versioning and registry.
type ModelStage ¶
type ModelStage string
ModelStage represents the deployment stage of a model.
const ( ModelStageNone ModelStage = "None" ModelStageStaging ModelStage = "Staging" ModelStageProduction ModelStage = "Production" ModelStageArchived ModelStage = "Archived" )
type Provider ¶
type Provider interface {
ExperimentTracker
ModelRegistry
ArtifactStore
io.Closer
// Name returns the provider name.
Name() string
}
Provider is the main interface for MLOps platforms.
type Run ¶
type Run struct {
ID string `json:"id"`
ExperimentID string `json:"experiment_id"`
Name string `json:"name,omitempty"`
Status RunStatus `json:"status"`
StartTime time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time,omitempty"`
Params map[string]string `json:"params,omitempty"`
Metrics map[string]float64 `json:"metrics,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
ArtifactURI string `json:"artifact_uri,omitempty"`
}
Run represents a single run within an experiment.
type RunOption ¶
type RunOption func(*runConfig)
RunOption configures run creation.
func WithRunParams ¶
WithRunParams sets initial run parameters.