Datasets:
Download scripts/build_environment.py from CrossSWE/CrossSWE-Bench: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/datasets/CrossSWE/CrossSWE-Bench/resolve/main/scripts/build_environment.py
- Command line
-
hf download hf://datasets/CrossSWE/CrossSWE-Bench/scripts/build_environment.py
-
curl -L -o build_environment.py https://huggingface.co/datasets/CrossSWE/CrossSWE-Bench/resolve/main/scripts/build_environment.py
1.27 kB
| """Build a task's environment-only Docker image from its release recipe.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import subprocess | |
| from common import ROOT, contained, load_task, sha256 | |
| def build(instance_id, tag): | |
| task = load_task(instance_id) | |
| directory = contained(ROOT / "instances", task["instance_id"]) | |
| recipe = contained(directory, "environment/Dockerfile") | |
| if not recipe.is_file(): | |
| raise ValueError("This task does not yet have a portable environment recipe") | |
| refs = {ref["path"]: ref for ref in task["artifacts"]} | |
| for path in recipe.parent.rglob("*"): | |
| if path.is_file(): | |
| relative = str(path.relative_to(directory)) | |
| if relative not in refs or sha256(path) != refs[relative]["sha256"]: | |
| raise ValueError(f"Environment recipe artifact changed: {relative}") | |
| subprocess.run(["docker", "build", "--pull", "--platform", "linux/amd64", "--tag", tag, "--file", str(recipe), str(recipe.parent)], check=True) | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--instance-id", required=True) | |
| parser.add_argument("--tag", required=True) | |
| args = parser.parse_args() | |
| build(args.instance_id, args.tag) | |