Documentation
¶
Overview ¶
Package deps manages external dependencies for GPU Go, including downloading and managing vgpu libraries from the CDN.
Index ¶
- Constants
- type DepsManifest
- type DownloadResult
- type DownloadStatus
- 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) ComputeUpdateDiff() (*UpdateDiff, error)
- func (m *Manager) DownloadAllRequired(ctx context.Context, progressFn func(lib Library, downloaded, total int64)) ([]DownloadResult, error)
- func (m *Manager) DownloadLibrary(ctx context.Context, lib Library, progressFn func(downloaded, total int64)) error
- func (m *Manager) EnsureLibrariesByTypes(ctx context.Context, libTypes []string, vendorSlug string, ...) ([]Library, error)
- func (m *Manager) EnsureLibraryByType(ctx context.Context, libType string, vendorSlug string) (string, error)
- func (m *Manager) FetchManifest(ctx context.Context) (*ReleaseManifest, bool, error)
- func (m *Manager) FetchReleaseManifest(ctx context.Context) (*ReleaseManifest, bool, error)
- func (m *Manager) GetAllLibraries(manifest *ReleaseManifest) []Library
- func (m *Manager) GetDownloadedLibraries() (*DownloadedManifest, error)
- func (m *Manager) GetInstalledLibraries() (*DepsManifest, error)
- func (m *Manager) GetLibrariesForPlatform(manifest *ReleaseManifest, 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() (*ReleaseManifest, error)
- func (m *Manager) LoadDepsManifest() (*DepsManifest, error)
- func (m *Manager) LoadDownloadedManifest() (*DownloadedManifest, error)
- func (m *Manager) LoadReleaseManifest() (*ReleaseManifest, error)
- func (m *Manager) SaveDepsManifest(manifest *DepsManifest) error
- func (m *Manager) SelectRequiredDeps(manifest *ReleaseManifest) *DepsManifest
- func (m *Manager) SyncReleases(ctx context.Context, osStr, arch string) (*ReleaseManifest, error)
- func (m *Manager) UpdateDepsManifest(ctx context.Context) (*DepsManifest, []Library, error)
- func (m *Manager) VerifyLibrary(path, expectedHash string) bool
- type ManagerOption
- type Manifest
- type ReleaseManifest
- type UpdateDiff
Constants ¶
const ( // DefaultCDNBaseURL is the default CDN for downloading dependencies DefaultCDNBaseURL = "https://cdn.tensor-fusion.ai" // ReleaseManifestFile is the filename for the cached releases manifest (from API sync) ReleaseManifestFile = "releases-manifest.json" // DepsManifestFile is the filename for the required dependencies manifest DepsManifestFile = "deps-manifest.json" // DownloadedManifestFile is the filename for the downloaded dependencies manifest DownloadedManifestFile = "downloaded-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 DepsManifest ¶ added in v1.1.7
type DepsManifest struct {
UpdatedAt time.Time `json:"updated_at"`
Libraries map[string]Library `json:"libraries"` // key -> library
}
DepsManifest represents the required dependencies for current environment
type DownloadResult ¶ added in v1.1.7
type DownloadResult struct {
Library Library `json:"library"`
Status DownloadStatus `json:"status"`
Error string `json:"error,omitempty"`
}
DownloadResult represents the result of downloading a library
type DownloadStatus ¶ added in v1.1.7
type DownloadStatus string
DownloadStatus represents the status of a library during download
const ( DownloadStatusNew DownloadStatus = "new" DownloadStatusUpdated DownloadStatus = "updated" DownloadStatusExisting DownloadStatus = "existing" DownloadStatusFailed DownloadStatus = "failed" )
type DownloadedManifest ¶
type DownloadedManifest struct {
UpdatedAt time.Time `json:"updated_at"`
Libraries map[string]Library `json:"libraries"` // key -> 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 = DepsManifest
LocalManifest is an alias for DepsManifest for backward compatibility
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 deps manifest has updates compared to downloaded manifest Returns the libraries that need to be downloaded
func (*Manager) CleanCache ¶
CleanCache removes all cached downloads
func (*Manager) ComputeUpdateDiff ¶ added in v1.1.7
func (m *Manager) ComputeUpdateDiff() (*UpdateDiff, error)
ComputeUpdateDiff computes the difference between deps manifest and downloaded manifest
func (*Manager) DownloadAllRequired ¶ added in v1.1.7
func (m *Manager) DownloadAllRequired(ctx context.Context, progressFn func(lib Library, downloaded, total int64)) ([]DownloadResult, error)
DownloadAllRequired downloads all libraries in deps manifest that need downloading Returns the download results for each library
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) EnsureLibrariesByTypes ¶ added in v1.1.11
func (m *Manager) EnsureLibrariesByTypes(ctx context.Context, libTypes []string, vendorSlug string, progressFn func(lib Library, downloaded, total int64)) ([]Library, error)
EnsureLibrariesByTypes ensures ALL libraries of the specified types exist and are downloaded This is different from EnsureLibraryByType which only returns one library vendorSlug filters by vendor (e.g., "nvidia", "amd"). Empty string matches all vendors. Returns the list of all libraries that were checked/downloaded
func (*Manager) EnsureLibraryByType ¶ added in v1.1.7
func (m *Manager) EnsureLibraryByType(ctx context.Context, libType string, vendorSlug string) (string, error)
EnsureLibraryByType ensures a library of the specified type exists and is downloaded If not available, it will auto-sync and download on demand Returns the path to the library
func (*Manager) FetchManifest ¶
FetchManifest is an alias for FetchReleaseManifest
func (*Manager) FetchReleaseManifest ¶ added in v1.1.7
FetchReleaseManifest loads the release manifest, and syncs from API if not available or outdated Returns (manifest, synced, error) where synced is true if auto-sync was performed
func (*Manager) GetAllLibraries ¶
func (m *Manager) GetAllLibraries(manifest *ReleaseManifest) []Library
GetAllLibraries returns all libraries from the manifest
func (*Manager) GetDownloadedLibraries ¶
func (m *Manager) GetDownloadedLibraries() (*DownloadedManifest, error)
GetDownloadedLibraries returns the downloaded manifest
func (*Manager) GetInstalledLibraries ¶
func (m *Manager) GetInstalledLibraries() (*DepsManifest, error)
GetInstalledLibraries returns the deps manifest (renamed from installed)
func (*Manager) GetLibrariesForPlatform ¶
func (m *Manager) GetLibrariesForPlatform(manifest *ReleaseManifest, 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 type is empty string, matches any type
func (*Manager) GetLibraryPath ¶
GetLibraryPath returns the path to a library in cache
func (*Manager) GetRemoteGPUWorkerPath ¶
GetRemoteGPUWorkerPath returns the path to the remote-gpu-worker binary It ensures the library exists, downloading if necessary
func (*Manager) InstallLibrary ¶
InstallLibrary marks a library as required (adds to deps manifest)
func (*Manager) LoadCachedManifest ¶
func (m *Manager) LoadCachedManifest() (*ReleaseManifest, error)
LoadCachedManifest is an alias for LoadReleaseManifest
func (*Manager) LoadDepsManifest ¶ added in v1.1.7
func (m *Manager) LoadDepsManifest() (*DepsManifest, error)
LoadDepsManifest loads the deps manifest from local storage
func (*Manager) LoadDownloadedManifest ¶ added in v1.1.7
func (m *Manager) LoadDownloadedManifest() (*DownloadedManifest, error)
LoadDownloadedManifest loads the downloaded manifest from local storage
func (*Manager) LoadReleaseManifest ¶ added in v1.1.7
func (m *Manager) LoadReleaseManifest() (*ReleaseManifest, error)
LoadReleaseManifest loads the release manifest from local storage
func (*Manager) SaveDepsManifest ¶ added in v1.1.7
func (m *Manager) SaveDepsManifest(manifest *DepsManifest) error
SaveDepsManifest saves the deps manifest to local storage
func (*Manager) SelectRequiredDeps ¶ added in v1.1.7
func (m *Manager) SelectRequiredDeps(manifest *ReleaseManifest) *DepsManifest
SelectRequiredDeps selects the required dependencies from release manifest For each library type, it selects all artifacts from the latest version This ensures that types with multiple files (like remote-gpu-client) get all files
func (*Manager) SyncReleases ¶
SyncReleases fetches releases from the API and caches them locally as release-manifest If os and arch are empty strings, uses the current platform Returns the synced manifest for verbose output
func (*Manager) UpdateDepsManifest ¶ added in v1.1.7
UpdateDepsManifest syncs releases and updates the deps manifest with latest versions Returns (updated deps manifest, list of changes from old deps)
func (*Manager) VerifyLibrary ¶
VerifyLibrary checks if a file exists and has the expected hash
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
type Manifest ¶
type Manifest = ReleaseManifest
Manifest is an alias for ReleaseManifest for backward compatibility
type ReleaseManifest ¶ added in v1.1.7
type ReleaseManifest struct {
Version string `json:"version"`
UpdatedAt time.Time `json:"updated_at"`
Libraries []Library `json:"libraries"`
}
ReleaseManifest represents the global releases manifest synced from API
type UpdateDiff ¶ added in v1.1.7
type UpdateDiff struct {
ToDownload []Library `json:"to_download"` // new or version mismatch
UpToDate []Library `json:"up_to_date"` // already downloaded with correct version
}
UpdateDiff represents the difference between deps-manifest and downloaded-manifest