Skip to content

Commit

Permalink
refactor: Move preflight config to preflight package
Browse files Browse the repository at this point in the history
Co-authored-by: logan <[email protected]>
  • Loading branch information
bgins and noryev committed Feb 3, 2025
1 parent 4582da5 commit f01160d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 0 additions & 8 deletions pkg/options/resource-provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand Down
13 changes: 10 additions & 3 deletions pkg/resourceprovider/preflight/preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type CheckResult struct {
Error error
}

type PreflightConfig struct {
type preflightConfig struct {
GPU struct {
MinMemoryGB int64
}
Expand All @@ -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)
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions pkg/resourceprovider/resourceprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ type ResourceProviderOptions struct {
Pow ResourceProviderPowOptions
IPFS ipfs.IPFSOptions
Telemetry system.TelemetryOptions
Preflight preflight.PreflightConfig
}

type ResourceProvider struct {
Expand All @@ -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)
}

Expand Down

0 comments on commit f01160d

Please sign in to comment.