MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / FetchSpecStore

Function FetchSpecStore

utils/spec_store.go:31–55  ·  view source on GitHub ↗

FetchSpecStore loads GPU specs and availability from the API concurrently and merges them into a SpecStore. Specs are required; availability is best-effort — a failure leaves configurations unmarked rather than aborting.

(client *api.Client)

Source from the content-addressed store, hash-verified

29// merges them into a SpecStore. Specs are required; availability is best-effort
30// — a failure leaves configurations unmarked rather than aborting.
31func FetchSpecStore(client *api.Client) (*SpecStore, error) {
32 var (
33 specsMap map[string]api.GpuSpecConfig
34 specsErr error
35 availability map[string]string
36 wg sync.WaitGroup
37 )
38 wg.Add(2)
39 go func() {
40 defer wg.Done()
41 specsMap, specsErr = client.GetSpecs()
42 }()
43 go func() {
44 defer wg.Done()
45 if avail, err := client.GetAvailability(); err == nil && avail != nil {
46 availability = avail.Specs
47 }
48 }()
49 wg.Wait()
50
51 if specsErr != nil {
52 return nil, fmt.Errorf("failed to fetch GPU specs: %w", specsErr)
53 }
54 return NewSpecStoreWithAvailability(specsMap, availability), nil
55}
56
57func publicConfigKey(gpuType string, gpuCount int) string {
58 return fmt.Sprintf("%s_x%d", gpuType, gpuCount)

Callers 3

fetchCreateSpecsCmdFunction · 0.92
runModifyFunction · 0.92
runCreateFunction · 0.92

Calls 3

GetSpecsMethod · 0.80
GetAvailabilityMethod · 0.80

Tested by

no test coverage detected