Skip to content

Commit

Permalink
added env variable for bacalhau results directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kelindi committed Dec 11, 2024
1 parent 3c3564d commit 117adf9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions .local.dev
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ WEB3_USERS_ADDRESS=0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82
BACALHAU_API_HOST=localhost
BACALHAU_API_PORT=20000
JOB_STATUS_POLL_INTERVAL=5
BACALHAU_RESULTS_DIRECTORY=

8 changes: 2 additions & 6 deletions pkg/executor/bacalhau/bacalhau.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type BacalhauExecutorOptions struct {
ApiHost string
ApiPort string
JobStatusPollInterval uint64
ResultsDirectory string
}

type BacalhauExecutor struct {
Expand Down Expand Up @@ -160,12 +161,7 @@ func (executor *BacalhauExecutor) RunJob(

func (executor *BacalhauExecutor) prepareResults(jobId string, executionId string) (cid string, resultsDir string, err error) {

home, err := os.UserHomeDir()
if err != nil {
return "", "", fmt.Errorf("error getting home directory: %s", err.Error())
}

resultsPath := filepath.Join(home, ".bacalhau", "compute", "results", "local-publisher", fmt.Sprintf("%s.tar.gz", executionId))
resultsPath := filepath.Join(executor.Options.ResultsDirectory, fmt.Sprintf("%s.tar.gz", executionId))

gzipFile, err := os.Open(resultsPath)
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions pkg/options/bacalhau.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,30 @@ package options

import (
"fmt"
"os"
"path/filepath"

"github.com/lilypad-tech/lilypad/pkg/executor/bacalhau"
"github.com/spf13/cobra"
)

func GetDefaultBacalhauOptions() bacalhau.BacalhauExecutorOptions {
home, err := os.UserHomeDir()
if err != nil {
panic(fmt.Errorf("error getting home directory: %s", err.Error()))
}

resultsPath := filepath.Join(home, ".bacalhau", "compute", "results", "local-publisher")





return bacalhau.BacalhauExecutorOptions{
ApiHost: GetDefaultServeOptionString("BACALHAU_API_HOST", "localhost"),
ApiPort: GetDefaultServeOptionString("BACALHAU_API_PORT", "20000"),
JobStatusPollInterval: GetDefaultServeOptionUint64("JOB_STATUS_POLL_INTERVAL", 5),
ResultsDirectory: GetDefaultServeOptionString("BACALHAU_RESULTS_DIRECTORY", resultsPath),
}
}

Expand Down

0 comments on commit 117adf9

Please sign in to comment.