SWE-bench CLI

0.1.5 · active · verified Sat Apr 11

sb-cli is a command-line interface (CLI) tool designed to interact with the SWE-bench API. It enables users to submit predictions for SWE-bench instances, manage their runs, and track progress. The current version is 0.1.5, and it has an active development cadence driven by the SWE-bench community.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically execute the `sb submit` command using Python's `subprocess` module. Before running, ensure `sb-cli` is installed and configured with your SWE-bench API token (`sb config --api-token YOUR_TOKEN`). You also need to have started a run using `sb start` and provide valid paths to your SWE-bench instance and prediction files.

import subprocess
import os

# NOTE: This quickstart demonstrates submitting a run via the CLI.
# You must first configure your SWE-bench API token using `sb config --api-token YOUR_TOKEN`
# and start a run using `sb start` before submitting.

# Placeholder for your instance and prediction paths
instance_path = os.environ.get('SB_INSTANCE_PATH', 'path/to/your/swe_bench_instance.json')
prediction_path = os.environ.get('SB_PREDICTION_PATH', 'path/to/your/prediction.json')

if not os.path.exists(instance_path) or not os.path.exists(prediction_path):
    print(f"Warning: Placeholder paths used. Please replace '{instance_path}' and '{prediction_path}' "
          "with actual file paths for a successful submission.")
    print("You may need to run 'sb config' and 'sb start' first.")
    # Exit or mock for demonstration if files don't exist
    # For a real run, ensure these paths are valid.
    # For this example, we will just print the command without executing if paths are missing.
    command = [
        "sb",
        "submit",
        "--instance-path", instance_path,
        "--prediction-path", prediction_path,
        "--log-dir", "./sb_logs" # Optional: specify a log directory
    ]
    print(f"Mock command to execute: {' '.join(command)}")
else:
    print("Attempting to submit SWE-bench prediction...")
    command = [
        "sb",
        "submit",
        "--instance-path", instance_path,
        "--prediction-path", prediction_path,
        "--log-dir", "./sb_logs" # Optional: specify a log directory
    ]
    try:
        result = subprocess.run(command, capture_output=True, text=True, check=True)
        print("Submission successful!")
        print("STDOUT:", result.stdout)
        if result.stderr: print("STDERR:", result.stderr)
    except subprocess.CalledProcessError as e:
        print("Submission failed!")
        print("STDOUT:", e.stdout)
        print("STDERR:", e.stderr)
    except FileNotFoundError:
        print("Error: 'sb' command not found. Is sb-cli installed and in your PATH?")

view raw JSON →