Documentation
¶
Overview ¶
Package deps manages external dependencies for GPU Go, including downloading and managing vgpu libraries from the CDN.
Index ¶
- Constants
- type DownloadedManifest
- type Library
- type LocalManifest
- type Manager
- func (m *Manager) CheckUpdates(ctx context.Context) ([]Library, error)
- func (m *Manager) CleanCache() error
- func (m *Manager) DownloadLibrary(ctx context.Context, lib Library, progressFn func(downloaded, total int64)) error
- func (m *Manager) FetchManifest(ctx context.Context) (*Manifest, bool, error)
- func (m *Manager) GetAllLibraries(manifest *Manifest) []Library
- func (m *Manager) GetDownloadedLibraries() (*DownloadedManifest, error)
- func (m *Manager) GetInstalledLibraries() (*LocalManifest, error)
- func (m *Manager) GetLibrariesForPlatform(manifest *Manifest, osStr, arch, libType string) []Library
- func (m *Manager) GetLibraryPath(name string) string
- func (m *Manager) GetRemoteGPUWorkerPath(ctx context.Context) (string, error)
- func (m *Manager) InstallLibrary(lib Library) error
- func (m *Manager) LoadCachedManifest() (*Manifest, error)
- func (m *Manager) SyncReleases(ctx context.Context, osStr, arch string) (*Manifest, error)
- func (m *Manager) VerifyLibrary(path, expectedHash string) bool
- type ManagerOption
- type Manifest
Constants ¶
const ( // DefaultCDNBaseURL is the default CDN for downloading dependencies DefaultCDNBaseURL = "https://cdn.tensor-fusion.ai" // ManifestPath is the path to the version manifest on CDN ManifestPath = "/vgpu/manifest.json" // CachedManifestFile is the filename for the cached releases manifest CachedManifestFile = "releases-manifest.json" // DownloadedManifestFile is the filename for the downloaded dependencies manifest DownloadedManifestFile = "downloaded-manifest.json" // InstalledManifestFile is the filename for the installed dependencies manifest InstalledManifestFile = "deps-manifest.json" // AutoSyncInterval is the interval for auto-syncing the manifest AutoSyncInterval = 7 * 24 * time.Hour )
const ( LibraryTypeVGPULibrary = "vgpu-library" LibraryTypeRemoteGPUWorker = "remote-gpu-worker" LibraryTypeRemoteGPUClient = "remote-gpu-client" )
Library type constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DownloadedManifest ¶
type DownloadedManifest struct {
UpdatedAt time.Time `json:"updated_at"`
Libraries map[string]Library `json:"libraries"` // name -> library
}
DownloadedManifest represents locally downloaded dependencies
type Library ¶
type Library struct {
Name string `json:"name"`
Version string `json:"version"`
Platform string `json:"platform"` // linux, darwin, windows
Arch string `json:"arch"` // amd64, arm64
URL string `json:"url"`
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
Type string `json:"type,omitempty"` // e.g., "vgpu-library", "remote-gpu-worker", "remote-gpu-client"
// Vendor information from release
VendorSlug string `json:"vendorSlug,omitempty"` // e.g., "stub", "nvidia", "amd"
VendorName string `json:"vendorName,omitempty"` // e.g., "STUB", "NVIDIA", "AMD"
}
Library represents a downloadable library
type LocalManifest ¶
type LocalManifest struct {
InstalledAt time.Time `json:"installed_at"`
Libraries map[string]Library `json:"libraries"` // name -> library
}
LocalManifest represents locally installed dependencies
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages dependency downloads and versions
func NewManager ¶
func NewManager(opts ...ManagerOption) *Manager
NewManager creates a new dependency manager
func (*Manager) CheckUpdates ¶
CheckUpdates checks if any installed libraries have updates available
func (*Manager) CleanCache ¶
CleanCache removes all cached downloads
func (*Manager) DownloadLibrary ¶
func (m *Manager) DownloadLibrary(ctx context.Context, lib Library, progressFn func(downloaded, total int64)) error
DownloadLibrary downloads a library to the cache directory
func (*Manager) FetchManifest ¶
FetchManifest loads the cached manifest, and syncs from API if not available or outdated Returns true as second argument if an auto-sync was performed and updates were found
func (*Manager) GetAllLibraries ¶
GetAllLibraries returns all libraries from the manifest, grouped by platform/arch
func (*Manager) GetDownloadedLibraries ¶
func (m *Manager) GetDownloadedLibraries() (*DownloadedManifest, error)
GetDownloadedLibraries returns the downloaded libraries
func (*Manager) GetInstalledLibraries ¶
func (m *Manager) GetInstalledLibraries() (*LocalManifest, error)
GetInstalledLibraries returns the locally installed libraries
func (*Manager) GetLibrariesForPlatform ¶
func (m *Manager) GetLibrariesForPlatform(manifest *Manifest, osStr, arch, libType string) []Library
GetLibrariesForPlatform returns libraries matching the specified platform and type If both os and arch are empty strings, uses the current platform If only os is provided, matches any arch for that os If only arch is provided, matches any os for that arch If type is empty string, matches any type
func (*Manager) GetLibraryPath ¶
GetLibraryPath returns the path to an installed library (in cache)
func (*Manager) GetRemoteGPUWorkerPath ¶
GetRemoteGPUWorkerPath returns the path to the remote-gpu-worker binary It first checks if already installed, if not downloads it from the API
func (*Manager) InstallLibrary ¶
InstallLibrary installs a downloaded library (marks it as installed)
func (*Manager) LoadCachedManifest ¶
LoadCachedManifest loads the cached manifest from local storage
func (*Manager) SyncReleases ¶
SyncReleases fetches releases from the API and caches them locally If os and arch are empty strings, uses the current platform Returns the synced manifest for verbose output
func (*Manager) VerifyLibrary ¶
VerifyLibrary checks if a file exists and has the expected hash Returns true if expectedHash is empty (verification skipped)
type ManagerOption ¶
type ManagerOption func(*Manager)
ManagerOption configures the dependency manager
func WithAPIBaseURL ¶
func WithAPIBaseURL(url string) ManagerOption
WithAPIBaseURL sets a custom API base URL
func WithAPIClient ¶
func WithAPIClient(client *api.Client) ManagerOption
WithAPIClient sets a custom API client
func WithCDNBaseURL ¶
func WithCDNBaseURL(url string) ManagerOption
WithCDNBaseURL sets a custom CDN base URL