Skip to content

Commit 35f03f2

Browse files
MarcCotematheperxingdi-eric-yuan
authored
Rename output logs file and agent's output trajectory file (#230)
* Pull changes from #107 and #212 * Add a workspace class. Refactoring + tests * Refactor SWE-Bench and make sure all 500 tasks can be solved. * Rename output logs file and agent's output trajectory file * Pass revision id to parent class * Tests should check for default SWE-bench/SWE-bench_Verified * Make sure we apply any changes needed for setting up the environment. * Rename RemoteWorkspace -> Workspace * Fix typos. * Use better delimiter for here-document + add explantion to workspace.write_file * Show with hidden files when listing file with workspace * Fix interact_with_pdb test * Raises if git diff fails * Rename log to trajectory * fix test, now log file is named debug_gym.log --------- Co-authored-by: Matheus Pereira <matpereira@microsoft.com> Co-authored-by: Xingdi (Eric) Yuan <xingdi-eric-yuan@users.noreply.github.com>
1 parent 0adba71 commit 35f03f2

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

debug_gym/agents/base_agent.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,10 @@ def save_patch(self, task_name="custom"):
347347
f"Patch saved in {pjoin(self._output_path, task_name, 'debug_gym.patch')}"
348348
)
349349

350-
def log(self, task_name="custom"):
350+
def save_trajectory(self, task_name="custom"):
351351
# Simple tools list.
352352
tools = [f"{tool.name}({tool.arguments})" for tool in self.env.tools]
353-
jsonl_output = {
353+
json_output = {
354354
"problem": task_name,
355355
"config": self.config,
356356
"tools": self.llm.define_tools(self.env.tools) if self.llm else tools,
@@ -362,14 +362,13 @@ def log(self, task_name="custom"):
362362
}
363363
for step_id in range(len(self.history)):
364364
step_json = self.history.json(step_id)
365-
jsonl_output["log"].append(step_json)
365+
json_output["log"].append(step_json)
366366
os.makedirs(pjoin(self._output_path, task_name), exist_ok=True)
367-
with open(pjoin(self._output_path, task_name, "debug_gym.jsonl"), "w") as f:
368-
json.dump(jsonl_output, f, indent=4)
367+
json_file = pjoin(self._output_path, task_name, "trajectory.json")
368+
with open(json_file, "w") as f:
369+
json.dump(json_output, f, indent=4)
369370

370-
self.logger.debug(
371-
f"Log saved in {pjoin(self._output_path, task_name, 'debug_gym.jsonl')}"
372-
)
371+
self.logger.debug(f"Trajectory saved in {json_file}")
373372

374373

375374
def create_agent(agent_type: str, **agent_kwargs):

debug_gym/logger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def log_file_path(self) -> str:
109109
str(
110110
log_file_path(
111111
self.logdir,
112-
self.problem_id,
112+
"debug_gym",
113113
relative=True,
114114
)
115115
)
@@ -551,7 +551,7 @@ def _initialize_main_logger(self, level):
551551

552552
def _initialize_file_handler(self, name: str, mode: str):
553553
self.setLevel(logging.DEBUG) # Ensure logger operates at DEBUG level
554-
self.log_file = log_file_path(self.log_dir, name)
554+
self.log_file = log_file_path(self.log_dir, "debug_gym")
555555
fh = logging.FileHandler(self.log_file, mode=mode)
556556
formatter = StripAnsiFormatter("%(asctime)s %(levelname)-8s %(message)s")
557557
fh.setFormatter(formatter)

scripts/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def run_agent(args, problem, config):
139139
report_progress_error = False
140140
raise
141141

142-
# save log
143-
agent.log(task_name=problem)
142+
# save trajectory
143+
agent.save_trajectory(task_name=problem)
144144

145145
# optionally apply patch
146146
if config["save_patch"]:

tests/test_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_task_log_file_path(tmp_path):
157157
status="pending",
158158
logdir=str(log_dir),
159159
)
160-
expected_path = str(log_dir / "test_task.log")
160+
expected_path = str(log_dir / "debug_gym.log")
161161
assert task.log_file_path == expected_path
162162

163163

0 commit comments

Comments
 (0)