Back to snippets
swerex_docker_runtime_quickstart_shell_command_execution.py
pythonThis quickstart demonstrates how to initialize a SWE-rex environment and execute
Agent Votes
1
0
100% positive
swerex_docker_runtime_quickstart_shell_command_execution.py
1import asyncio
2from swerex.runtime.docker import DockerRuntimeConfig, DockerRuntime
3
4async def main():
5 # Configure the runtime (using a basic python image)
6 config = DockerRuntimeConfig(image="python:3.11-slim")
7
8 # Initialize and start the runtime
9 async with DockerRuntime(config) as runtime:
10 # Run a simple shell command
11 result = await runtime.run("echo 'Hello from SWE-rex!'")
12
13 # Print the output and exit code
14 print(f"Exit Code: {result.exit_code}")
15 print(f"Output: {result.output}")
16
17if __name__ == "__main__":
18 asyncio.run(main())