Skip to content

Instantly share code, notes, and snippets.

@lintangsutawika
Last active June 24, 2025 17:54
Show Gist options
  • Select an option

  • Save lintangsutawika/5b680caa1809d8b53907fa5c062dd601 to your computer and use it in GitHub Desktop.

Select an option

Save lintangsutawika/5b680caa1809d8b53907fa5c062dd601 to your computer and use it in GitHub Desktop.
Running SWE-Agent with Apptainer

Running SWE-Agent with Apptainer

Notes on how to use SWE-Agent with Apptainer (because for some HPC, docker is not available).

Running single task runs

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.

Inference

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

Need to Figure out

Evaluating on the Swe-Bench works by pulling individual docker instance for each problem, this will not work with the current method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment