55from debug_gym .constants import DEBUG_GYM_CACHE_DIR
66from debug_gym .gym .entities import EvalOutput
77from debug_gym .gym .envs .env import RepoEnv
8+ from debug_gym .gym .terminal import DockerTerminal , Terminal
89
910
1011class AiderBenchmarkEnv (RepoEnv ):
1112 REPO_URL = "https://github.com/exercism/python"
1213 REPO_PATH = DEBUG_GYM_CACHE_DIR / "exercism"
1314
15+ def __init__ (
16+ self ,
17+ terminal : Terminal | None = None ,
18+ ** kwargs ,
19+ ):
20+ terminal = terminal or DockerTerminal (logger = kwargs .get ("logger" ))
21+ if not isinstance (terminal , DockerTerminal ):
22+ raise ValueError ("AiderBenchmarkEnv only supports DockerTerminal." )
23+
24+ super ().__init__ (terminal = terminal , ** kwargs )
25+
1426 @property
1527 def instructions (self ) -> str :
1628 return self .current_sample ["instructions" ]
@@ -31,11 +43,26 @@ def eval(self, **kwargs) -> EvalOutput:
3143 self .last_eval = EvalOutput (success , output )
3244 return self .last_eval
3345
46+ def setup_terminal (self ):
47+ self .logger .info (f"Configuring docker container: { self .terminal .container } " )
48+
49+ self .terminal .run ("git init" )
50+ self .terminal .run ("git config user.name 'debug-gym'" )
51+ self .terminal .run ("git config user.email '<>'" )
52+
53+ self .terminal .run ("git add *.py" )
54+ self .terminal .run ("git commit -am 'Init'" )
55+
56+ self .terminal .run ("git add .debugignore" )
57+ self .terminal .run ("git add .debugreadonly" )
58+ self .terminal .run ("git commit -am 'Add debug-gym ignore and read-only files'" )
59+
3460 def reset (self , * , options : dict = None ):
3561 options = options or {}
3662 self .current_sample = self .dataset [options ["task_name" ]]
3763 directory = self .current_sample ["base_directory" ]
3864 self .setup_workspace (directory , entrypoint = self .entrypoint )
65+ self .setup_terminal ()
3966 infos = super ().reset (options = options )
4067 return infos
4168
0 commit comments