Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions harbor_parity/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
outputs/
__pycache__/
42 changes: 42 additions & 0 deletions harbor_parity/Dockerfile.eval
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Scoring image for the original side: every HumanEvalPack toolchain in one
# image plus this repository (bigcode-evaluation-harness) installed, so that
# scoring goes through the harness' own HumanEvalFixTests.process_results and
# the Muennighoff/code_eval_octopack executor.
#
# Build from the repository root:
# docker build -f harbor_parity/Dockerfile.eval -t humanevalpack-original-eval .
FROM golang:1.22.12-bookworm AS go
FROM node:20.18.1-bookworm AS node
FROM eclipse-temurin:17-jdk-jammy AS jdk

FROM rust:1.83-bookworm
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ libboost-dev libssl-dev python3 python3-venv python3-pip git \
&& rm -rf /var/lib/apt/lists/*

COPY --from=go /usr/local/go /usr/local/go
COPY --from=node /usr/local/bin/node /usr/local/bin/node
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
COPY --from=jdk /opt/java/openjdk /opt/java/openjdk
ENV JAVA_HOME=/opt/java/openjdk \
GOPATH=/root/go \
NODE_PATH=/usr/local/lib/node_modules \
PATH=/opt/java/openjdk/bin:/usr/local/go/bin:/root/go/bin:/venv/bin:$PATH
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
&& npm i -g js-md5@0.8.3

# The executor runs `go test main_test.go` in a bare temp dir (no go.mod), i.e.
# GOPATH mode. Put testify and its dependencies on the GOPATH.
RUN mkdir /tmp/gomod && cd /tmp/gomod \
&& GO111MODULE=on go mod init gomod \
&& GO111MODULE=on go get github.com/stretchr/testify/assert@v1.9.0 \
&& GO111MODULE=on go list -m -f '{{.Path}} {{.Dir}}' all | while read p d; do \
if [ -n "$d" ] && [ "$p" != gomod ]; then mkdir -p "$GOPATH/src/$p" && cp -r "$d/." "$GOPATH/src/$p/"; fi; \
done \
&& rm -rf /tmp/gomod
ENV GO111MODULE=off

COPY . /harness
RUN python3 -m venv /venv && /venv/bin/pip install --no-cache-dir -e /harness
WORKDIR /work
32 changes: 32 additions & 0 deletions harbor_parity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# HumanEvalFix parity for the Harbor `humanevalpack` adapter

Original-side code for the parity experiment of the Harbor `humanevalpack`
adapter (https://github.com/harbor-framework/adapters/pull/142).

This harness only does single-shot generation, so parity uses Harbor's
Scenario 2: the same agent (mini-swe-agent 2.4.6) runs on both sides, and this
side is scored with this repository's own evaluator
(`HumanEvalFixTests.process_results` -> `Muennighoff/code_eval_octopack`).

- `parity_sample.json` - the 80 sampled tasks (16 per language).
- `agent_images/` - per-language images (same Dockerfiles as the adapter) plus
mini-swe-agent, installed the way Harbor installs it.
- `run_agent.py` - builds each task's runnable file and instruction with the
same rules as the adapter, runs the agent in a container, and saves
everything before the upstream test block as the generation.
- `Dockerfile.eval` - every HumanEvalPack toolchain plus this repository.
- `score.py` - grades each generation through `process_results` (one problem
at a time) and writes `scores.json`.
- `make_oracle_generations.py` - canonical-solution generations, used to check
the scorer (80/80 pass).

```bash
docker build -f harbor_parity/Dockerfile.eval -t humanevalpack-original-eval .
export OPENAI_API_KEY=... OPENAI_BASE_URL=...
uv run --python 3.11 --with datasets --with evaluate python harbor_parity/run_agent.py \
--output-dir harbor_parity/outputs/run1 --model openai/deepseek-v4.1-flash -n 2
docker run --rm -v "$PWD/harbor_parity:/hp" humanevalpack-original-eval \
python /hp/score.py --output-dir /hp/outputs/run1
```

Results (pass@1 %, 3 runs): 98.75 / 97.50 / 100.00 (mean 98.75 +/- 0.72 SEM).
9 changes: 9 additions & 0 deletions harbor_parity/agent_images/cpp.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
# boost/any.hpp is in the upstream include helper; -lcrypto/-lssl are used by CPP/162
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ libboost-dev libssl-dev python3 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
COPY workspace/ /workspace/
RUN mkdir -p /logs/verifier
15 changes: 15 additions & 0 deletions harbor_parity/agent_images/go.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.22.12-bookworm
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends python3 \
&& rm -rf /var/lib/apt/lists/*
# Pre-fetch testify (used by every upstream Go test) and warm the build cache so
# tests also run offline.
RUN mkdir -p /opt/humanevalpack/go && cd /opt/humanevalpack/go \
&& go mod init humanevalpack \
&& go get github.com/stretchr/testify/assert@v1.9.0 \
&& printf 'package main\n\nimport (\n "testing"\n "github.com/stretchr/testify/assert"\n)\n\nfunc TestWarm(t *testing.T) { assert.Equal(t, 1, 1) }\n' > warm_test.go \
&& go test warm_test.go && rm warm_test.go
WORKDIR /workspace
RUN cp /opt/humanevalpack/go/go.mod /opt/humanevalpack/go/go.sum /workspace/
COPY workspace/ /workspace/
RUN mkdir -p /logs/verifier
7 changes: 7 additions & 0 deletions harbor_parity/agent_images/java.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM eclipse-temurin:17-jdk-jammy
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends python3 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
COPY workspace/ /workspace/
RUN mkdir -p /logs/verifier
8 changes: 8 additions & 0 deletions harbor_parity/agent_images/js.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:20.18.1-bookworm
ENV DEBIAN_FRONTEND=noninteractive
# js-md5 is required by JavaScript/162; python3 (preinstalled) runs the verifier
RUN npm install -g js-md5@0.8.3
ENV NODE_PATH=/usr/local/lib/node_modules
WORKDIR /workspace
COPY workspace/ /workspace/
RUN mkdir -p /logs/verifier
19 changes: 19 additions & 0 deletions harbor_parity/agent_images/mswea.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Adds mini-swe-agent on top of a per-language agent image, installed the same
# way Harbor's built-in `mini-swe-agent` agent installs it at trial start.
ARG BASE=scratch
FROM ${BASE}
ARG MSWEA_VERSION=2.4.6
RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates bash git build-essential \
&& rm -rf /var/lib/apt/lists/*
ENV PATH=/root/.local/bin:$PATH
# Retried as a whole: downloads from astral.sh / GitHub can be flaky.
RUN for i in 1 2 3 4 5; do \
( command -v uv >/dev/null 2>&1 || curl -LsSf https://astral.sh/uv/install.sh | sh ) \
&& uv python install 3.12 \
&& uv tool install --python 3.12 "mini-swe-agent==${MSWEA_VERSION}" \
--with 'litellm[mcp]' --with orjson --with fastapi \
&& mini-swe-agent --help > /dev/null && exit 0; \
echo "attempt $i failed, retrying"; sleep 15; \
done; exit 1
RUN mkdir -p /logs/agent
14 changes: 14 additions & 0 deletions harbor_parity/agent_images/rust.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM rust:1.83-bookworm
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends python3 \
&& rm -rf /var/lib/apt/lists/*
# Same dependencies as the upstream evaluator's Cargo.toml; prebuilt so that
# agent and verifier builds are fast and work offline.
ENV CARGO_TARGET_DIR=/opt/humanevalpack/rust-target
COPY workspace/Cargo.toml /opt/humanevalpack/rust/Cargo.toml
RUN cd /opt/humanevalpack/rust && mkdir src && echo 'fn main(){}' > src/main.rs \
&& cargo generate-lockfile && cargo build && cargo test --no-run \
&& rm -rf src
WORKDIR /workspace
COPY workspace/ /workspace/
RUN cp /opt/humanevalpack/rust/Cargo.lock /workspace/Cargo.lock && mkdir -p /logs/verifier
29 changes: 29 additions & 0 deletions harbor_parity/make_oracle_generations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Write canonical solutions as generations (sanity check of the scoring setup).

Each generation has exactly the shape run_agent.py saves: the runnable file
(language prefix + declaration + body) up to the test block, with the body
replaced by `canonical_solution`.
"""
import argparse
import json
from pathlib import Path

from datasets import load_dataset

import run_agent as ra

ap = argparse.ArgumentParser()
ap.add_argument("--output-dir", type=Path, required=True)
args = ap.parse_args()
args.output_dir.mkdir(parents=True, exist_ok=True)
tasks = json.loads((ra.HERE / "parity_sample.json").read_text())["tasks"]
for lang in ["js", "java", "go", "cpp", "rust"]:
task = ra.create_task(lang, "fixtests")()
ds = load_dataset("bigcode/humanevalpack", lang, split="test", revision=ra.DATASET_REVISION)
for tid in [t for t in tasks if t.startswith(lang + "-")]:
doc = dict(ds[int(tid.split("-")[1])])
doc["buggy_solution"] = doc["canonical_solution"]
program = ra.runnable_context(lang, task, doc)
gen = program[: program.rfind(doc["test"].rstrip())]
(args.output_dir / f"{tid}.generation.txt").write_text(gen, encoding="utf-8", newline="\n")
print("done")
86 changes: 86 additions & 0 deletions harbor_parity/parity_sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"seed": 20261201,
"per_language": 16,
"tasks": [
"js-9",
"js-17",
"js-21",
"js-24",
"js-35",
"js-36",
"js-38",
"js-42",
"js-44",
"js-49",
"js-58",
"js-59",
"js-63",
"js-82",
"js-116",
"js-159",
"java-27",
"java-42",
"java-64",
"java-77",
"java-84",
"java-101",
"java-119",
"java-130",
"java-137",
"java-141",
"java-142",
"java-148",
"java-150",
"java-153",
"java-155",
"java-156",
"go-7",
"go-8",
"go-31",
"go-42",
"go-48",
"go-49",
"go-72",
"go-82",
"go-83",
"go-91",
"go-98",
"go-107",
"go-113",
"go-117",
"go-130",
"go-145",
"cpp-32",
"cpp-45",
"cpp-47",
"cpp-54",
"cpp-60",
"cpp-70",
"cpp-83",
"cpp-97",
"cpp-102",
"cpp-104",
"cpp-106",
"cpp-130",
"cpp-131",
"cpp-140",
"cpp-149",
"cpp-162",
"rust-11",
"rust-20",
"rust-26",
"rust-29",
"rust-50",
"rust-58",
"rust-73",
"rust-81",
"rust-83",
"rust-84",
"rust-86",
"rust-119",
"rust-136",
"rust-138",
"rust-145",
"rust-159"
]
}
Loading