Skip to content

Commit

Permalink
fix: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
walkah committed Jan 10, 2025
1 parent 3a2777b commit 527843e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ toolchain go1.23.2
require (
github.com/BurntSushi/toml v0.3.1
github.com/bacalhau-project/bacalhau v1.5.1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/ethereum/go-ethereum v1.13.4
github.com/fatih/color v1.16.0
github.com/go-chi/httprate v0.14.1
Expand Down Expand Up @@ -75,7 +76,6 @@ require (
github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect
github.com/cskr/pubsub v1.0.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
Expand Down
24 changes: 12 additions & 12 deletions pkg/executor/bacalhau/bacalhau.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,20 @@ func (executor *BacalhauExecutor) RunJob(
deal data.DealContainer,
module data.Module,
) (*executorlib.ExecutorResults, error) {
jobId, err := executor.getJobID(deal, module)
jobID, err := executor.getJobID(deal, module)
if err != nil {
return nil, err
}

var jobExecutions []*models.Execution
for {
jobInfo, err := executor.bacalhauClient.getJob(jobId)
jobInfo, err := executor.bacalhauClient.getJob(jobID)
if err != nil {
return nil, fmt.Errorf("error getting job %s: %s", jobId, err.Error())
return nil, fmt.Errorf("error getting job %s: %s", jobID, err.Error())
}

if jobInfo.Executions == nil {
return nil, fmt.Errorf("no executions retrieved for job %s", jobId)
return nil, fmt.Errorf("no executions retrieved for job %s", jobID)
}

jobExecutions = jobInfo.Executions.Items
Expand All @@ -137,7 +137,7 @@ func (executor *BacalhauExecutor) RunJob(
if err != nil {
return nil, fmt.Errorf("error creating results directory: %s", err.Error())
}
outputDir, err := executor.fetchResults(jobId, resultsDir)
outputDir, err := executor.fetchResults(jobID, resultsDir)
if err != nil {
return nil, fmt.Errorf("error fetching results: %s", err.Error())
}
Expand All @@ -156,30 +156,30 @@ func (executor *BacalhauExecutor) RunJob(
return results, nil
}

func (executor *BacalhauExecutor) fetchResults(jobId string, resultsDir string) (string, error) {
resultsUrl, err := executor.bacalhauClient.getJobResult(jobId)
func (executor *BacalhauExecutor) fetchResults(jobID string, resultsDir string) (string, error) {
resultsURL, err := executor.bacalhauClient.getJobResult(jobID)
if err != nil {
return "", fmt.Errorf("error fetching results: %s", err.Error())
}

// We need to make sure we use BACALHAU_HOST to get the correct URL
u, err := url.Parse(resultsUrl)
u, err := url.Parse(resultsURL)
if err != nil {
return "", fmt.Errorf("error parsing URL: %s", err.Error())
}
u.Host = fmt.Sprintf("%s:%s", executor.Options.ApiHost, u.Port())
resultsUrl = u.String()
resultsURL = u.String()

// Create the file
tarballPath := filepath.Join(resultsDir, fmt.Sprintf("%s.tar.gz", jobId))
tarballPath := filepath.Join(resultsDir, fmt.Sprintf("%s.tar.gz", jobID))
out, err := os.Create(tarballPath)
if err != nil {
return "", fmt.Errorf("error creating file: %s", err.Error())
}
defer out.Close()

// Get the data
resp, err := http.Get(resultsUrl)
resp, err := http.Get(resultsURL)
if err != nil {
return "", fmt.Errorf("error making GET request: %s", err.Error())
}
Expand All @@ -197,7 +197,7 @@ func (executor *BacalhauExecutor) fetchResults(jobId string, resultsDir string)
}

// Extract the tar.gz file
outputPath := filepath.Join(resultsDir, jobId)
outputPath := filepath.Join(resultsDir, jobID)
err = executorlib.ExtractTarGz(tarballPath, outputPath)
if err != nil {
return "", fmt.Errorf("error extracting tar.gz file: %s", err.Error())
Expand Down

0 comments on commit 527843e

Please sign in to comment.