Documentation
¶
Overview ¶
Package studio provides one-click AI development environment management across various container and VM platforms (WSL, Colima, AppleContainer, K8S, Docker).
Index ¶
- Constants
- type AppleContainerBackend
- func (b *AppleContainerBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
- func (b *AppleContainerBackend) Exec(ctx context.Context, envID string, cmd []string) ([]byte, error)
- func (b *AppleContainerBackend) Get(ctx context.Context, idOrName string) (*Environment, error)
- func (b *AppleContainerBackend) IsAvailable(ctx context.Context) bool
- func (b *AppleContainerBackend) List(ctx context.Context) ([]*Environment, error)
- func (b *AppleContainerBackend) Logs(ctx context.Context, envID string, follow bool) (<-chan string, error)
- func (b *AppleContainerBackend) Mode() Mode
- func (b *AppleContainerBackend) Name() string
- func (b *AppleContainerBackend) Remove(ctx context.Context, envID string) error
- func (b *AppleContainerBackend) Start(ctx context.Context, envID string) error
- func (b *AppleContainerBackend) Stop(ctx context.Context, envID string) error
- type Architecture
- type Backend
- type ColimaBackend
- func (b *ColimaBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
- func (b *ColimaBackend) EnsureRunning(ctx context.Context) error
- func (b *ColimaBackend) Exec(ctx context.Context, envID string, cmd []string) ([]byte, error)
- func (b *ColimaBackend) Get(ctx context.Context, idOrName string) (*Environment, error)
- func (b *ColimaBackend) GetColimaIP(ctx context.Context) (string, error)
- func (b *ColimaBackend) GetProfile() string
- func (b *ColimaBackend) IsAvailable(ctx context.Context) bool
- func (b *ColimaBackend) List(ctx context.Context) ([]*Environment, error)
- func (b *ColimaBackend) Logs(ctx context.Context, envID string, follow bool) (<-chan string, error)
- func (b *ColimaBackend) Mode() Mode
- func (b *ColimaBackend) Name() string
- func (b *ColimaBackend) Remove(ctx context.Context, envID string) error
- func (b *ColimaBackend) SetDockerHost(dockerHost string)
- func (b *ColimaBackend) Start(ctx context.Context, envID string) error
- func (b *ColimaBackend) Stop(ctx context.Context, envID string) error
- type CreateOptions
- type DockerBackend
- func (b *DockerBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
- func (b *DockerBackend) Exec(ctx context.Context, envID string, cmd []string) ([]byte, error)
- func (b *DockerBackend) Get(ctx context.Context, idOrName string) (*Environment, error)
- func (b *DockerBackend) IsAvailable(ctx context.Context) bool
- func (b *DockerBackend) List(ctx context.Context) ([]*Environment, error)
- func (b *DockerBackend) Logs(ctx context.Context, envID string, follow bool) (<-chan string, error)
- func (b *DockerBackend) Mode() Mode
- func (b *DockerBackend) Name() string
- func (b *DockerBackend) Remove(ctx context.Context, envID string) error
- func (b *DockerBackend) SetupGPUEnvironment(ctx context.Context, envID string, workerURL string) error
- func (b *DockerBackend) Start(ctx context.Context, envID string) error
- func (b *DockerBackend) Stop(ctx context.Context, envID string) error
- type Environment
- type EnvironmentStatus
- type LibraryDownloader
- func (d *LibraryDownloader) Download(lib LibraryInfo) (string, error)
- func (d *LibraryDownloader) DownloadDefaultLibraries() ([]string, error)
- func (d *LibraryDownloader) DownloadURL(lib LibraryInfo) string
- func (d *LibraryDownloader) GetCacheDir() string
- func (d *LibraryDownloader) SetCacheDir(dir string)
- type LibraryInfo
- type Manager
- func (m *Manager) AddSSHConfig(env *Environment) error
- func (m *Manager) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
- func (m *Manager) Get(ctx context.Context, idOrName string) (*Environment, error)
- func (m *Manager) GetBackend(mode Mode) (Backend, error)
- func (m *Manager) List(ctx context.Context) ([]*Environment, error)
- func (m *Manager) ListAvailableBackends(ctx context.Context) []Backend
- func (m *Manager) RegisterBackend(backend Backend)
- func (m *Manager) Remove(ctx context.Context, idOrName string) error
- func (m *Manager) RemoveSSHConfig(envName string) error
- func (m *Manager) Start(ctx context.Context, idOrName string) error
- func (m *Manager) Stop(ctx context.Context, idOrName string) error
- type Mode
- type PortMapping
- type ResourceSpec
- type SSHConfig
- type StudioImage
- type VolumeMount
- type WSLBackend
- func (b *WSLBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
- func (b *WSLBackend) EnsureSSHServer(ctx context.Context, envID string) error
- func (b *WSLBackend) Exec(ctx context.Context, envID string, cmd []string) ([]byte, error)
- func (b *WSLBackend) Get(ctx context.Context, idOrName string) (*Environment, error)
- func (b *WSLBackend) GetDistro(ctx context.Context) (string, error)
- func (b *WSLBackend) GetWSLIP(ctx context.Context) (string, error)
- func (b *WSLBackend) IsAvailable(ctx context.Context) bool
- func (b *WSLBackend) List(ctx context.Context) ([]*Environment, error)
- func (b *WSLBackend) Logs(ctx context.Context, envID string, follow bool) (<-chan string, error)
- func (b *WSLBackend) Mode() Mode
- func (b *WSLBackend) Name() string
- func (b *WSLBackend) Remove(ctx context.Context, envID string) error
- func (b *WSLBackend) SetDistro(distro string)
- func (b *WSLBackend) Start(ctx context.Context, envID string) error
- func (b *WSLBackend) Stop(ctx context.Context, envID string) error
Constants ¶
const ( // CDN base URL for TensorFusion libraries DefaultCDNURL = "https://cdn.tensor-fusion.ai" // Library version - this would normally come from config DefaultLibVersion = "v1.0.0" )
const ( OSDarwin = "darwin" OSLinux = "linux" OSWindows = "windows" )
Platform constants for runtime.GOOS comparisons
const ( DefaultProtocolTCP = "tcp" MountOptionReadOnly = ":ro" DefaultImageStudioTorch = "tensorfusion/studio-torch:latest" DockerStateRunning = "running" DockerStateExited = "exited" DockerStateCreated = "created" DefaultHostLocalhost = "localhost" )
Docker-related constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppleContainerBackend ¶
type AppleContainerBackend struct {
// contains filtered or unexported fields
}
AppleContainerBackend implements the Backend interface using Apple native containers This uses Docker CLI with the assumption that Docker Desktop or similar is running on macOS using Apple Virtualization Framework
func NewAppleContainerBackend ¶
func NewAppleContainerBackend() *AppleContainerBackend
NewAppleContainerBackend creates a new Apple container backend
func (*AppleContainerBackend) Create ¶
func (b *AppleContainerBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
func (*AppleContainerBackend) Get ¶
func (b *AppleContainerBackend) Get(ctx context.Context, idOrName string) (*Environment, error)
func (*AppleContainerBackend) IsAvailable ¶
func (b *AppleContainerBackend) IsAvailable(ctx context.Context) bool
func (*AppleContainerBackend) List ¶
func (b *AppleContainerBackend) List(ctx context.Context) ([]*Environment, error)
func (*AppleContainerBackend) Mode ¶
func (b *AppleContainerBackend) Mode() Mode
func (*AppleContainerBackend) Name ¶
func (b *AppleContainerBackend) Name() string
func (*AppleContainerBackend) Remove ¶
func (b *AppleContainerBackend) Remove(ctx context.Context, envID string) error
type Architecture ¶
Architecture detection
func DetectArchitecture ¶
func DetectArchitecture() Architecture
DetectArchitecture detects the current system architecture
func (Architecture) String ¶
func (a Architecture) String() string
String returns the architecture string for CDN lookup
type Backend ¶
type Backend interface {
// Name returns the backend name
Name() string
// Mode returns the mode this backend handles
Mode() Mode
// IsAvailable checks if this backend is available on the system
IsAvailable(ctx context.Context) bool
// Create creates a new environment
Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
// Start starts a stopped environment
Start(ctx context.Context, envID string) error
// Stop stops a running environment
Stop(ctx context.Context, envID string) error
// Remove removes an environment
Remove(ctx context.Context, envID string) error
// List lists all environments
List(ctx context.Context) ([]*Environment, error)
// Get gets an environment by ID or name
Get(ctx context.Context, idOrName string) (*Environment, error)
// Exec executes a command in an environment
Exec(ctx context.Context, envID string, cmd []string) ([]byte, error)
// Logs returns logs from an environment
Logs(ctx context.Context, envID string, follow bool) (<-chan string, error)
}
Backend is the interface for container/VM runtime backends
type ColimaBackend ¶
type ColimaBackend struct {
// contains filtered or unexported fields
}
ColimaBackend implements the Backend interface using Colima (macOS/Linux)
func NewColimaBackend ¶
func NewColimaBackend() *ColimaBackend
NewColimaBackend creates a new Colima backend
func NewColimaBackendWithProfile ¶
func NewColimaBackendWithProfile(profile string) *ColimaBackend
NewColimaBackendWithProfile creates a new Colima backend with specific profile
func (*ColimaBackend) Create ¶
func (b *ColimaBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
func (*ColimaBackend) EnsureRunning ¶
func (b *ColimaBackend) EnsureRunning(ctx context.Context) error
EnsureRunning ensures Colima is running
func (*ColimaBackend) Get ¶
func (b *ColimaBackend) Get(ctx context.Context, idOrName string) (*Environment, error)
func (*ColimaBackend) GetColimaIP ¶
func (b *ColimaBackend) GetColimaIP(ctx context.Context) (string, error)
GetColimaIP returns the IP address of the Colima VM
func (*ColimaBackend) GetProfile ¶
func (b *ColimaBackend) GetProfile() string
GetProfile returns the Colima profile name
func (*ColimaBackend) IsAvailable ¶
func (b *ColimaBackend) IsAvailable(ctx context.Context) bool
func (*ColimaBackend) List ¶
func (b *ColimaBackend) List(ctx context.Context) ([]*Environment, error)
func (*ColimaBackend) Mode ¶
func (b *ColimaBackend) Mode() Mode
func (*ColimaBackend) Name ¶
func (b *ColimaBackend) Name() string
func (*ColimaBackend) Remove ¶
func (b *ColimaBackend) Remove(ctx context.Context, envID string) error
func (*ColimaBackend) SetDockerHost ¶
func (b *ColimaBackend) SetDockerHost(dockerHost string)
SetDockerHost sets a custom Docker socket path
type CreateOptions ¶
type CreateOptions struct {
Name string `json:"name"`
Mode Mode `json:"mode"`
Image string `json:"image"`
GPUWorkerURL string `json:"gpu_worker_url,omitempty"`
SSHPublicKey string `json:"ssh_public_key,omitempty"`
WorkDir string `json:"work_dir,omitempty"`
Ports []PortMapping `json:"ports,omitempty"`
Envs map[string]string `json:"envs,omitempty"`
Volumes []VolumeMount `json:"volumes,omitempty"`
Resources ResourceSpec `json:"resources,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
CreateOptions contains options for creating an environment
type DockerBackend ¶
type DockerBackend struct {
// contains filtered or unexported fields
}
DockerBackend implements the Backend interface using Docker
func NewDockerBackend ¶
func NewDockerBackend() *DockerBackend
NewDockerBackend creates a new Docker backend
func NewDockerBackendWithHost ¶
func NewDockerBackendWithHost(dockerHost string) *DockerBackend
NewDockerBackendWithHost creates a new Docker backend with custom host
func NewPodmanBackend ¶
func NewPodmanBackend() *DockerBackend
NewPodmanBackend creates a new Podman backend (uses Docker interface)
func (*DockerBackend) Create ¶
func (b *DockerBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
func (*DockerBackend) Get ¶
func (b *DockerBackend) Get(ctx context.Context, idOrName string) (*Environment, error)
func (*DockerBackend) IsAvailable ¶
func (b *DockerBackend) IsAvailable(ctx context.Context) bool
func (*DockerBackend) List ¶
func (b *DockerBackend) List(ctx context.Context) ([]*Environment, error)
func (*DockerBackend) Mode ¶
func (b *DockerBackend) Mode() Mode
func (*DockerBackend) Name ¶
func (b *DockerBackend) Name() string
func (*DockerBackend) Remove ¶
func (b *DockerBackend) Remove(ctx context.Context, envID string) error
func (*DockerBackend) SetupGPUEnvironment ¶
func (b *DockerBackend) SetupGPUEnvironment(ctx context.Context, envID string, workerURL string) error
SetupGPUEnvironment configures the container for GPU access
type Environment ¶
type Environment struct {
ID string `json:"id"`
Name string `json:"name"`
Mode Mode `json:"mode"`
Image string `json:"image"`
Status EnvironmentStatus `json:"status"`
ConnectionURL string `json:"connection_url,omitempty"`
SSHHost string `json:"ssh_host,omitempty"`
SSHPort int `json:"ssh_port,omitempty"`
SSHUser string `json:"ssh_user,omitempty"`
WorkDir string `json:"work_dir,omitempty"`
GPUWorkerURL string `json:"gpu_worker_url,omitempty"`
CreatedAt time.Time `json:"created_at"`
Labels map[string]string `json:"labels,omitempty"`
}
Environment represents a running studio environment
type EnvironmentStatus ¶
type EnvironmentStatus string
EnvironmentStatus represents the status of an environment
const ( StatusPending EnvironmentStatus = "pending" StatusPulling EnvironmentStatus = "pulling" StatusStarting EnvironmentStatus = "starting" StatusRunning EnvironmentStatus = "running" StatusStopped EnvironmentStatus = "stopped" StatusError EnvironmentStatus = "error" StatusTerminated EnvironmentStatus = "terminated" )
type LibraryDownloader ¶
type LibraryDownloader struct {
// contains filtered or unexported fields
}
LibraryDownloader handles downloading versioned GPU libraries from CDN
func NewLibraryDownloader ¶
func NewLibraryDownloader(cdnURL, version string) *LibraryDownloader
NewLibraryDownloader creates a new library downloader
func (*LibraryDownloader) Download ¶
func (d *LibraryDownloader) Download(lib LibraryInfo) (string, error)
Download downloads a library from the CDN
func (*LibraryDownloader) DownloadDefaultLibraries ¶
func (d *LibraryDownloader) DownloadDefaultLibraries() ([]string, error)
DownloadDefaultLibraries downloads the default set of GPU libraries
func (*LibraryDownloader) DownloadURL ¶
func (d *LibraryDownloader) DownloadURL(lib LibraryInfo) string
DownloadURL constructs the CDN download URL for a library
func (*LibraryDownloader) GetCacheDir ¶
func (d *LibraryDownloader) GetCacheDir() string
GetCacheDir returns the cache directory path
func (*LibraryDownloader) SetCacheDir ¶
func (d *LibraryDownloader) SetCacheDir(dir string)
SetCacheDir sets a custom cache directory
type LibraryInfo ¶
type LibraryInfo struct {
Name string
Version string
Arch Architecture
Checksum string // SHA256 checksum
}
LibraryInfo contains information about a library to download
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages AI studio environments across different backends
func (*Manager) AddSSHConfig ¶
func (m *Manager) AddSSHConfig(env *Environment) error
AddSSHConfig adds an SSH config entry for an environment
func (*Manager) Create ¶
func (m *Manager) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
Create creates a new environment
func (*Manager) GetBackend ¶
GetBackend returns a backend by mode
func (*Manager) List ¶
func (m *Manager) List(ctx context.Context) ([]*Environment, error)
List lists all environments across all backends
func (*Manager) ListAvailableBackends ¶
ListAvailableBackends returns all available backends
func (*Manager) RegisterBackend ¶
RegisterBackend registers a backend
func (*Manager) RemoveSSHConfig ¶
RemoveSSHConfig removes an SSH config entry for an environment
type Mode ¶
type Mode string
Mode represents the container/VM runtime mode
const ( ModeWSL Mode = "wsl" // Windows Subsystem for Linux ModeColima Mode = "colima" // Colima (macOS/Linux) ModeAppleContainer Mode = "apple" // Apple Virtualization Framework ModeDocker Mode = "docker" // Native Docker ModeKubernetes Mode = "k8s" // Kubernetes (kind, minikube, etc.) ModeAuto Mode = "auto" // Auto-detect best option )
type PortMapping ¶
type PortMapping struct {
HostPort int `json:"host_port"`
ContainerPort int `json:"container_port"`
Protocol string `json:"protocol,omitempty"` // tcp, udp
}
PortMapping represents a port mapping
type ResourceSpec ¶
type ResourceSpec struct {
CPUs float64 `json:"cpus,omitempty"`
Memory string `json:"memory,omitempty"` // e.g., "8Gi"
}
ResourceSpec represents resource limits
type SSHConfig ¶
type SSHConfig struct {
Host string
HostName string
User string
Port int
IdentityFile string
ExtraOptions map[string]string
}
SSHConfig represents an SSH configuration entry
func (*SSHConfig) GenerateSSHConfigEntry ¶
GenerateSSHConfigEntry generates an SSH config entry string
type StudioImage ¶
type StudioImage struct {
Name string `json:"name"`
Tag string `json:"tag"`
Description string `json:"description"`
Features []string `json:"features"` // torch, cuda, ssh, jupyter, etc.
Size string `json:"size"`
Registry string `json:"registry"`
Labels map[string]string `json:"labels,omitempty"`
}
StudioImage represents a pre-configured AI development image
func DefaultImages ¶
func DefaultImages() []StudioImage
DefaultImages returns the list of available studio images
type VolumeMount ¶
type VolumeMount struct {
HostPath string `json:"host_path"`
ContainerPath string `json:"container_path"`
ReadOnly bool `json:"read_only,omitempty"`
}
VolumeMount represents a volume mount
type WSLBackend ¶
type WSLBackend struct {
// contains filtered or unexported fields
}
WSLBackend implements the Backend interface using Windows Subsystem for Linux
func NewWSLBackendWithDistro ¶
func NewWSLBackendWithDistro(distro string) *WSLBackend
NewWSLBackendWithDistro creates a new WSL backend with specific distro
func (*WSLBackend) Create ¶
func (b *WSLBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)
func (*WSLBackend) EnsureSSHServer ¶
func (b *WSLBackend) EnsureSSHServer(ctx context.Context, envID string) error
EnsureSSHServer ensures SSH server is running in the container
func (*WSLBackend) Get ¶
func (b *WSLBackend) Get(ctx context.Context, idOrName string) (*Environment, error)
func (*WSLBackend) GetDistro ¶
func (b *WSLBackend) GetDistro(ctx context.Context) (string, error)
GetDistro returns the configured or default WSL distribution
func (*WSLBackend) GetWSLIP ¶
func (b *WSLBackend) GetWSLIP(ctx context.Context) (string, error)
GetWSLIP returns the IP address of the WSL instance
func (*WSLBackend) IsAvailable ¶
func (b *WSLBackend) IsAvailable(ctx context.Context) bool
func (*WSLBackend) List ¶
func (b *WSLBackend) List(ctx context.Context) ([]*Environment, error)
func (*WSLBackend) Mode ¶
func (b *WSLBackend) Mode() Mode
func (*WSLBackend) Name ¶
func (b *WSLBackend) Name() string
func (*WSLBackend) SetDistro ¶
func (b *WSLBackend) SetDistro(distro string)
SetDistro sets the WSL distribution name