Files
wehub-resource-sync a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

68 lines
1.7 KiB
Go

package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"github.com/spf13/cobra"
)
var (
evalSwebenchScript string
evalSwebenchPython string
)
var evalSwebenchCmd = &cobra.Command{
Use: "swebench [args...]",
Short: "Run the SWE-bench harness (eval/run_eval.py)",
Long: `Thin passthrough to the Python SWE-bench harness in eval/. All positional arguments and flags after -- are forwarded to run_eval.py unchanged.`,
DisableFlagParsing: true,
RunE: runEvalSwebench,
}
func init() {
evalSwebenchCmd.Flags().StringVar(&evalSwebenchScript, "script", "eval/run_eval.py", "path to the Python harness (repo-relative or absolute)")
evalSwebenchCmd.Flags().StringVar(&evalSwebenchPython, "python", "", "python interpreter (default: $PYTHON or python3)")
evalCmd.AddCommand(evalSwebenchCmd)
}
func runEvalSwebench(_ *cobra.Command, args []string) error {
script := evalSwebenchScript
passthrough := args
for i, a := range args {
switch a {
case "--script":
if i+1 < len(args) {
script = args[i+1]
passthrough = append(append([]string{}, args[:i]...), args[i+2:]...)
}
case "--python":
if i+1 < len(args) {
evalSwebenchPython = args[i+1]
passthrough = append(append([]string{}, args[:i]...), args[i+2:]...)
}
}
}
if _, err := os.Stat(script); err != nil {
abs, _ := filepath.Abs(script)
return fmt.Errorf("SWE-bench harness not found at %s: %w", abs, err)
}
py := evalSwebenchPython
if py == "" {
py = os.Getenv("PYTHON")
}
if py == "" {
py = "python3"
}
cmd := exec.Command(py, append([]string{script}, passthrough...)...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}