Notes on how to use SWE-Agent with Apptainer (because for some HPC, docker is not available).
Like a DockerFile, we can configure a container using a definition file. Save the snippet below as sweagent.def.
Bootstrap: docker
From: python:3.12
%post
git clone https://github.com/SWE-agent/SWE-agent.git
cd SWE-agent/
python -m pip install --upgrade pip && pip install --editable .
cd ../
%environment
alias ll="ls -l"
Build the apptainer image.
apptainer build sweagent.sif sweagent.def
Then we can run sweagent using the container.
apptainer exec --fakeroot --writable-tmpfs sweagent.sif \
python -m sweagent run \
--env.deployment.type=local \
--config /path/to/agent/config \
--config config/coding_challenge.yaml \
... \
--actions.apply_patch_locally=True
--fakeroot allows to use sudo level access and --writable-tmpfs enables temporary writing that won't change the apptainer image permanently.
--env.deployment.type=local is what allows to forgo using docker, but running it in apptainer should still afford the expected safety measures.
With example from SWE-Gym sample idx 1
apptainer exec --fakeroot --writable-tmpfs sweagent.sif
python -m sweagent run
--env.deployment.type=local
--env.repo.github_url=https://github.com/getmoto/moto/
--env.repo.base_commit=7f6c9cb1deafb280fe7fcc7551c38e397f11a706
--problem_statement.path=problem_statement.md
--config config/claude.yaml
--config config/coding_challenge.yaml
--actions.apply_patch_locally=True
Evaluating on the Swe-Bench works by pulling individual docker instance for each problem, this will not work with the current method.