Skip to content

Commit e3faea2

Browse files
authored
plex create deprecated (#622)
1 parent 397beb5 commit e3faea2

42 files changed

Lines changed: 4008 additions & 713 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
- name: Run Equibind
4141
run: |
42-
result_dir=$(./plex create -t tools/equibind.json -i testdata/binding/pdbbind_processed_size1 --autoRun=true -a test -a ci | grep 'Finished processing, results written to' | sed -n 's/^.*Finished processing, results written to //p' | sed 's/\/io.json//')
42+
result_dir=$(./plex init -t tools/equibind.json -i '{"protein": ["testdata/binding/abl/7n9g.pdb"], "small_molecule": ["testdata/binding/abl/ZINC000003986735.sdf"]}' --scatteringMethod=dotProduct --autoRun=true -a test -a ci | grep 'Finished processing, results written to' | sed -n 's/^.*Finished processing, results written to //p' | sed 's/\/io.json//')
4343
cd "$result_dir/entry-0/outputs"
4444
if [ "$(find . -name '*docked.sdf' | grep 'docked.sdf')" == "" ]; then
4545
echo "No docked files found"

.github/workflows/releaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959

6060
- name: Run Equibind
6161
run: |
62-
result_dir=$(./plex create -t tools/equibind.json -i testdata/binding/pdbbind_processed_size1 -a test -a ci --autoRun=true | grep 'Finished processing, results written to' | sed -n 's/^.*Finished processing, results written to //p' | sed 's/\/io.json//')
62+
result_dir=$(./plex init -t tools/equibind.json -i '{"protein": ["testdata/binding/abl/7n9g.pdb"], "small_molecule": ["testdata/binding/abl/ZINC000003986735.sdf"]}' --scatteringMethod=dotProduct --autoRun=true -a test -a ci | grep 'Finished processing, results written to' | sed -n 's/^.*Finished processing, results written to //p' | sed 's/\/io.json//')
6363
cd "$result_dir/entry-0/outputs"
6464
if [ "$(find . -name '*docked.sdf' | grep 'docked.sdf')" == "" ]; then
6565
echo "No docked files found"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,6 @@ yarn-error.log
311311
yarn-debug.log*
312312
.pnpm-debug.log*
313313
!./gateway/frontend/lib/
314+
315+
# gorm
316+
gateway/gorm.db

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Invoke-Expression (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/lab
6767

6868
2. Submit an example plex job
6969
```
70-
./plex create -t tools/equibind.json -i testdata/binding/abl --autoRun=True
70+
./plex init -t tools/equibind.json -i '{"protein": ["testdata/binding/abl/7n9g.pdb"], "small_molecule": ["testdata/binding/abl/ZINC000003986735.sdf"]}' --scatteringMethod=dotProduct --autoRun=true
7171
```
7272

7373
![Getting Started](./readme-getting-started-2x.gif)

cmd/create.go

Lines changed: 0 additions & 103 deletions
This file was deleted.

cmd/init.go

Lines changed: 14 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import (
66
"io/ioutil"
77
"log"
88
"os"
9-
"path/filepath"
10-
"strings"
119

1210
"github.com/labdao/plex/internal/ipfs"
1311
"github.com/labdao/plex/internal/ipwl"
14-
"github.com/labdao/plex/internal/web3"
1512
"github.com/spf13/cobra"
1613
)
1714

1815
var (
19-
inputs string
20-
scatteringMethod string
16+
toolPath string
17+
inputs string
18+
scatteringMethod string
19+
autoRun bool
20+
annotationsForAutoRun *[]string
2121
)
2222

2323
var initCmd = &cobra.Command{
@@ -34,7 +34,7 @@ var initCmd = &cobra.Command{
3434
log.Fatal("Invalid inputs JSON:", err)
3535
}
3636

37-
ioJson, err := InitilizeIo(toolPath, scatteringMethod, kwargs)
37+
ioJson, err := ipwl.InitializeIo(toolPath, scatteringMethod, kwargs)
3838
if err != nil {
3939
log.Fatal(err)
4040
}
@@ -69,153 +69,23 @@ var initCmd = &cobra.Command{
6969
if err := tempFile.Close(); err != nil {
7070
log.Fatalf("Failed to close the temporary file: %v", err)
7171
}
72-
},
73-
}
74-
75-
func InitilizeIo(toolPath string, scatteringMethod string, inputVectors map[string][]string) ([]ipwl.IO, error) {
76-
// Open the file and load its content
77-
tool, toolInfo, err := ipwl.ReadToolConfig(toolPath)
78-
if err != nil {
79-
return nil, err
80-
}
81-
82-
// Check if all kwargs are in the tool's inputs
83-
for inputKey := range inputVectors {
84-
if _, exists := tool.Inputs[inputKey]; !exists {
85-
log.Printf("The argument %s is not in the tool inputs.\n", inputKey)
86-
log.Printf("Available keys: %v\n", tool.Inputs)
87-
return nil, fmt.Errorf("the argument %s is not in the tool inputs", inputKey)
88-
}
89-
}
90-
91-
// Handle scattering methods and create the inputsList
92-
var inputsList [][]string
93-
switch scatteringMethod {
94-
case "dotProduct":
95-
// check if all lists have the same length
96-
var vectorLength int
97-
for _, v := range inputVectors {
98-
if vectorLength == 0 {
99-
vectorLength = len(v)
100-
continue
101-
}
102-
if len(v) != vectorLength {
103-
return nil, fmt.Errorf("all input arguments must have the same length for dot_product scattering method")
104-
}
105-
vectorLength = len(v)
106-
}
107-
for i := 0; i < vectorLength; i++ {
108-
tmp := []string{}
109-
for _, v := range inputVectors {
110-
tmp = append(tmp, v[i])
111-
}
112-
inputsList = append(inputsList, tmp)
113-
}
114-
case "crossProduct":
115-
cartesian := func(arrs ...[]string) [][]string {
116-
result := [][]string{{}}
117-
118-
for _, arr := range arrs {
119-
var temp [][]string
120-
121-
for _, res := range result {
122-
for _, str := range arr {
123-
product := append([]string{}, res...)
124-
product = append(product, str)
125-
temp = append(temp, product)
126-
}
127-
}
128-
129-
result = temp
130-
}
131-
132-
return result
133-
}
134-
135-
keys := make([]string, 0, len(inputVectors))
136-
for k := range inputVectors {
137-
keys = append(keys, k)
138-
}
139-
arrays := make([][]string, len(inputVectors))
140-
for i, k := range keys {
141-
arrays[i] = inputVectors[k]
142-
}
143-
inputsList = cartesian(arrays...)
144-
default:
145-
return nil, fmt.Errorf("invalid scattering method: %s", scatteringMethod)
146-
}
147-
148-
var userId string
149-
150-
if web3.IsValidEthereumAddress(os.Getenv("RECIPIENT_WALLET")) {
151-
userId = os.Getenv("RECIPIENT_WALLET")
152-
} else {
153-
fmt.Print("Invalid wallet address detected. Using empty string for user ID.\n")
154-
userId = ""
155-
}
156-
157-
// populate ioJSONGraph based on inputsList
158-
var ioJSONGraph []ipwl.IO
159-
for _, inputs := range inputsList {
160-
io := ipwl.IO{
161-
Tool: toolInfo,
162-
Inputs: make(map[string]ipwl.FileInput),
163-
Outputs: make(map[string]ipwl.Output),
164-
State: "created",
165-
ErrMsg: "",
166-
UserID: userId,
167-
}
16872

169-
inputKeys := make([]string, 0, len(inputVectors))
170-
for k := range inputVectors {
171-
inputKeys = append(inputKeys, k)
172-
}
173-
174-
for i, inputValue := range inputs {
175-
inputKey := inputKeys[i]
176-
177-
if strings.Count(inputValue, "/") == 1 {
178-
parts := strings.Split(inputValue, "/")
179-
cid := parts[0]
180-
fileName := parts[1]
181-
if !ipfs.IsValidCID(cid) {
182-
return nil, fmt.Errorf("invalid CID: %s", cid)
183-
}
184-
io.Inputs[inputKey] = ipwl.FileInput{
185-
Class: tool.Inputs[inputKey].Type,
186-
FilePath: fileName,
187-
IPFS: cid,
188-
}
189-
} else {
190-
cid, err := ipfs.WrapAndPinFile(inputValue) // Pin the file and get the CID
191-
if err != nil {
192-
return nil, err
193-
}
194-
io.Inputs[inputKey] = ipwl.FileInput{
195-
Class: tool.Inputs[inputKey].Type,
196-
FilePath: filepath.Base(inputValue), // Use the respective input value from inputsList
197-
IPFS: cid, // Use the CID returned by WrapAndPinFile
198-
}
199-
}
200-
}
201-
202-
for outputKey := range tool.Outputs {
203-
io.Outputs[outputKey] = ipwl.FileOutput{
204-
Class: tool.Outputs[outputKey].Type,
205-
FilePath: "", // Assuming filepath is empty, adapt as needed
206-
IPFS: "", // Assuming IPFS is not provided, adapt as needed
73+
if autoRun {
74+
_, _, err := PlexRun(cid, outputDir, verbose, showAnimation, concurrency, *annotationsForAutoRun)
75+
if err != nil {
76+
fmt.Println("Error:", err)
77+
os.Exit(1)
20778
}
20879
}
209-
ioJSONGraph = append(ioJSONGraph, io)
210-
}
211-
212-
return ioJSONGraph, nil
80+
},
21381
}
21482

21583
func init() {
21684
initCmd.Flags().StringVarP(&toolPath, "toolPath", "t", "", "Path of the Tool config (can be a local path or an IPFS CID)")
21785
initCmd.Flags().StringVarP(&inputs, "inputs", "i", "{}", "Inputs in JSON format")
21886
initCmd.Flags().StringVarP(&scatteringMethod, "scatteringMethod", "", "{}", "Inputs in JSON format")
87+
initCmd.Flags().BoolVarP(&autoRun, "autoRun", "", false, "Auto submit the IO to plex run")
88+
annotationsForAutoRun = initCmd.Flags().StringArrayP("annotations", "a", []string{}, "Annotations to add to Bacalhau job")
21989

22090
rootCmd.AddCommand(initCmd)
22191
}

cmd/upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var upgradeCmd = &cobra.Command{
3131
}
3232

3333
const (
34-
CurrentPlexVersion = "v0.9.1"
34+
CurrentPlexVersion = "v0.10.0"
3535
ReleaseURL = "https://api.github.com/repos/labdao/plex/releases/latest"
3636
ToolsURL = "https://api.github.com/repos/labdao/plex/contents/tools?ref=main"
3737
)

0 commit comments

Comments
 (0)