Skip to content

Commit

Permalink
plex init now adds userId annotation upon creating io.json (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
acashmoney authored Aug 22, 2023
1 parent f37a3cf commit 5833bd4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 71 deletions.
2 changes: 0 additions & 2 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ var createCmd = &cobra.Command{

if autoRun && userID != "" {
*annotationsForAutoRun = append(*annotationsForAutoRun, fmt.Sprintf("userId=%s", userID))

fmt.Printf("Annotations for PlexRun: %v\n", *annotationsForAutoRun)
}

if autoRun {
Expand Down
12 changes: 12 additions & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"

"github.com/labdao/plex/internal/ipfs"
"github.com/labdao/plex/internal/ipwl"
"github.com/labdao/plex/internal/web3"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -143,6 +145,15 @@ func InitilizeIo(toolPath string, scatteringMethod string, inputVectors map[stri
return nil, fmt.Errorf("invalid scattering method: %s", scatteringMethod)
}

var userId string

if web3.IsValidEthereumAddress(os.Getenv("RECIPIENT_WALLET")) {
userId = os.Getenv("RECIPIENT_WALLET")
} else {
fmt.Print("Invalid wallet address detected. Using empty string for user ID.\n")
userId = ""
}

// populate ioJSONGraph based on inputsList
var ioJSONGraph []ipwl.IO
for _, inputs := range inputsList {
Expand All @@ -152,6 +163,7 @@ func InitilizeIo(toolPath string, scatteringMethod string, inputVectors map[stri
Outputs: make(map[string]ipwl.Output),
State: "created",
ErrMsg: "",
UserID: userId,
}

inputKeys := make([]string, 0, len(inputVectors))
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ require (
github.com/Masterminds/semver v1.5.0
github.com/bacalhau-project/bacalhau v0.3.28
github.com/google/uuid v1.3.0
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-ipfs-api v0.3.0
github.com/spf13/cobra v1.7.0
k8s.io/apimachinery v0.27.0
)

Expand Down Expand Up @@ -94,7 +96,6 @@ require (
github.com/ipfs/go-bitfield v1.1.0 // indirect
github.com/ipfs/go-block-format v0.1.1 // indirect
github.com/ipfs/go-blockservice v0.5.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-cidutil v0.1.0 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
github.com/ipfs/go-delegated-routing v0.7.0 // indirect
Expand Down Expand Up @@ -236,7 +237,6 @@ require (
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.9.4 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.15.0 // indirect
Expand Down
Loading

0 comments on commit 5833bd4

Please sign in to comment.