Documentation
¶
Index ¶
- Constants
- Variables
- func DockerImageName(projectDir string) string
- func GetProjectDir(configFilename string) (string, error)
- type ArgumentType
- type Build
- type BuildOptions
- type CUDABaseImage
- type CompatibilityError
- type Concurrency
- type Config
- func (c *Config) CUDABaseImageTag() (string, error)
- func (c *Config) Complete(projectDir string) error
- func (c *Config) ParsedEnvironment() map[string]string
- func (c *Config) PythonRequirementsForArch(goos string, goarch string, includePackages []string) (string, error)
- func (c *Config) RequirementsFile(projectDir string) string
- func (c *Config) TensorFlowVersion() (string, bool)
- func (c *Config) TorchVersion() (string, bool)
- func (c *Config) TorchaudioVersion() (string, bool)
- func (c *Config) TorchvisionVersion() (string, bool)
- type ConfigError
- type DeprecationWarning
- type LoadResult
- type ParseError
- type RunArgument
- type RunItem
- type SchemaError
- type TFCompatibility
- type TorchCompatibility
- type ValidateOption
- type ValidationError
- type ValidationResult
- type WeightSource
Constants ¶
Variables ¶
var ( BuildSourceEpochTimestamp int64 = -1 BuildXCachePath string PipPackageNameRegex = regexp.MustCompile(`^([^>=<~ \n[#]+)`) )
var CUDABaseImages []CUDABaseImage
var TFCompatibilityMatrix []TFCompatibility
var TorchCompatibilityMatrix []TorchCompatibility
Functions ¶
func DockerImageName ¶ added in v0.0.8
DockerImageName returns the default Docker image name for images
func GetProjectDir ¶
GetProjectDir returns the project's root directory by searching for the config file starting from the current working directory.
Types ¶
type ArgumentType ¶ added in v0.0.8
type ArgumentType string
ArgumentType represents the type of a run argument.
const ( ArgumentTypeString ArgumentType = "str" ArgumentTypeInt ArgumentType = "int" ArgumentTypeFloat ArgumentType = "float" ArgumentTypeBool ArgumentType = "bool" ArgumentTypePath ArgumentType = "Path" )
type Build ¶ added in v0.0.8
type Build struct {
GPU bool `json:"gpu,omitempty" yaml:"gpu,omitempty"`
PythonVersion string `json:"python_version,omitempty" yaml:"python_version"`
PythonRequirements string `json:"python_requirements,omitempty" yaml:"python_requirements,omitempty"`
PythonPackages []string `json:"python_packages,omitempty" yaml:"python_packages,omitempty"` // Deprecated, but included for backwards compatibility
Run []RunItem `json:"run,omitempty" yaml:"run,omitempty"`
SystemPackages []string `json:"system_packages,omitempty" yaml:"system_packages,omitempty"`
PreInstall []string `json:"pre_install,omitempty" yaml:"pre_install,omitempty"` // Deprecated, but included for backwards compatibility
CUDA string `json:"cuda,omitempty" yaml:"cuda,omitempty"`
CuDNN string `json:"cudnn,omitempty" yaml:"cudnn,omitempty"`
// SDKVersion pins the cog Python SDK version installed in the container.
// Accepts a PEP 440 version string (e.g. "0.18.0" or "0.18.0a1").
// When empty the latest release is installed. Overridden by COG_SDK_WHEEL env var.
SDKVersion string `json:"sdk_version,omitempty" yaml:"sdk_version,omitempty"`
// contains filtered or unexported fields
}
type BuildOptions ¶ added in v0.17.0
type BuildOptions struct {
// SourceEpochTimestamp is the number of seconds since Unix epoch to use
// for the build timestamp. Set to -1 to disable timestamp rewrites.
// This is useful for reproducible builds.
SourceEpochTimestamp int64
// XCachePath is the path to the BuildKit cache directory.
// If empty, inline caching is used instead of local cache.
XCachePath string
}
BuildOptions contains runtime options passed via CLI flags, not from cog.yaml. These are separate from the Config struct because they are not part of the model configuration - they are build-time settings that affect how the container is built but not what's in it.
func DefaultBuildOptions ¶ added in v0.17.0
func DefaultBuildOptions() BuildOptions
DefaultBuildOptions returns BuildOptions with sensible defaults.
type CUDABaseImage ¶ added in v0.0.8
func (*CUDABaseImage) ImageTag ¶ added in v0.0.8
func (i *CUDABaseImage) ImageTag() string
type CompatibilityError ¶ added in v0.17.0
type CompatibilityError struct {
Component1 string
Version1 string
Component2 string
Version2 string
Message string
}
CompatibilityError indicates an incompatible version combination.
func (*CompatibilityError) ConfigError ¶ added in v0.17.0
func (e *CompatibilityError) ConfigError()
func (*CompatibilityError) Error ¶ added in v0.17.0
func (e *CompatibilityError) Error() string
type Concurrency ¶ added in v0.13.7
type Concurrency struct {
Max int `json:"max,omitempty" yaml:"max"`
}
type Config ¶ added in v0.0.8
type Config struct {
Build *Build `json:"build" yaml:"build"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
Predict string `json:"predict,omitempty" yaml:"predict"`
Train string `json:"train,omitempty" yaml:"train,omitempty"`
Concurrency *Concurrency `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
Environment []string `json:"environment,omitempty" yaml:"environment,omitempty"`
Weights []WeightSource `json:"weights,omitempty" yaml:"weights,omitempty"`
// contains filtered or unexported fields
}
func FromYAML ¶ added in v0.0.16
FromYAML parses YAML content into an uncompleted Config. This is a convenience function primarily for testing. Callers should call Complete() on the returned config to resolve CUDA versions etc. For production code, use Load() which handles validation and completion.
Note: This function skips validation since it has no project directory context. The Complete() method will validate requirements files exist when called.
func (*Config) CUDABaseImageTag ¶ added in v0.0.8
func (*Config) Complete ¶ added in v0.17.0
Complete performs CUDA resolution, requirements loading, and environment loading for a Config. Use this when building a Config struct directly (not from YAML). For configs loaded from YAML, use Load() instead which handles validation and completion.
func (*Config) ParsedEnvironment ¶ added in v0.14.9
func (*Config) PythonRequirementsForArch ¶ added in v0.5.0
func (c *Config) PythonRequirementsForArch(goos string, goarch string, includePackages []string) (string, error)
PythonRequirementsForArch returns a requirements.txt file with all the GPU packages resolved for given OS and architecture.
func (*Config) RequirementsFile ¶ added in v0.15.2
func (*Config) TensorFlowVersion ¶ added in v0.9.7
func (*Config) TorchVersion ¶ added in v0.9.7
func (*Config) TorchaudioVersion ¶ added in v0.9.21
func (*Config) TorchvisionVersion ¶ added in v0.9.7
type ConfigError ¶ added in v0.17.0
type ConfigError interface {
error
ConfigError() // marker method
}
ConfigError is the base interface for all config errors. Allows callers to use errors.As to get config-specific details.
type DeprecationWarning ¶ added in v0.17.0
DeprecationWarning indicates use of a deprecated field. This is a warning, not an error - validation still succeeds.
func (*DeprecationWarning) ConfigError ¶ added in v0.17.0
func (w *DeprecationWarning) ConfigError()
func (*DeprecationWarning) Error ¶ added in v0.17.0
func (w *DeprecationWarning) Error() string
type LoadResult ¶ added in v0.17.0
type LoadResult struct {
Config *Config
Warnings []DeprecationWarning
RootDir string
}
LoadResult contains the loaded config and any warnings.
func Load ¶ added in v0.17.0
func Load(r io.Reader, projectDir string) (*LoadResult, error)
Load parses, validates, and completes a config from an io.Reader. The projectDir is used for validation (checking that referenced files exist) and for completion (resolving CUDA versions, loading requirements files, etc.). Always returns warnings if present, even on success.
type ParseError ¶ added in v0.17.0
ParseError indicates the YAML file could not be parsed.
func (*ParseError) ConfigError ¶ added in v0.17.0
func (e *ParseError) ConfigError()
func (*ParseError) Error ¶ added in v0.17.0
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶ added in v0.17.0
func (e *ParseError) Unwrap() error
type RunArgument ¶ added in v0.0.8
type RunArgument struct {
Type ArgumentType `json:"type"`
Default *string `json:"default"`
Min *string `json:"min"`
Max *string `json:"max"`
Options *[]string `json:"options"`
Help *string `json:"help"`
}
RunArgument describes a single argument for a prediction run.
type RunItem ¶ added in v0.7.0
type RunItem struct {
Command string `json:"command,omitempty" yaml:"command"`
Mounts []struct {
Type string `json:"type,omitempty" yaml:"type"`
ID string `json:"id,omitempty" yaml:"id"`
Target string `json:"target,omitempty" yaml:"target"`
} `json:"mounts,omitempty" yaml:"mounts,omitempty"`
}
func (*RunItem) UnmarshalJSON ¶ added in v0.7.1
type SchemaError ¶ added in v0.17.0
SchemaError indicates the config structure doesn't match the schema. For example, wrong type for a field or unknown field.
func (*SchemaError) ConfigError ¶ added in v0.17.0
func (e *SchemaError) ConfigError()
func (*SchemaError) Error ¶ added in v0.17.0
func (e *SchemaError) Error() string
type TFCompatibility ¶ added in v0.0.8
type TFCompatibility struct {
TF string
TFCPUPackage string
TFGPUPackage string
CUDA string
CuDNN string
Pythons []string
}
func (*TFCompatibility) UnmarshalJSON ¶ added in v0.0.8
func (compat *TFCompatibility) UnmarshalJSON(data []byte) error
type TorchCompatibility ¶ added in v0.0.8
type TorchCompatibility struct {
Torch string
Torchvision string
Torchaudio string
FindLinks string
ExtraIndexURL string
CUDA *string
Pythons []string
}
func (*TorchCompatibility) TorchVersion ¶ added in v0.0.8
func (c *TorchCompatibility) TorchVersion() string
func (*TorchCompatibility) TorchvisionVersion ¶ added in v0.0.8
func (c *TorchCompatibility) TorchvisionVersion() string
type ValidateOption ¶ added in v0.17.0
type ValidateOption func(*validateOptions)
ValidateOption configures validation behavior.
func WithProjectDir ¶ added in v0.17.0
func WithProjectDir(dir string) ValidateOption
WithProjectDir sets the project directory for resolving relative paths.
func WithRequirementsFS ¶ added in v0.17.0
func WithRequirementsFS(fsys fs.FS) ValidateOption
WithRequirementsFS sets the filesystem for reading python_requirements file.
func WithStrictDeprecations ¶ added in v0.17.0
func WithStrictDeprecations() ValidateOption
WithStrictDeprecations treats deprecation warnings as errors.
type ValidationError ¶ added in v0.17.0
ValidationError indicates a semantic validation failure. The config parses correctly but values are invalid.
func (*ValidationError) ConfigError ¶ added in v0.17.0
func (e *ValidationError) ConfigError()
func (*ValidationError) Error ¶ added in v0.17.0
func (e *ValidationError) Error() string
type ValidationResult ¶ added in v0.17.0
type ValidationResult struct {
Errors []error
Warnings []DeprecationWarning
}
ValidationResult holds all errors and warnings from validation.
func NewValidationResult ¶ added in v0.17.0
func NewValidationResult() *ValidationResult
NewValidationResult creates an empty ValidationResult.
func ValidateConfigFile ¶ added in v0.17.0
func ValidateConfigFile(cfg *configFile, opts ...ValidateOption) *ValidationResult
ValidateConfigFile checks a configFile for errors. Returns all validation errors and deprecation warnings. Does not mutate the input.
func (*ValidationResult) AddError ¶ added in v0.17.0
func (r *ValidationResult) AddError(err error)
AddError adds a validation error.
func (*ValidationResult) AddWarning ¶ added in v0.17.0
func (r *ValidationResult) AddWarning(w DeprecationWarning)
AddWarning adds a deprecation warning.
func (*ValidationResult) Err ¶ added in v0.17.0
func (r *ValidationResult) Err() error
Err returns a combined error if there are any validation errors, nil otherwise.
func (*ValidationResult) HasErrors ¶ added in v0.17.0
func (r *ValidationResult) HasErrors() bool
HasErrors returns true if there are any validation errors.
func (*ValidationResult) HasWarnings ¶ added in v0.17.0
func (r *ValidationResult) HasWarnings() bool
HasWarnings returns true if there are any deprecation warnings.
type WeightSource ¶ added in v0.17.0
type WeightSource struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Source string `json:"source" yaml:"source"`
Target string `json:"target,omitempty" yaml:"target,omitempty"`
}
WeightSource defines a weight file or directory to include in the model.