Skip to content

Commit ad573f9

Browse files
feat(wanda): add deps command
Used for parsing a Wanda file to get a visual on all dependent targets. Topic: wanda-cli-dep Relative: wanda-build-deps Labels: draft Generated with help from Claude Opus 4.5 Signed-off-by: andrew <andrew@anyscale.com>
1 parent 56e00c6 commit ad573f9

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

wanda/wanda/main.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"log"
77
"os"
8+
"strings"
89

910
"github.com/ray-project/rayci/wanda"
1011
)
@@ -13,7 +14,11 @@ const usage = `
1314
wanda - container image builder for RayCI using a container registry as a
1415
content-addressed build cache.
1516
16-
Runs in either remote mode or local mode.
17+
Usage:
18+
wanda [flags] <spec.wanda.yaml> Build an image (with dependencies)
19+
wanda deps <spec.wanda.yaml> Show dependency build order
20+
21+
Modes:
1722
- Remote:
1823
Enabled by setting -rayci flag. Takes RAYCI_ env vars for input and runs in
1924
remote mode. Builds and uploads image to the cache repository.
@@ -25,6 +30,15 @@ Flags:
2530
`
2631

2732
func main() {
33+
// Check for subcommand before flag parsing
34+
if len(os.Args) > 1 && !strings.HasPrefix(os.Args[1], "-") {
35+
switch os.Args[1] {
36+
case "deps":
37+
runDeps(os.Args[2:])
38+
return
39+
}
40+
}
41+
2842
workDir := flag.String("work_dir", ".", "root directory for the build")
2943
docker := flag.String("docker", "", "path to the docker client binary")
3044
rayCI := flag.Bool(
@@ -89,3 +103,24 @@ func main() {
89103
log.Fatal(err)
90104
}
91105
}
106+
107+
func runDeps(args []string) {
108+
if len(args) != 1 {
109+
log.Fatal("usage: wanda deps <spec.wanda.yaml>")
110+
}
111+
112+
graph, err := wanda.BuildDepGraph(args[0], os.LookupEnv)
113+
if err != nil {
114+
log.Fatal(err)
115+
}
116+
117+
if err := graph.ValidateDeps(); err != nil {
118+
log.Fatal(err)
119+
}
120+
121+
fmt.Println("Build order:")
122+
for i, name := range graph.Order() {
123+
rs := graph.Get(name)
124+
fmt.Printf(" %d. %s (%s)\n", i+1, name, rs.Path)
125+
}
126+
}

0 commit comments

Comments
 (0)