Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from bacalhau-project:main #10

Merged
merged 17 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cspell/custom-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ multierror
multiformats
Muxed
mypy
nats
NATS
nbconvert
nemt
NOAA
Expand Down
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: request/new, type/bug
assignees: ''

---

### Bug Description
*Briefly describe the unexpected behavior or performance regression. What happened that wasn’t supposed to?*

### Expected Behavior
*Detail what you expected to happen instead of the bug.*

### Steps to Reproduce
1. Step one to reproduce
2. Step two
3. Step three
4. (Continue as necessary)

### Bacalhau Versions
- **Agent Version**: Run `bacalhau agent version` to get this.
- **CLI Client Version**: Run `bacalhau version` for the client info.

### Host Environment
*Provide details about the environment where the bug occurred:*
- Operating System:
- CPU Architecture:
- Any other relevant environment details:

### Job Specification
*(If applicable, provide the job spec used when the issue occurred.)*

### Logs
#### Agent Logs:
*(Include here if applicable.)*

#### Client Logs:
*(Include here if applicable.)*
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Discussion
url: https://github.com/bacalhau-project/bacalhau/discussions
about: Ideal for ideas, feedback, or longer form questions.
- name: Chat
url: https://bacalhauproject.slack.com
about: Ideal for short questions, looking for advice, general conversation, and meeting other Bacalhau users!
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest a new feature or enhancement to Bacalhau
title: ''
labels: request/new, type/enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ updates:
directory: "/"
schedule:
interval: daily
labels:
- "lang/go"
- "th/dependencies"
open-pull-requests-limit: 1
- package-ecosystem: "pip"
directory: "/integration/"
schedule:
interval: daily
labels:
- "lang/python"
- "th/dependencies"
open-pull-requests-limit: 1
37 changes: 37 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Dependabot Auto Merge

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
paths-ignore:
- "**.md"

jobs:
trigger-circleci:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Trigger CircleCI Pipeline
run: .circleci/trigger_pipeline.sh
env:
BRANCH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.event.ref }}
CIRCLE_TOKEN: ${{ secrets.CIRCLE_CI_TOKEN }}

auto-merge:
runs-on: ubuntu-latest
needs: trigger-circleci
steps:
- name: Auto merge PR
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const mergePayload = {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
merge_method: 'squash'
};
github.pulls.merge(mergePayload);
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ dist/
.secret
.arg
.ruff_cache
.aider*
10 changes: 6 additions & 4 deletions cmd/cli/agent/alive.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,24 @@ func NewAliveCmd() *cobra.Command {
Use: "alive",
Short: "Get the agent's liveness and health info.",
Args: cobra.NoArgs,
Run: o.runAlive,
RunE: o.runAlive,
}
aliveCmd.Flags().AddFlagSet(cliflags.OutputNonTabularFormatFlags(&o.OutputOpts))
return aliveCmd
}

// Run executes alive command
func (o *AliveOptions) runAlive(cmd *cobra.Command, _ []string) {
func (o *AliveOptions) runAlive(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()
response, err := util.GetAPIClientV2(cmd).Agent().Alive(ctx)
if err != nil {
util.Fatal(cmd, fmt.Errorf("could not get server alive: %w", err), 1)
return fmt.Errorf("could not get server alive: %w", err)
}

writeErr := output.OutputOneNonTabular(cmd, o.OutputOpts, response)
if writeErr != nil {
util.Fatal(cmd, fmt.Errorf("failed to write alive: %w", writeErr), 1)
return fmt.Errorf("failed to write alive: %w", writeErr)
}

return nil
}
12 changes: 7 additions & 5 deletions cmd/cli/agent/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,24 @@ func NewNodeCmd() *cobra.Command {
Use: "node",
Short: "Get the agent's node info.",
Args: cobra.NoArgs,
Run: o.runNode,
RunE: o.runNode,
}
nodeCmd.Flags().AddFlagSet(cliflags.OutputNonTabularFormatFlags(&o.OutputOpts))
return nodeCmd
}

// Run executes node command
func (o *NodeOptions) runNode(cmd *cobra.Command, _ []string) {
func (o *NodeOptions) runNode(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()
response, err := util.GetAPIClientV2(cmd).Agent().Node(ctx, &apimodels.GetAgentNodeRequest{})
if err != nil {
util.Fatal(cmd, fmt.Errorf("could not get server node: %w", err), 1)
return fmt.Errorf("could not get server node: %w", err)
}

writeErr := output.OutputOneNonTabular(cmd, o.OutputOpts, response.NodeInfo)
writeErr := output.OutputOneNonTabular(cmd, o.OutputOpts, response.NodeState)
if writeErr != nil {
util.Fatal(cmd, fmt.Errorf("failed to write node: %w", writeErr), 1)
return fmt.Errorf("failed to write node: %w", writeErr)
}

return nil
}
11 changes: 6 additions & 5 deletions cmd/cli/agent/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package agent_test
import (
"testing"

"github.com/stretchr/testify/suite"

"github.com/bacalhau-project/bacalhau/pkg/lib/marshaller"
"github.com/bacalhau-project/bacalhau/pkg/models"
"github.com/stretchr/testify/suite"

cmdtesting "github.com/bacalhau-project/bacalhau/cmd/testing"
"github.com/bacalhau-project/bacalhau/cmd/util/output"
Expand All @@ -25,18 +26,18 @@ func (s *NodeSuite) TestNodeJSONOutput() {
_, out, err := s.ExecuteTestCobraCommand("agent", "node", "--output", string(output.JSONFormat))
s.Require().NoError(err, "Could not request node with json output.")

nodeInfo := &models.NodeInfo{}
nodeInfo := &models.NodeState{}
err = marshaller.JSONUnmarshalWithMax([]byte(out), &nodeInfo)
s.Require().NoError(err, "Could not unmarshall the output into json - %+v", err)
s.Require().Equal(s.Node.ID, nodeInfo.ID(), "Node ID does not match in json.")
s.Require().Equal(s.Node.ID, nodeInfo.Info.ID(), "Node ID does not match in json.")
}

func (s *NodeSuite) TestNodeYAMLOutput() {
_, out, err := s.ExecuteTestCobraCommand("agent", "node")
s.Require().NoError(err, "Could not request node with yaml output.")

nodeInfo := &models.NodeInfo{}
nodeInfo := &models.NodeState{}
err = marshaller.YAMLUnmarshalWithMax([]byte(out), &nodeInfo)
s.Require().NoError(err, "Could not unmarshall the output into yaml - %+v", err)
s.Require().Equal(s.Node.ID, nodeInfo.ID(), "Node ID does not match in yaml.")
s.Require().Equal(s.Node.ID, nodeInfo.Info.ID(), "Node ID does not match in yaml.")
}
10 changes: 6 additions & 4 deletions cmd/cli/agent/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ func NewVersionCmd() *cobra.Command {
Use: "version",
Short: "Get the agent version.",
Args: cobra.NoArgs,
Run: oV.runVersion,
RunE: oV.runVersion,
}
versionCmd.Flags().AddFlagSet(cliflags.OutputNonTabularFormatFlags(&oV.OutputOpts))
return versionCmd
}

// Run executes version command
func (oV *VersionOptions) runVersion(cmd *cobra.Command, _ []string) {
func (oV *VersionOptions) runVersion(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()
serverVersionResponse, err := util.GetAPIClientV2(cmd).Agent().Version(ctx)
if err != nil {
util.Fatal(cmd, fmt.Errorf("could not get server version: %w", err), 1)
return fmt.Errorf("could not get server version: %w", err)
}

v := serverVersionResponse.BuildVersionInfo
Expand All @@ -58,6 +58,8 @@ func (oV *VersionOptions) runVersion(cmd *cobra.Command, _ []string) {
}

if writeErr != nil {
util.Fatal(cmd, fmt.Errorf("failed to write version: %w", writeErr), 1)
return fmt.Errorf("failed to write version: %w", writeErr)
}

return nil
}
6 changes: 2 additions & 4 deletions cmd/cli/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ func NewCmd() *cobra.Command {
Args: cobra.MinimumNArgs(0),
PreRunE: hook.RemoteCmdPreRunHooks,
PostRunE: hook.RemoteCmdPostRunHooks,
Run: func(cmd *cobra.Command, cmdArgs []string) {
if err := create(cmd, cmdArgs, OC); err != nil {
util.Fatal(cmd, err, 1)
}
RunE: func(cmd *cobra.Command, cmdArgs []string) error {
return create(cmd, cmdArgs, OC)
},
}

Expand Down
13 changes: 1 addition & 12 deletions cmd/cli/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ package create_test
import (
"context"
"os"
"strings"
"sync"
"testing"

"github.com/bacalhau-project/bacalhau/pkg/lib/marshaller"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -139,14 +137,5 @@ func (s *CreateSuite) TestCreateDontPanicOnEmptyFile() {

commandReturnValue := <-commandChan

errorOutputMap := make(map[string]interface{})
for _, o := range strings.Split(commandReturnValue.out, "\n") {
err := marshaller.YAMLUnmarshalWithMax([]byte(o), &errorOutputMap)
if err != nil {
continue
}
}

require.Contains(s.T(), errorOutputMap["Message"], "the job provided is invalid", "Output message should error properly.")
require.Equal(s.T(), int(errorOutputMap["Code"].(float64)), 1, "Expected no error when no input is provided")
require.Contains(s.T(), commandReturnValue.out, "the job provided is invalid", "Output message should error properly.")
}
6 changes: 2 additions & 4 deletions cmd/cli/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ func NewCmd() *cobra.Command {
Args: cobra.ExactArgs(1),
PreRunE: hook.RemoteCmdPreRunHooks,
PostRunE: hook.RemoteCmdPostRunHooks,
Run: func(cmd *cobra.Command, cmdArgs []string) { // nolintunparam // incorrectly suggesting unused
if err := describe(cmd, cmdArgs, OD); err != nil {
util.Fatal(cmd, err, 1)
}
RunE: func(cmd *cobra.Command, cmdArgs []string) error {
return describe(cmd, cmdArgs, OD)
},
}

Expand Down
6 changes: 1 addition & 5 deletions cmd/cli/describe/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/stretchr/testify/suite"

cmdtesting "github.com/bacalhau-project/bacalhau/cmd/testing"
"github.com/bacalhau-project/bacalhau/cmd/util"
"github.com/bacalhau-project/bacalhau/pkg/bacerrors"
legacy_job "github.com/bacalhau-project/bacalhau/pkg/legacyjob"
"github.com/bacalhau-project/bacalhau/pkg/model"
Expand Down Expand Up @@ -196,7 +195,6 @@ func (s *DescribeSuite) TestDescribeJobEdgeCases() {
{numOfJobs: 1}, // just enough that describe could get screwed up
}

util.Fatal = util.FakeFatalErrorHandler
for _, tc := range tests {
for _, n := range numOfJobsTests {
func() {
Expand Down Expand Up @@ -247,10 +245,8 @@ func (s *DescribeSuite) TestDescribeJobEdgeCases() {
returnedJobEngineSpec,
fmt.Sprintf("Submitted job entrypoints not the same as the description. Edgecase: %s", tc.describeIDEdgecase))
} else {
c := &model.TestFatalErrorHandlerContents{}
s.Require().NoError(model.JSONUnmarshalWithMax([]byte(out), &c))
e := bacerrors.NewJobNotFound(tc.describeIDEdgecase)
s.Require().Contains(c.Message, e.GetMessage(), "Job not found error string not found.", err)
s.Require().Contains(string(out), e.GetMessage(), "Job not found error string not found.", err)
}

}()
Expand Down
12 changes: 4 additions & 8 deletions cmd/cli/devstack/devstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,11 @@ func NewCmd() *cobra.Command {
Short: "Start a cluster of bacalhau nodes for testing and development",
Long: devStackLong,
Example: devstackExample,
PreRun: func(cmd *cobra.Command, _ []string) {
if err := configflags.BindFlags(cmd, devstackFlags); err != nil {
util.Fatal(cmd, err, 1)
}
PreRunE: func(cmd *cobra.Command, _ []string) error {
return configflags.BindFlags(cmd, devstackFlags)
},
Run: func(cmd *cobra.Command, _ []string) {
if err := runDevstack(cmd, ODs, IsNoop); err != nil {
util.Fatal(cmd, err, 1)
}
RunE: func(cmd *cobra.Command, _ []string) error {
return runDevstack(cmd, ODs, IsNoop)
},
}

Expand Down
6 changes: 2 additions & 4 deletions cmd/cli/docker/docker_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ func newDockerRunCmd() *cobra.Command { //nolint:funlen
Args: cobra.MinimumNArgs(1),
PreRunE: hook.Chain(hook.RemoteCmdPreRunHooks, configflags.PreRun(dockerRunFlags)),
PostRunE: hook.RemoteCmdPostRunHooks,
Run: func(cmd *cobra.Command, cmdArgs []string) {
if err := dockerRun(cmd, cmdArgs, opts); err != nil {
util.Fatal(cmd, err, 1)
}
RunE: func(cmd *cobra.Command, cmdArgs []string) error {
return dockerRun(cmd, cmdArgs, opts)
},
}

Expand Down
Loading
Loading