From f01160d58a2c567e2ee5fa2502526c67fbe80fe7 Mon Sep 17 00:00:00 2001 From: Brian Ginsburg Date: Mon, 3 Feb 2025 15:55:31 -0800 Subject: [PATCH] refactor: Move preflight config to preflight package Co-authored-by: logan --- pkg/options/resource-provider.go | 8 -------- pkg/resourceprovider/preflight/preflight.go | 13 ++++++++++--- pkg/resourceprovider/resourceprovider.go | 3 +-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/pkg/options/resource-provider.go b/pkg/options/resource-provider.go index be4a3e3e..06e7a1cc 100644 --- a/pkg/options/resource-provider.go +++ b/pkg/options/resource-provider.go @@ -6,7 +6,6 @@ import ( "github.com/lilypad-tech/lilypad/pkg/data" "github.com/lilypad-tech/lilypad/pkg/resourceprovider" - "github.com/lilypad-tech/lilypad/pkg/resourceprovider/preflight" "github.com/lilypad-tech/lilypad/pkg/system" "github.com/spf13/cobra" ) @@ -19,13 +18,6 @@ func NewResourceProviderOptions() resourceprovider.ResourceProviderOptions { Pow: GetDefaultResourceProviderPowOptions(), IPFS: GetDefaultIPFSOptions(), Telemetry: GetDefaultTelemetryOptions(), - Preflight: preflight.PreflightConfig{ - GPU: struct { - MinMemoryGB int64 - }{ - MinMemoryGB: preflight.RequiredGPUMemoryGB, - }, - }, } options.Web3.Service = system.ResourceProviderService return options diff --git a/pkg/resourceprovider/preflight/preflight.go b/pkg/resourceprovider/preflight/preflight.go index ea6565a4..7a269134 100644 --- a/pkg/resourceprovider/preflight/preflight.go +++ b/pkg/resourceprovider/preflight/preflight.go @@ -22,7 +22,7 @@ type CheckResult struct { Error error } -type PreflightConfig struct { +type preflightConfig struct { GPU struct { MinMemoryGB int64 } @@ -35,9 +35,16 @@ type preflightChecker struct { gpuInfo []GPUInfo } -func RunPreflightChecks(ctx context.Context, config PreflightConfig) error { +func RunPreflightChecks(ctx context.Context) error { log.Info().Msg("Starting preflight checks...") checker := &preflightChecker{} + config := preflightConfig{ + GPU: struct { + MinMemoryGB int64 + }{ + MinMemoryGB: RequiredGPUMemoryGB, + }, + } // Logging GPU requirements gpuInfo, err := checker.GetGPUInfo(ctx) @@ -58,7 +65,7 @@ func RunPreflightChecks(ctx context.Context, config PreflightConfig) error { return nil } -func (p *preflightChecker) RunAllChecks(ctx context.Context, config PreflightConfig) error { +func (p *preflightChecker) RunAllChecks(ctx context.Context, config preflightConfig) error { gpuResult := p.CheckGPU(ctx, &GPUCheckConfig{ MinMemory: config.GPU.MinMemoryGB * 1024 * 1024 * 1024, diff --git a/pkg/resourceprovider/resourceprovider.go b/pkg/resourceprovider/resourceprovider.go index fec7b566..b6076555 100644 --- a/pkg/resourceprovider/resourceprovider.go +++ b/pkg/resourceprovider/resourceprovider.go @@ -74,7 +74,6 @@ type ResourceProviderOptions struct { Pow ResourceProviderPowOptions IPFS ipfs.IPFSOptions Telemetry system.TelemetryOptions - Preflight preflight.PreflightConfig } type ResourceProvider struct { @@ -90,7 +89,7 @@ func NewResourceProvider( executor executor.Executor, tracer trace.Tracer, ) (*ResourceProvider, error) { - if err := preflight.RunPreflightChecks(context.Background(), options.Preflight); err != nil { + if err := preflight.RunPreflightChecks(context.Background()); err != nil { return nil, fmt.Errorf("preflight checks failed: %w", err) }