From d385ed97ce39657d58fb92c82df4bc06b5856f96 Mon Sep 17 00:00:00 2001 From: Aoyang Fang Date: Thu, 25 Jun 2026 20:11:16 +0100 Subject: [PATCH 1/2] Fix uncommented English lines in run-tests.sh across all tasks Bare English sentences (e.g. "Create Test Directory", "Generate file paths...") were being executed as shell commands instead of being treated as comments. Add # prefix to all affected lines. Co-Authored-By: Claude Opus 4.6 (1M context) --- tasks_long_cli/61810_cow/run-tests.sh | 8 ++++---- tasks_long_cli/61810_fs/run-tests.sh | 8 ++++---- tasks_long_cli/61810_lock/run-tests.sh | 8 ++++---- tasks_long_cli/61810_mmap/run-tests.sh | 8 ++++---- tasks_long_cli/61810_net/run-tests.sh | 8 ++++---- tasks_long_cli/61810_pgtbl/run-tests.sh | 8 ++++---- tasks_long_cli/61810_syscall/run-tests.sh | 8 ++++---- tasks_long_cli/61810_thread/run-tests.sh | 8 ++++---- tasks_long_cli/61810_traps/run-tests.sh | 8 ++++---- tasks_long_cli/61810_util/run-tests.sh | 8 ++++---- tasks_long_cli/cs61_fa24_ants/run-tests.sh | 8 ++++---- tasks_long_cli/cs61_fa24_cats/run-tests.sh | 8 ++++---- tasks_long_cli/cs61_fa24_hog/run-tests.sh | 8 ++++---- tasks_long_cli/cs61_fa24_hw08/run-tests.sh | 8 ++++---- tasks_long_cli/cs61_fa24_scheme/run-tests.sh | 8 ++++---- 15 files changed, 60 insertions(+), 60 deletions(-) diff --git a/tasks_long_cli/61810_cow/run-tests.sh b/tasks_long_cli/61810_cow/run-tests.sh index 896db85..9502049 100644 --- a/tasks_long_cli/61810_cow/run-tests.sh +++ b/tasks_long_cli/61810_cow/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -20,10 +20,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -32,7 +32,7 @@ mkdir -p /app/test_output ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/61810_fs/run-tests.sh b/tasks_long_cli/61810_fs/run-tests.sh index 3d27c3e..fdea1c4 100644 --- a/tasks_long_cli/61810_fs/run-tests.sh +++ b/tasks_long_cli/61810_fs/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -19,10 +19,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -30,7 +30,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/61810_lock/run-tests.sh b/tasks_long_cli/61810_lock/run-tests.sh index 96b379d..a50332f 100644 --- a/tasks_long_cli/61810_lock/run-tests.sh +++ b/tasks_long_cli/61810_lock/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -20,10 +20,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -31,7 +31,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/61810_mmap/run-tests.sh b/tasks_long_cli/61810_mmap/run-tests.sh index 7ae5cb0..d374c4f 100644 --- a/tasks_long_cli/61810_mmap/run-tests.sh +++ b/tasks_long_cli/61810_mmap/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -20,10 +20,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -31,7 +31,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/61810_net/run-tests.sh b/tasks_long_cli/61810_net/run-tests.sh index 99e170b..2ebbf65 100644 --- a/tasks_long_cli/61810_net/run-tests.sh +++ b/tasks_long_cli/61810_net/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -20,10 +20,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -31,7 +31,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/61810_pgtbl/run-tests.sh b/tasks_long_cli/61810_pgtbl/run-tests.sh index aaacfd9..48efe4d 100644 --- a/tasks_long_cli/61810_pgtbl/run-tests.sh +++ b/tasks_long_cli/61810_pgtbl/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -20,10 +20,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -31,7 +31,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/61810_syscall/run-tests.sh b/tasks_long_cli/61810_syscall/run-tests.sh index 92c1413..a30c5ff 100644 --- a/tasks_long_cli/61810_syscall/run-tests.sh +++ b/tasks_long_cli/61810_syscall/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -20,10 +20,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -31,7 +31,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/61810_thread/run-tests.sh b/tasks_long_cli/61810_thread/run-tests.sh index cb76ff6..47413fe 100644 --- a/tasks_long_cli/61810_thread/run-tests.sh +++ b/tasks_long_cli/61810_thread/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -20,10 +20,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -31,7 +31,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/61810_traps/run-tests.sh b/tasks_long_cli/61810_traps/run-tests.sh index 6065812..406d7c9 100644 --- a/tasks_long_cli/61810_traps/run-tests.sh +++ b/tasks_long_cli/61810_traps/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -20,10 +20,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -31,7 +31,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/61810_util/run-tests.sh b/tasks_long_cli/61810_util/run-tests.sh index 6d7cb9f..19503a6 100644 --- a/tasks_long_cli/61810_util/run-tests.sh +++ b/tasks_long_cli/61810_util/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -20,10 +20,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -31,7 +31,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/cs61_fa24_ants/run-tests.sh b/tasks_long_cli/cs61_fa24_ants/run-tests.sh index 4be46ef..00d0dab 100644 --- a/tasks_long_cli/cs61_fa24_ants/run-tests.sh +++ b/tasks_long_cli/cs61_fa24_ants/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -19,10 +19,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -30,7 +30,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/cs61_fa24_cats/run-tests.sh b/tasks_long_cli/cs61_fa24_cats/run-tests.sh index c8b2c2a..7598244 100644 --- a/tasks_long_cli/cs61_fa24_cats/run-tests.sh +++ b/tasks_long_cli/cs61_fa24_cats/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -19,10 +19,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -30,7 +30,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/cs61_fa24_hog/run-tests.sh b/tasks_long_cli/cs61_fa24_hog/run-tests.sh index b25b941..57136c9 100644 --- a/tasks_long_cli/cs61_fa24_hog/run-tests.sh +++ b/tasks_long_cli/cs61_fa24_hog/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -19,10 +19,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -30,7 +30,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/cs61_fa24_hw08/run-tests.sh b/tasks_long_cli/cs61_fa24_hw08/run-tests.sh index 8acf6ac..7524b3c 100644 --- a/tasks_long_cli/cs61_fa24_hw08/run-tests.sh +++ b/tasks_long_cli/cs61_fa24_hw08/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -19,10 +19,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -30,7 +30,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest diff --git a/tasks_long_cli/cs61_fa24_scheme/run-tests.sh b/tasks_long_cli/cs61_fa24_scheme/run-tests.sh index 4e2c43d..9618128 100644 --- a/tasks_long_cli/cs61_fa24_scheme/run-tests.sh +++ b/tasks_long_cli/cs61_fa24_scheme/run-tests.sh @@ -4,7 +4,7 @@ source /opt/pytest-proj/.venv/bin/activate uv pip install pytest==8.4.1 -Create Test Directory +# Create Test Directory mkdir -p /app/test_output #### f2p text parsing method, here generate _output.txt, save it to the /app/test_output/ directory, so that .py can further generate _score.json file @@ -19,10 +19,10 @@ mkdir -p /app/test_output # Traverse all files in test_dir, use -print0 and read -d $'\0' to support spaces or special characters find "$test_dir" -type f -print0 | while IFS= read -r -d $'\0' file1; do - Generate file paths in proj_dir with the same structure as in test_dir. + # Generate file paths in proj_dir with the same structure as in test_dir. file2="${proj_dir}${file1#$test_dir}" - If the file exists in proj_dir, then delete it. + # If the file exists in proj_dir, then delete it. if [ -f "$file2" ]; then echo "Deleting $file2" rm "$file2" @@ -30,7 +30,7 @@ mkdir -p /app/test_output done ) -The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. +# The .py file is responsible for parsing the _output.txt generated in the previous step and converting it into a _score.json file. python3 "/tests/f2p.py" ### p2p pytest From 5390713f4ebb5bc1b6983f8faa04168f2b967bc7 Mon Sep 17 00:00:00 2001 From: lincyaw <814750204@qq.com> Date: Sun, 28 Jun 2026 09:31:17 +0100 Subject: [PATCH 2/2] upadte --- scripts_python/agentm_run.py | 103 ++++++++++++++++++ .../installed_agents/agentm/__init__.py | 0 .../agentm/agentm-setup.sh.j2 | 39 +++++++ .../installed_agents/agentm/agentm_agent.py | 72 ++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 scripts_python/agentm_run.py create mode 100644 terminal_bench/agents/installed_agents/agentm/__init__.py create mode 100644 terminal_bench/agents/installed_agents/agentm/agentm-setup.sh.j2 create mode 100644 terminal_bench/agents/installed_agents/agentm/agentm_agent.py diff --git a/scripts_python/agentm_run.py b/scripts_python/agentm_run.py new file mode 100644 index 0000000..f4ab88b --- /dev/null +++ b/scripts_python/agentm_run.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python3 +"""Run longcli-bench tasks with AgentM as the agent. + +Usage: + # Single task + LLM_BASE_URL="http://localhost:8088/v1" LLM_API_KEY="..." \ + python scripts_python/agentm_run.py \ + --model doubao-seed-2-0-pro-260215 \ + --task-id 61810_cow \ + --tasks-dir tasks_long_cli \ + --output-path runs_agentm \ + --n-attempts 1 \ + --give-test-output 3 + + # Batch (all longcli tasks) + python scripts_python/agentm_run.py \ + --model doubao-seed-2-0-pro-260215 \ + --tasks-dir tasks_long_cli \ + --output-path runs_agentm \ + --n-attempts 1 + +Aggregation: + python scripts_python/longcli_aggregate_results.py \ + --input-dirs runs_agentm \ + --tasks-dir tasks_long_cli \ + --output-json agentm_summary.json \ + --output-csv agentm_summary.csv +""" + +from __future__ import annotations + +import argparse +import subprocess +import sys + + +AGENT_IMPORT_PATH = ( + "terminal_bench.agents.installed_agents.agentm.agentm_agent:AgentMAgent" +) + +DEFAULT_TASKS = [ + "61810_cow", + "61810_fs", + "61810_lock", + "61810_mmap", + "61810_net", + "61810_pgtbl", + "61810_syscall", + "61810_thread", + "61810_traps", + "61810_util", + "ap1400_2_hw26", + "ap1400_2_hw35", + "cmu15_445_p0", + "cmu15_445_p1", + "cmu15_445_p2", + "cs61_fa24_ants", + "cs61_fa24_cats", + "cs61_fa24_hog", + "cs61_fa24_hw08", + "cs61_fa24_scheme", +] + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument("--model", required=True, help="Model name for AgentM") + parser.add_argument("--task-id", nargs="*", default=None, help="Specific task IDs (default: all 20)") + parser.add_argument("--tasks-dir", default="tasks_long_cli", help="Task directory") + parser.add_argument("--output-path", default="runs_agentm", help="Output directory") + parser.add_argument("--run-id", default=None, help="Run ID (default: agentm-)") + parser.add_argument("--n-attempts", type=int, default=1, help="Number of attempts per task") + parser.add_argument("--give-test-output", type=int, default=0, help="Self-correction turns") + parser.add_argument("--n-concurrent-trials", type=int, default=1, help="Concurrent tasks") + parser.add_argument("--on-existing", choices=["skip", "overwrite", "error"], default="skip") + args = parser.parse_args() + + task_ids = args.task_id or DEFAULT_TASKS + run_id = args.run_id or f"agentm-{args.model.split('/')[-1]}" + + for task_id in task_ids: + cmd = [ + "uv", "run", "tb", "run", + "--agent-import-path", AGENT_IMPORT_PATH, + "--model", args.model, + "--task-id", task_id, + "--dataset-path", args.tasks_dir, + "--run-id", run_id, + "--n-attempts", str(args.n_attempts), + ] + if args.give_test_output: + cmd.extend(["--give-test-output", str(args.give_test_output)]) + + print(f"\n{'='*60}") + print(f"Running: {task_id}") + print(f"{'='*60}") + result = subprocess.run(cmd) + if result.returncode != 0: + print(f"WARNING: task {task_id} exited with code {result.returncode}") + + +if __name__ == "__main__": + main() diff --git a/terminal_bench/agents/installed_agents/agentm/__init__.py b/terminal_bench/agents/installed_agents/agentm/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/terminal_bench/agents/installed_agents/agentm/agentm-setup.sh.j2 b/terminal_bench/agents/installed_agents/agentm/agentm-setup.sh.j2 new file mode 100644 index 0000000..1ab8780 --- /dev/null +++ b/terminal_bench/agents/installed_agents/agentm/agentm-setup.sh.j2 @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +# Install uv if not present +if ! command -v uv &>/dev/null; then + curl -LsSf https://astral.sh/uv/install.sh | sh + export PATH="$HOME/.local/bin:$PATH" +fi + +# Ensure ~/.local/bin is on PATH for this and future shells +export PATH="$HOME/.local/bin:$PATH" +grep -q '.local/bin' ~/.bashrc 2>/dev/null || echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc + +# Install AgentM as a uv tool (avoids externally-managed-environment errors) +uv tool install "agentm @ git+https://github.com/Lincyaw/AgentM.git" + +# Create the local scenario manifest under ~/.agentm/ so agentm can find it +mkdir -p ~/.agentm/contrib/scenarios/local +cat > ~/.agentm/contrib/scenarios/local/manifest.yaml << 'MANIFEST' +name: local +description: Minimal tool set for terminal-bench tasks. +extensions: + - module: agentm.extensions.builtin.operations + config: + backend: local + - module: agentm.extensions.builtin.tool_result_cap + - module: agentm.extensions.builtin.file_tools + - module: agentm.extensions.builtin.tool_bash + - module: agentm.extensions.builtin.observability + - module: agentm.extensions.builtin.system_prompt + config: + prompt: "" + - module: agentm.extensions.builtin.runtime_context + - module: agentm.extensions.builtin.llm_compaction + - module: agentm.extensions.builtin.read_history +MANIFEST + +# Verify installation +agentm --help >/dev/null 2>&1 || { echo "AgentM installation failed"; exit 1; } diff --git a/terminal_bench/agents/installed_agents/agentm/agentm_agent.py b/terminal_bench/agents/installed_agents/agentm/agentm_agent.py new file mode 100644 index 0000000..fd79022 --- /dev/null +++ b/terminal_bench/agents/installed_agents/agentm/agentm_agent.py @@ -0,0 +1,72 @@ +import os +import shlex +from pathlib import Path + +from terminal_bench.agents.installed_agents.abstract_installed_agent import ( + AbstractInstalledAgent, +) +from terminal_bench.terminal.models import TerminalCommand + + +class AgentMAgent(AbstractInstalledAgent): + """AgentM agent adapter for terminal-bench / longcli-bench. + + Installs AgentM into the task container via uv and runs it with the + local scenario (bash + file tools). + + Environment variables (set on the host, forwarded into the container): + LLM_BASE_URL — OpenAI-compatible endpoint (e.g. http://host:8088/v1) + LLM_API_KEY — API key for the endpoint + + Usage: + LLM_BASE_URL="http://localhost:8088/v1" LLM_API_KEY="..." \ + tb run --agent-import-path \ + terminal_bench.agents.installed_agents.agentm.agentm_agent:AgentMAgent \ + --model doubao-seed-2-0-pro-260215 \ + --task-id \ + --dataset-path tasks_long_cli + """ + + def __init__(self, model_name: str | None = None, *args, **kwargs): + super().__init__(*args, **kwargs) + self._model_name = model_name + + @staticmethod + def name() -> str: + return "agentm" + + @property + def _env(self) -> dict[str, str]: + env: dict[str, str] = { + "AGENTM_PROVIDER": "openai", + } + if self._model_name: + env["AGENTM_MODEL"] = self._model_name + + base_url = os.environ.get("LLM_BASE_URL") or os.environ.get("OPENAI_BASE_URL") + if base_url: + env["AGENTM_BASE_URL"] = base_url + env["OPENAI_BASE_URL"] = base_url + + api_key = os.environ.get("LLM_API_KEY") or os.environ.get("OPENAI_API_KEY") + if api_key: + env["AGENTM_API_KEY"] = api_key + env["OPENAI_API_KEY"] = api_key + + return env + + @property + def _install_agent_script_path(self) -> Path: + return self._get_templated_script_path("agentm-setup.sh.j2") + + def _run_agent_commands(self, instruction: str) -> list[TerminalCommand]: + escaped = shlex.quote(instruction) + return [ + TerminalCommand( + command=f"agentm --scenario local -p {escaped}", + min_timeout_sec=0.0, + max_timeout_sec=float("inf"), + block=True, + append_enter=True, + ), + ]