@elizaos/sweagent-root 2.0.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +270 -0
- package/package.json +71 -0
- package/python/LICENSE +21 -0
- package/python/config/README.md +15 -0
- package/python/config/bash_only.yaml +222 -0
- package/python/config/benchmarks/250212_sweagent_heavy_sbl.yaml +188 -0
- package/python/config/benchmarks/250225_anthropic_filemap_simple_review.yaml +75 -0
- package/python/config/benchmarks/250522_anthropic_filemap_simple_review.yaml +92 -0
- package/python/config/benchmarks/250526_anthropic_filemap_simple_review_sbl.yaml +93 -0
- package/python/config/benchmarks/anthropic_filemap_multilingual.yaml +66 -0
- package/python/config/coding_challenge.yaml +104 -0
- package/python/config/default.yaml +69 -0
- package/python/config/default_backticks.yaml +69 -0
- package/python/config/default_mm_no_images.yaml +82 -0
- package/python/config/default_mm_with_images.yaml +83 -0
- package/python/config/demo/default.yaml +80 -0
- package/python/config/demo/no_instructions.yaml +69 -0
- package/python/config/demo/only_bash.yaml +60 -0
- package/python/config/exotic/default_shell.yaml +52 -0
- package/python/config/exotic/windowed_replace.yaml +125 -0
- package/python/config/exotic/windowed_replace_late_repro.yaml +127 -0
- package/python/config/human/human.yaml +24 -0
- package/python/config/human/human_demo.yaml +52 -0
- package/python/config/sweagent_0_7/07.yaml +101 -0
- package/python/config/sweagent_0_7/07_fcalling.yaml +100 -0
- package/python/config/sweagent_0_7/07_from_url.yaml +114 -0
- package/python/config/sweagent_0_7/07_thought_action.yaml +102 -0
- package/python/config/sweagent_0_7/07_thought_action_xml.yaml +96 -0
- package/python/mlc_config.json +44 -0
- package/python/pyproject.toml +262 -0
- package/python/sweagent/__init__.py +114 -0
- package/python/sweagent/__main__.py +4 -0
- package/python/sweagent/agent/__init__.py +0 -0
- package/python/sweagent/agent/action_sampler.py +317 -0
- package/python/sweagent/agent/agents.py +1294 -0
- package/python/sweagent/agent/extra/shell_agent.py +106 -0
- package/python/sweagent/agent/history_processors.py +399 -0
- package/python/sweagent/agent/hooks/__init__.py +0 -0
- package/python/sweagent/agent/hooks/abstract.py +139 -0
- package/python/sweagent/agent/hooks/status.py +34 -0
- package/python/sweagent/agent/models.py +896 -0
- package/python/sweagent/agent/problem_statement.py +312 -0
- package/python/sweagent/agent/reviewer.py +664 -0
- package/python/sweagent/environment/__init__.py +0 -0
- package/python/sweagent/environment/hooks/__init__.py +0 -0
- package/python/sweagent/environment/hooks/abstract.py +60 -0
- package/python/sweagent/environment/hooks/status.py +28 -0
- package/python/sweagent/environment/repo.py +219 -0
- package/python/sweagent/environment/swe_env.py +276 -0
- package/python/sweagent/exceptions.py +54 -0
- package/python/sweagent/inspector/README.md +6 -0
- package/python/sweagent/inspector/__init__.py +0 -0
- package/python/sweagent/inspector/favicon.ico +0 -0
- package/python/sweagent/inspector/fileViewer.js +354 -0
- package/python/sweagent/inspector/icons/computer.png +0 -0
- package/python/sweagent/inspector/icons/edit_icon.svg +11 -0
- package/python/sweagent/inspector/icons/swe-agent-logo-50.png +0 -0
- package/python/sweagent/inspector/icons/swellama_blue.png +0 -0
- package/python/sweagent/inspector/icons/swellama_brown.png +0 -0
- package/python/sweagent/inspector/icons/swellama_grey.png +0 -0
- package/python/sweagent/inspector/icons/swellama_tan.png +0 -0
- package/python/sweagent/inspector/index.html +25 -0
- package/python/sweagent/inspector/server.py +354 -0
- package/python/sweagent/inspector/static.py +169 -0
- package/python/sweagent/inspector/style.css +454 -0
- package/python/sweagent/run/__init__.py +0 -0
- package/python/sweagent/run/_progress.py +158 -0
- package/python/sweagent/run/batch_instances.py +419 -0
- package/python/sweagent/run/common.py +387 -0
- package/python/sweagent/run/compare_runs.py +123 -0
- package/python/sweagent/run/extract_pred.py +19 -0
- package/python/sweagent/run/hooks/__init__.py +0 -0
- package/python/sweagent/run/hooks/abstract.py +67 -0
- package/python/sweagent/run/hooks/apply_patch.py +106 -0
- package/python/sweagent/run/hooks/open_pr.py +244 -0
- package/python/sweagent/run/hooks/swe_bench_evaluate.py +113 -0
- package/python/sweagent/run/inspector_cli.py +493 -0
- package/python/sweagent/run/merge_predictions.py +64 -0
- package/python/sweagent/run/quick_stats.py +96 -0
- package/python/sweagent/run/remove_unfinished.py +63 -0
- package/python/sweagent/run/rich_test.py +91 -0
- package/python/sweagent/run/run.py +147 -0
- package/python/sweagent/run/run_batch.py +442 -0
- package/python/sweagent/run/run_replay.py +219 -0
- package/python/sweagent/run/run_shell.py +155 -0
- package/python/sweagent/run/run_single.py +225 -0
- package/python/sweagent/run/run_traj_to_demo.py +85 -0
- package/python/sweagent/tools/__init__.py +0 -0
- package/python/sweagent/tools/bundle.py +57 -0
- package/python/sweagent/tools/commands.py +220 -0
- package/python/sweagent/tools/parsing.py +619 -0
- package/python/sweagent/tools/tools.py +430 -0
- package/python/sweagent/tools/utils.py +108 -0
- package/python/sweagent/types.py +102 -0
- package/python/sweagent/utils/__init__.py +0 -0
- package/python/sweagent/utils/config.py +80 -0
- package/python/sweagent/utils/files.py +27 -0
- package/python/sweagent/utils/github.py +118 -0
- package/python/sweagent/utils/jinja_warnings.py +14 -0
- package/python/sweagent/utils/log.py +175 -0
- package/python/sweagent/utils/patch_formatter.py +152 -0
- package/python/sweagent/utils/serialization.py +45 -0
- package/python/tests/__init__.py +0 -0
- package/python/tests/conftest.py +191 -0
- package/python/tests/test_agent.py +258 -0
- package/python/tests/test_batch_instance.py +43 -0
- package/python/tests/test_commands/_interactive_dummy.py +35 -0
- package/python/tests/test_commands/interactive_dummy_wrapper.sh +29 -0
- package/python/tests/test_data/config_files/dummy_interactive.yaml +62 -0
- package/python/tests/test_data/data_sources/ctf/crypto/Katy/Dockerfile +20 -0
- package/python/tests/test_data/data_sources/ctf/crypto/Katy/README.md +13 -0
- package/python/tests/test_data/data_sources/ctf/crypto/Katy/challenge.json +12 -0
- package/python/tests/test_data/data_sources/ctf/crypto/Katy/customrandom.c +50 -0
- package/python/tests/test_data/data_sources/ctf/crypto/Katy/docker-compose.yml +14 -0
- package/python/tests/test_data/data_sources/ctf/crypto/Katy/release +0 -0
- package/python/tests/test_data/data_sources/ctf/crypto/Katy/server +0 -0
- package/python/tests/test_data/data_sources/ctf/crypto/Katy/solver.py +12 -0
- package/python/tests/test_data/data_sources/ctf/forensics/flash/README.md +16 -0
- package/python/tests/test_data/data_sources/ctf/forensics/flash/challenge.json +9 -0
- package/python/tests/test_data/data_sources/ctf/forensics/flash/flash_c8429a430278283c0e571baebca3d139.zip +0 -0
- package/python/tests/test_data/data_sources/ctf/misc/networking_1/README.md +15 -0
- package/python/tests/test_data/data_sources/ctf/misc/networking_1/challenge.json +10 -0
- package/python/tests/test_data/data_sources/ctf/misc/networking_1/networking.pcap +0 -0
- package/python/tests/test_data/data_sources/ctf/pwn/warmup/Dockerfile +28 -0
- package/python/tests/test_data/data_sources/ctf/pwn/warmup/README.md +14 -0
- package/python/tests/test_data/data_sources/ctf/pwn/warmup/challenge.json +14 -0
- package/python/tests/test_data/data_sources/ctf/pwn/warmup/docker-compose.yml +14 -0
- package/python/tests/test_data/data_sources/ctf/pwn/warmup/flag.txt +1 -0
- package/python/tests/test_data/data_sources/ctf/pwn/warmup/warmup +0 -0
- package/python/tests/test_data/data_sources/ctf/pwn/warmup/warmup.c +26 -0
- package/python/tests/test_data/data_sources/ctf/pwn/warmup/warmup.py +9 -0
- package/python/tests/test_data/data_sources/ctf/rev/rock/README.md +14 -0
- package/python/tests/test_data/data_sources/ctf/rev/rock/challenge.json +8 -0
- package/python/tests/test_data/data_sources/ctf/rev/rock/rock +0 -0
- package/python/tests/test_data/data_sources/ctf/rev/rock/rock.cpp +167 -0
- package/python/tests/test_data/data_sources/ctf/rev/rock/solution.cpp +24 -0
- package/python/tests/test_data/data_sources/ctf/rev/rock/test_solver/solution.py +6 -0
- package/python/tests/test_data/data_sources/ctf/rev/rock/test_solver/test.sh +10 -0
- package/python/tests/test_data/data_sources/ctf/web/i_got_id_demo/000-default.conf +18 -0
- package/python/tests/test_data/data_sources/ctf/web/i_got_id_demo/Dockerfile +20 -0
- package/python/tests/test_data/data_sources/ctf/web/i_got_id_demo/cgi/file.pl +38 -0
- package/python/tests/test_data/data_sources/ctf/web/i_got_id_demo/cgi/forms.pl +40 -0
- package/python/tests/test_data/data_sources/ctf/web/i_got_id_demo/cgi/hello.pl +11 -0
- package/python/tests/test_data/data_sources/ctf/web/i_got_id_demo/challenge.json +12 -0
- package/python/tests/test_data/data_sources/ctf/web/i_got_id_demo/docker-compose.yml +14 -0
- package/python/tests/test_data/data_sources/ctf/web/i_got_id_demo/flag +1 -0
- package/python/tests/test_data/data_sources/ctf/web/i_got_id_demo/index.html +11 -0
- package/python/tests/test_data/data_sources/ctf/web/i_got_id_demo/solution.txt +1 -0
- package/python/tests/test_data/data_sources/debug_20240322.json +1 -0
- package/python/tests/test_data/data_sources/expert_instances.yaml +16 -0
- package/python/tests/test_data/data_sources/human_eval.json +1 -0
- package/python/tests/test_data/data_sources/simple_instances.yaml +3 -0
- package/python/tests/test_data/data_sources/simple_instances_long.yaml +30 -0
- package/python/tests/test_data/data_sources/swe-bench-dev-easy.json +1 -0
- package/python/tests/test_data/data_sources/swe-bench-dev-easy_first_only.json +1 -0
- package/python/tests/test_data/data_sources/swe-bench-lite-test.json +1 -0
- package/python/tests/test_data/trajectories/gpt4__swe-agent-test-repo__default_from_url__t-0.00__p-0.95__c-3.00__install-1/6e44b9__sweagenttestrepo-1c2844.traj +342 -0
- package/python/tests/test_data/trajectories/gpt4__swe-agent-test-repo__default_from_url__t-0.00__p-0.95__c-3.00__install-1/solution_missing_colon.py +15 -0
- package/python/tests/test_data/trajectories/gpt4__swe-agent__test-repo__default_from_url__t-0.00__p-0.95__c-3.00__install-1/args.yaml +518 -0
- package/python/tests/test_data/trajectories/gpt4__swe-agent__test-repo__default_from_url__t-0.00__p-0.95__c-3.00__install-1/swe-agent__test-repo-i1.traj +124 -0
- package/python/tests/test_data/trajectories/gpt4__swe-bench-dev-easy_first_only__default__t-0.00__p-0.95__c-3.00__install-1/all_preds.jsonl +1 -0
- package/python/tests/test_data/trajectories/gpt4__swe-bench-dev-easy_first_only__default__t-0.00__p-0.95__c-3.00__install-1/args.yaml +520 -0
- package/python/tests/test_data/trajectories/gpt4__swe-bench-dev-easy_first_only__default__t-0.00__p-0.95__c-3.00__install-1/patches/pydicom__pydicom-1458.patch +18 -0
- package/python/tests/test_data/trajectories/gpt4__swe-bench-dev-easy_first_only__default__t-0.00__p-0.95__c-3.00__install-1/pydicom__pydicom-1458.traj +257 -0
- package/python/tests/test_env.py +66 -0
- package/python/tests/test_env_utils.py +129 -0
- package/python/tests/test_history_processors.py +40 -0
- package/python/tests/test_models.py +23 -0
- package/python/tests/test_openai_live.py +164 -0
- package/python/tests/test_packaging.py +7 -0
- package/python/tests/test_parsing.py +131 -0
- package/python/tests/test_problem_statement_multimodal.py +111 -0
- package/python/tests/test_quick_stats.py +42 -0
- package/python/tests/test_run.py +37 -0
- package/python/tests/test_run_batch.py +110 -0
- package/python/tests/test_run_hooks.py +114 -0
- package/python/tests/test_run_replay.py +33 -0
- package/python/tests/test_run_single.py +125 -0
- package/python/tests/test_tools_command_parsing.py +193 -0
- package/python/tests/test_utils.py +15 -0
- package/python/tests/tools/__init__.py +0 -0
- package/python/tests/tools/conftest.py +12 -0
- package/python/tests/tools/test_default_utils.py +153 -0
- package/python/tests/tools/test_edit_replace.py +0 -0
- package/python/tests/tools/test_split_string.py +82 -0
- package/python/tests/utils.py +29 -0
- package/python/tools/diff_state/bin/_state_diff_state +52 -0
- package/python/tools/diff_state/config.yaml +2 -0
- package/python/tools/edit_anthropic/bin/_state_anthropic +21 -0
- package/python/tools/edit_anthropic/bin/str_replace_editor +710 -0
- package/python/tools/edit_anthropic/config.yaml +56 -0
- package/python/tools/edit_anthropic/install.sh +3 -0
- package/python/tools/filemap/bin/filemap +45 -0
- package/python/tools/filemap/config.yaml +9 -0
- package/python/tools/filemap/install.sh +2 -0
- package/python/tools/forfeit/bin/exit_forfeit +5 -0
- package/python/tools/forfeit/config.yaml +5 -0
- package/python/tools/image_tools/bin/view_image +36 -0
- package/python/tools/image_tools/config.yaml +9 -0
- package/python/tools/multilingual_setup/bin/do_nothing +2 -0
- package/python/tools/multilingual_setup/config.yaml +1 -0
- package/python/tools/multilingual_setup/install.sh +45 -0
- package/python/tools/registry/bin/_read_env +10 -0
- package/python/tools/registry/bin/_write_env +10 -0
- package/python/tools/registry/config.yaml +1 -0
- package/python/tools/registry/install.sh +6 -0
- package/python/tools/registry/lib/__init__.py +0 -0
- package/python/tools/registry/lib/registry.py +56 -0
- package/python/tools/review_on_submit_m/README.md +6 -0
- package/python/tools/review_on_submit_m/bin/submit +54 -0
- package/python/tools/review_on_submit_m/config.yaml +6 -0
- package/python/tools/review_on_submit_m/install.sh +0 -0
- package/python/tools/search/bin/find_file +31 -0
- package/python/tools/search/bin/search_dir +39 -0
- package/python/tools/search/bin/search_file +55 -0
- package/python/tools/search/config.yaml +37 -0
- package/python/tools/search/install.sh +3 -0
- package/python/tools/submit/bin/submit +17 -0
- package/python/tools/submit/config.yaml +5 -0
- package/python/tools/web_browser/bin/click_mouse +41 -0
- package/python/tools/web_browser/bin/close_site +28 -0
- package/python/tools/web_browser/bin/double_click_mouse +37 -0
- package/python/tools/web_browser/bin/drag_mouse +46 -0
- package/python/tools/web_browser/bin/execute_script_on_page +39 -0
- package/python/tools/web_browser/bin/get_console_output +48 -0
- package/python/tools/web_browser/bin/move_mouse +35 -0
- package/python/tools/web_browser/bin/navigate_back +33 -0
- package/python/tools/web_browser/bin/navigate_forward +33 -0
- package/python/tools/web_browser/bin/open_site +36 -0
- package/python/tools/web_browser/bin/press_keys_on_page +51 -0
- package/python/tools/web_browser/bin/reload_page +33 -0
- package/python/tools/web_browser/bin/run_web_browser_server +394 -0
- package/python/tools/web_browser/bin/screenshot_site +38 -0
- package/python/tools/web_browser/bin/scroll_on_page +40 -0
- package/python/tools/web_browser/bin/set_browser_window_size +40 -0
- package/python/tools/web_browser/bin/type_text +34 -0
- package/python/tools/web_browser/bin/wait_time +39 -0
- package/python/tools/web_browser/config.yaml +155 -0
- package/python/tools/web_browser/install.sh +22 -0
- package/python/tools/web_browser/lib/browser_manager.py +404 -0
- package/python/tools/web_browser/lib/web_browser_config.py +33 -0
- package/python/tools/web_browser/lib/web_browser_utils.py +126 -0
- package/python/tools/web_browser/test_console.html +1 -0
- package/python/tools/windowed/bin/_state +25 -0
- package/python/tools/windowed/bin/create +29 -0
- package/python/tools/windowed/bin/goto +37 -0
- package/python/tools/windowed/bin/open +49 -0
- package/python/tools/windowed/bin/scroll_down +12 -0
- package/python/tools/windowed/bin/scroll_up +13 -0
- package/python/tools/windowed/config.yaml +38 -0
- package/python/tools/windowed/install.sh +15 -0
- package/python/tools/windowed/lib/__init__.py +0 -0
- package/python/tools/windowed/lib/flake8_utils.py +147 -0
- package/python/tools/windowed/lib/windowed_file.py +312 -0
- package/python/tools/windowed_edit_linting/bin/edit +128 -0
- package/python/tools/windowed_edit_linting/config.yaml +31 -0
- package/python/tools/windowed_edit_linting/install.sh +5 -0
- package/python/tools/windowed_edit_replace/bin/edit +172 -0
- package/python/tools/windowed_edit_replace/bin/insert +77 -0
- package/python/tools/windowed_edit_replace/config.yaml +60 -0
- package/python/tools/windowed_edit_replace/install.sh +5 -0
- package/python/tools/windowed_edit_rewrite/bin/edit +78 -0
- package/python/tools/windowed_edit_rewrite/config.yaml +11 -0
- package/python/tools/windowed_edit_rewrite/install.sh +5 -0
- package/python/trajectories/demonstrations/ctf/crypto/BabyEncryption.traj +318 -0
- package/python/trajectories/demonstrations/ctf/crypto/BabyTimeCapsule.traj +197 -0
- package/python/trajectories/demonstrations/ctf/crypto/eps.traj +289 -0
- package/python/trajectories/demonstrations/ctf/crypto/katy.traj +368 -0
- package/python/trajectories/demonstrations/ctf/forensics/flash.traj +102 -0
- package/python/trajectories/demonstrations/ctf/misc/networking_1.traj +102 -0
- package/python/trajectories/demonstrations/ctf/pwn/warmup.traj +159 -0
- package/python/trajectories/demonstrations/ctf/rev/rock.traj +251 -0
- package/python/trajectories/demonstrations/ctf/web/i_got_id_demo.traj +422 -0
- package/python/trajectories/demonstrations/function_calling_simple.traj +151 -0
- package/python/trajectories/demonstrations/human_thought__swe-bench-HumanEvalFix-python__lcb__t-0.00__p-0.95__c-4.00__install-0/humanevalfix-python-0.traj +129 -0
- package/python/trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__default__t-0.20__p-0.95__c-2.00__install-1___install_from_source/marshmallow-code__marshmallow-1867.traj +318 -0
- package/python/trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__default_sys-env_cursors_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.traj +251 -0
- package/python/trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__default_sys-env_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.traj +399 -0
- package/python/trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__function_calling__install-1/marshmallow-code__marshmallow-1867.traj +594 -0
- package/python/trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__function_calling_replace__install-1/marshmallow-code__marshmallow-1867.traj +592 -0
- package/python/trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__function_calling_replace_from_source/marshmallow-code__marshmallow-1867.traj +3316 -0
- package/python/trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__xml_sys-env_cursors_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.traj +251 -0
- package/python/trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__xml_sys-env_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.traj +399 -0
- package/python/trajectories/demonstrations/str_replace_anthropic_demo.yaml +432 -0
- package/rust/Cargo.toml +100 -0
- package/rust/README.md +49 -0
- package/rust/src/agent/action_sampler.rs +130 -0
- package/rust/src/agent/agents.rs +1029 -0
- package/rust/src/agent/history_processors.rs +277 -0
- package/rust/src/agent/hooks/mod.rs +208 -0
- package/rust/src/agent/mod.rs +24 -0
- package/rust/src/agent/models.rs +837 -0
- package/rust/src/agent/problem_statement.rs +355 -0
- package/rust/src/agent/reviewer.rs +505 -0
- package/rust/src/bin/sweagent.rs +784 -0
- package/rust/src/environment/deployment.rs +631 -0
- package/rust/src/environment/hooks/mod.rs +114 -0
- package/rust/src/environment/mod.rs +16 -0
- package/rust/src/environment/repo.rs +265 -0
- package/rust/src/environment/runtime.rs +237 -0
- package/rust/src/environment/swe_env.rs +248 -0
- package/rust/src/exceptions.rs +228 -0
- package/rust/src/lib.rs +68 -0
- package/rust/src/monitoring.rs +482 -0
- package/rust/src/run/hooks/mod.rs +134 -0
- package/rust/src/run/mod.rs +12 -0
- package/rust/src/run/run_batch.rs +563 -0
- package/rust/src/run/run_single.rs +196 -0
- package/rust/src/tools/bundle.rs +224 -0
- package/rust/src/tools/commands.rs +173 -0
- package/rust/src/tools/mod.rs +295 -0
- package/rust/src/tools/parsing.rs +354 -0
- package/rust/src/tools/registry.rs +143 -0
- package/rust/src/types.rs +554 -0
- package/rust/src/utils/config.rs +105 -0
- package/rust/src/utils/files.rs +137 -0
- package/rust/src/utils/github.rs +171 -0
- package/rust/src/utils/log.rs +65 -0
- package/rust/src/utils/mod.rs +17 -0
- package/rust/src/utils/serialization.rs +181 -0
- package/rust/src/utils/template.rs +173 -0
- package/typescript/README.md +335 -0
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
//! Batch runner for SWE-agent
|
|
2
|
+
|
|
3
|
+
use super::hooks::{CombinedRunHook, RunHook};
|
|
4
|
+
use super::run_single::{RunSingle, RunSingleActionConfig, RunSingleConfig};
|
|
5
|
+
use crate::agent::problem_statement::ProblemStatementConfig;
|
|
6
|
+
use crate::agent::AgentConfig;
|
|
7
|
+
use crate::environment::EnvironmentConfig;
|
|
8
|
+
use crate::exceptions::{Result, SWEAgentError};
|
|
9
|
+
use crate::types::{AgentRunResult, SimpleBatchInstance};
|
|
10
|
+
use serde::{Deserialize, Serialize};
|
|
11
|
+
use std::path::PathBuf;
|
|
12
|
+
|
|
13
|
+
/// Configuration for batch instance sources
|
|
14
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
15
|
+
#[serde(tag = "type", rename_all = "snake_case")]
|
|
16
|
+
pub enum BatchInstanceSourceConfig {
|
|
17
|
+
File {
|
|
18
|
+
path: String,
|
|
19
|
+
#[serde(default)]
|
|
20
|
+
filter: Option<String>,
|
|
21
|
+
#[serde(default)]
|
|
22
|
+
slice: Option<String>,
|
|
23
|
+
#[serde(default)]
|
|
24
|
+
shuffle: bool,
|
|
25
|
+
},
|
|
26
|
+
SweBench {
|
|
27
|
+
#[serde(default = "default_subset")]
|
|
28
|
+
subset: String,
|
|
29
|
+
#[serde(default = "default_split")]
|
|
30
|
+
split: String,
|
|
31
|
+
#[serde(default)]
|
|
32
|
+
filter: Option<String>,
|
|
33
|
+
#[serde(default)]
|
|
34
|
+
slice: Option<String>,
|
|
35
|
+
#[serde(default)]
|
|
36
|
+
shuffle: bool,
|
|
37
|
+
#[serde(default)]
|
|
38
|
+
evaluate: bool,
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fn default_subset() -> String {
|
|
43
|
+
"lite".to_string()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fn default_split() -> String {
|
|
47
|
+
"dev".to_string()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
impl Default for BatchInstanceSourceConfig {
|
|
51
|
+
fn default() -> Self {
|
|
52
|
+
Self::File {
|
|
53
|
+
path: "instances.yaml".to_string(),
|
|
54
|
+
filter: None,
|
|
55
|
+
slice: None,
|
|
56
|
+
shuffle: false,
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// Configuration for batch runs
|
|
62
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
63
|
+
pub struct RunBatchConfig {
|
|
64
|
+
#[serde(default)]
|
|
65
|
+
pub agent: AgentConfig,
|
|
66
|
+
#[serde(default)]
|
|
67
|
+
pub env: EnvironmentConfig,
|
|
68
|
+
#[serde(default)]
|
|
69
|
+
pub instances: BatchInstanceSourceConfig,
|
|
70
|
+
#[serde(default = "default_output_dir")]
|
|
71
|
+
pub output_dir: String,
|
|
72
|
+
#[serde(default = "default_num_workers")]
|
|
73
|
+
pub num_workers: usize,
|
|
74
|
+
#[serde(default)]
|
|
75
|
+
pub redo_existing: bool,
|
|
76
|
+
#[serde(default = "default_random_delay")]
|
|
77
|
+
pub random_delay_multiplier: f64,
|
|
78
|
+
#[serde(default)]
|
|
79
|
+
pub actions: RunSingleActionConfig,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
fn default_output_dir() -> String {
|
|
83
|
+
"./trajectories".to_string()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fn default_num_workers() -> usize {
|
|
87
|
+
1
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
fn default_random_delay() -> f64 {
|
|
91
|
+
0.3
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
impl Default for RunBatchConfig {
|
|
95
|
+
fn default() -> Self {
|
|
96
|
+
Self {
|
|
97
|
+
agent: AgentConfig::default(),
|
|
98
|
+
env: EnvironmentConfig::default(),
|
|
99
|
+
instances: BatchInstanceSourceConfig::default(),
|
|
100
|
+
output_dir: default_output_dir(),
|
|
101
|
+
num_workers: default_num_workers(),
|
|
102
|
+
redo_existing: false,
|
|
103
|
+
random_delay_multiplier: default_random_delay(),
|
|
104
|
+
actions: RunSingleActionConfig::default(),
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/// Result of a batch run
|
|
110
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
111
|
+
pub struct BatchRunResult {
|
|
112
|
+
pub results: Vec<InstanceResult>,
|
|
113
|
+
pub total_instances: usize,
|
|
114
|
+
pub completed: usize,
|
|
115
|
+
pub skipped: usize,
|
|
116
|
+
pub failed: usize,
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/// Result for a single instance in a batch
|
|
120
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
121
|
+
pub struct InstanceResult {
|
|
122
|
+
pub instance_id: String,
|
|
123
|
+
pub status: InstanceStatus,
|
|
124
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
125
|
+
pub result: Option<AgentRunResult>,
|
|
126
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
127
|
+
pub error: Option<String>,
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// Status of an instance run
|
|
131
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
132
|
+
#[serde(rename_all = "snake_case")]
|
|
133
|
+
pub enum InstanceStatus {
|
|
134
|
+
Completed,
|
|
135
|
+
Skipped,
|
|
136
|
+
Failed,
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// Batch runner for multiple problem instances
|
|
140
|
+
pub struct RunBatch {
|
|
141
|
+
config: RunBatchConfig,
|
|
142
|
+
instances: Vec<SimpleBatchInstance>,
|
|
143
|
+
hooks: CombinedRunHook,
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
impl RunBatch {
|
|
147
|
+
pub fn new(config: RunBatchConfig) -> Result<Self> {
|
|
148
|
+
Ok(Self {
|
|
149
|
+
config,
|
|
150
|
+
instances: Vec::new(),
|
|
151
|
+
hooks: CombinedRunHook::new(),
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// Create from configuration
|
|
156
|
+
pub fn from_config(config: RunBatchConfig) -> Self {
|
|
157
|
+
Self {
|
|
158
|
+
config,
|
|
159
|
+
instances: Vec::new(),
|
|
160
|
+
hooks: CombinedRunHook::new(),
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/// Add a hook
|
|
165
|
+
pub fn add_hook(&mut self, hook: Box<dyn RunHook>) {
|
|
166
|
+
self.hooks.add_hook(hook);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/// Load instances from source
|
|
170
|
+
pub async fn load_instances(&mut self) -> Result<()> {
|
|
171
|
+
let instances_config = self.config.instances.clone();
|
|
172
|
+
match instances_config {
|
|
173
|
+
BatchInstanceSourceConfig::File {
|
|
174
|
+
path,
|
|
175
|
+
filter,
|
|
176
|
+
slice,
|
|
177
|
+
shuffle,
|
|
178
|
+
} => {
|
|
179
|
+
self.load_from_file(&path, filter.as_deref(), slice.as_deref(), shuffle)?;
|
|
180
|
+
}
|
|
181
|
+
BatchInstanceSourceConfig::SweBench {
|
|
182
|
+
subset,
|
|
183
|
+
split,
|
|
184
|
+
filter,
|
|
185
|
+
slice,
|
|
186
|
+
shuffle,
|
|
187
|
+
..
|
|
188
|
+
} => {
|
|
189
|
+
self.load_swe_bench(
|
|
190
|
+
&subset,
|
|
191
|
+
&split,
|
|
192
|
+
filter.as_deref(),
|
|
193
|
+
slice.as_deref(),
|
|
194
|
+
shuffle,
|
|
195
|
+
)
|
|
196
|
+
.await?;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
Ok(())
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
fn load_from_file(
|
|
203
|
+
&mut self,
|
|
204
|
+
path: &str,
|
|
205
|
+
filter: Option<&str>,
|
|
206
|
+
slice: Option<&str>,
|
|
207
|
+
shuffle: bool,
|
|
208
|
+
) -> Result<()> {
|
|
209
|
+
let content = std::fs::read_to_string(path)?;
|
|
210
|
+
|
|
211
|
+
// Try YAML first, then JSON
|
|
212
|
+
let instances: Vec<SimpleBatchInstance> =
|
|
213
|
+
if path.ends_with(".yaml") || path.ends_with(".yml") {
|
|
214
|
+
serde_yaml::from_str(&content)?
|
|
215
|
+
} else {
|
|
216
|
+
serde_json::from_str(&content)?
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
self.instances = self.filter_instances(instances, filter, slice, shuffle);
|
|
220
|
+
Ok(())
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async fn load_swe_bench(
|
|
224
|
+
&mut self,
|
|
225
|
+
subset: &str,
|
|
226
|
+
split: &str,
|
|
227
|
+
filter: Option<&str>,
|
|
228
|
+
slice: Option<&str>,
|
|
229
|
+
shuffle: bool,
|
|
230
|
+
) -> Result<()> {
|
|
231
|
+
// SWE-bench can be loaded from:
|
|
232
|
+
// 1. HuggingFace datasets API (requires external download)
|
|
233
|
+
// 2. Local pre-downloaded files
|
|
234
|
+
// 3. A cached path
|
|
235
|
+
|
|
236
|
+
tracing::info!(
|
|
237
|
+
subset = subset,
|
|
238
|
+
split = split,
|
|
239
|
+
"Loading SWE-bench instances"
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
// Try common locations for pre-downloaded SWE-bench data
|
|
243
|
+
let possible_paths = [
|
|
244
|
+
format!("data/swe-bench-{}-{}.json", subset, split),
|
|
245
|
+
format!("data/swe-bench/{}/{}.json", subset, split),
|
|
246
|
+
format!(
|
|
247
|
+
"{}/swe-bench-{}-{}.json",
|
|
248
|
+
std::env::var("SWE_BENCH_DATA").unwrap_or_default(),
|
|
249
|
+
subset,
|
|
250
|
+
split
|
|
251
|
+
),
|
|
252
|
+
format!("~/.cache/sweagent/swe-bench-{}-{}.json", subset, split),
|
|
253
|
+
];
|
|
254
|
+
|
|
255
|
+
// Expand ~ in paths
|
|
256
|
+
let home = std::env::var("HOME").unwrap_or_default();
|
|
257
|
+
let expanded_paths: Vec<String> = possible_paths
|
|
258
|
+
.iter()
|
|
259
|
+
.map(|p| p.replace("~", &home))
|
|
260
|
+
.collect();
|
|
261
|
+
|
|
262
|
+
for path in &expanded_paths {
|
|
263
|
+
if std::path::Path::new(path).exists() {
|
|
264
|
+
tracing::info!(path = path, "Found SWE-bench data file");
|
|
265
|
+
return self.load_from_file(path, filter, slice, shuffle);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// If not found locally, try to download from HuggingFace
|
|
270
|
+
let url = format!(
|
|
271
|
+
"https://huggingface.co/datasets/princeton-nlp/SWE-bench_{}/resolve/main/{}.json",
|
|
272
|
+
subset, split
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
tracing::info!(url = &url, "Downloading SWE-bench data from HuggingFace");
|
|
276
|
+
|
|
277
|
+
let client = reqwest::Client::new();
|
|
278
|
+
let response =
|
|
279
|
+
client.get(&url).send().await.map_err(|e| {
|
|
280
|
+
SWEAgentError::ApiError(format!("Failed to download SWE-bench: {}", e))
|
|
281
|
+
})?;
|
|
282
|
+
|
|
283
|
+
if !response.status().is_success() {
|
|
284
|
+
return Err(SWEAgentError::ConfigurationError(format!(
|
|
285
|
+
"SWE-bench data not found. Please download {} subset manually or set SWE_BENCH_DATA env var. \
|
|
286
|
+
Tried paths: {:?}. API response: {}",
|
|
287
|
+
subset, expanded_paths, response.status()
|
|
288
|
+
)));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
let content = response.text().await?;
|
|
292
|
+
|
|
293
|
+
// Parse the JSON content - SWE-bench format is a list of objects
|
|
294
|
+
let raw_instances: Vec<serde_json::Value> = serde_json::from_str(&content)?;
|
|
295
|
+
|
|
296
|
+
let instances: Vec<SimpleBatchInstance> = raw_instances
|
|
297
|
+
.into_iter()
|
|
298
|
+
.filter_map(|obj| {
|
|
299
|
+
let id = obj
|
|
300
|
+
.get("instance_id")
|
|
301
|
+
.and_then(|v| v.as_str())
|
|
302
|
+
.map(String::from)?;
|
|
303
|
+
|
|
304
|
+
let problem_statement = obj
|
|
305
|
+
.get("problem_statement")
|
|
306
|
+
.and_then(|v| v.as_str())
|
|
307
|
+
.map(String::from)
|
|
308
|
+
.unwrap_or_default();
|
|
309
|
+
|
|
310
|
+
let repo = obj
|
|
311
|
+
.get("repo")
|
|
312
|
+
.and_then(|v| v.as_str())
|
|
313
|
+
.map(|r| format!("https://github.com/{}", r));
|
|
314
|
+
|
|
315
|
+
Some(SimpleBatchInstance {
|
|
316
|
+
id,
|
|
317
|
+
problem_statement,
|
|
318
|
+
repo_path: None,
|
|
319
|
+
github_url: repo,
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
.collect();
|
|
323
|
+
|
|
324
|
+
self.instances = self.filter_instances(instances, filter, slice, shuffle);
|
|
325
|
+
|
|
326
|
+
tracing::info!(count = self.instances.len(), "Loaded SWE-bench instances");
|
|
327
|
+
|
|
328
|
+
Ok(())
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
fn filter_instances(
|
|
332
|
+
&self,
|
|
333
|
+
mut instances: Vec<SimpleBatchInstance>,
|
|
334
|
+
filter: Option<&str>,
|
|
335
|
+
slice: Option<&str>,
|
|
336
|
+
shuffle: bool,
|
|
337
|
+
) -> Vec<SimpleBatchInstance> {
|
|
338
|
+
// Apply filter
|
|
339
|
+
if let Some(pattern) = filter {
|
|
340
|
+
if let Ok(re) = regex::Regex::new(pattern) {
|
|
341
|
+
instances.retain(|i| re.is_match(&i.id));
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Apply shuffle
|
|
346
|
+
if shuffle {
|
|
347
|
+
use rand::seq::SliceRandom;
|
|
348
|
+
let mut rng = rand::thread_rng();
|
|
349
|
+
instances.shuffle(&mut rng);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// Apply slice
|
|
353
|
+
if let Some(slice_str) = slice {
|
|
354
|
+
instances = self.apply_slice(instances, slice_str);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
instances
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
fn apply_slice(
|
|
361
|
+
&self,
|
|
362
|
+
instances: Vec<SimpleBatchInstance>,
|
|
363
|
+
slice_str: &str,
|
|
364
|
+
) -> Vec<SimpleBatchInstance> {
|
|
365
|
+
// Parse slice string like ":50", "10:20", "::2"
|
|
366
|
+
let parts: Vec<&str> = slice_str.split(':').collect();
|
|
367
|
+
|
|
368
|
+
let start = parts
|
|
369
|
+
.first()
|
|
370
|
+
.and_then(|s| s.parse::<usize>().ok())
|
|
371
|
+
.unwrap_or(0);
|
|
372
|
+
|
|
373
|
+
let end = parts
|
|
374
|
+
.get(1)
|
|
375
|
+
.and_then(|s| s.parse::<usize>().ok())
|
|
376
|
+
.unwrap_or(instances.len());
|
|
377
|
+
|
|
378
|
+
let step = parts
|
|
379
|
+
.get(2)
|
|
380
|
+
.and_then(|s| s.parse::<usize>().ok())
|
|
381
|
+
.unwrap_or(1);
|
|
382
|
+
|
|
383
|
+
instances
|
|
384
|
+
.into_iter()
|
|
385
|
+
.skip(start)
|
|
386
|
+
.take(end - start)
|
|
387
|
+
.step_by(step.max(1))
|
|
388
|
+
.collect()
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/// Check if an instance already has results
|
|
392
|
+
fn has_existing_result(&self, instance_id: &str) -> bool {
|
|
393
|
+
if self.config.redo_existing {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
let traj_path =
|
|
398
|
+
PathBuf::from(&self.config.output_dir).join(format!("{}.traj", instance_id));
|
|
399
|
+
|
|
400
|
+
traj_path.exists()
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/// Run all instances
|
|
404
|
+
pub async fn main(&mut self) -> Result<BatchRunResult> {
|
|
405
|
+
self.load_instances().await?;
|
|
406
|
+
|
|
407
|
+
let total = self.instances.len();
|
|
408
|
+
tracing::info!(
|
|
409
|
+
total = total,
|
|
410
|
+
workers = self.config.num_workers,
|
|
411
|
+
"Starting batch run"
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
self.hooks.on_start();
|
|
415
|
+
|
|
416
|
+
let mut results = Vec::new();
|
|
417
|
+
let mut completed = 0;
|
|
418
|
+
let mut skipped = 0;
|
|
419
|
+
let mut failed = 0;
|
|
420
|
+
|
|
421
|
+
for (idx, instance) in self.instances.clone().into_iter().enumerate() {
|
|
422
|
+
tracing::info!(
|
|
423
|
+
idx = idx,
|
|
424
|
+
total = total,
|
|
425
|
+
instance_id = %instance.id,
|
|
426
|
+
"Processing instance"
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
// Check for existing result
|
|
430
|
+
if self.has_existing_result(&instance.id) {
|
|
431
|
+
tracing::info!(instance_id = %instance.id, "Skipping - already exists");
|
|
432
|
+
self.hooks.on_instance_skipped("Already exists");
|
|
433
|
+
skipped += 1;
|
|
434
|
+
results.push(InstanceResult {
|
|
435
|
+
instance_id: instance.id,
|
|
436
|
+
status: InstanceStatus::Skipped,
|
|
437
|
+
result: None,
|
|
438
|
+
error: None,
|
|
439
|
+
});
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
self.hooks.on_instance_start(idx, &instance.id);
|
|
444
|
+
|
|
445
|
+
// Create config for this instance
|
|
446
|
+
let single_config = RunSingleConfig {
|
|
447
|
+
agent: self.config.agent.clone(),
|
|
448
|
+
env: self.config.env.clone(),
|
|
449
|
+
problem_statement: ProblemStatementConfig::Text {
|
|
450
|
+
text: instance.problem_statement.clone(),
|
|
451
|
+
id: instance.id.clone(),
|
|
452
|
+
},
|
|
453
|
+
output_dir: self.config.output_dir.clone(),
|
|
454
|
+
actions: self.config.actions.clone(),
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
// Run the instance
|
|
458
|
+
match RunSingle::from_config(single_config) {
|
|
459
|
+
Ok(mut runner) => match runner.run().await {
|
|
460
|
+
Ok(result) => {
|
|
461
|
+
self.hooks.on_instance_completed(&result);
|
|
462
|
+
completed += 1;
|
|
463
|
+
results.push(InstanceResult {
|
|
464
|
+
instance_id: instance.id,
|
|
465
|
+
status: InstanceStatus::Completed,
|
|
466
|
+
result: Some(result),
|
|
467
|
+
error: None,
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
Err(e) => {
|
|
471
|
+
tracing::error!(error = %e, instance_id = %instance.id, "Instance failed");
|
|
472
|
+
failed += 1;
|
|
473
|
+
results.push(InstanceResult {
|
|
474
|
+
instance_id: instance.id,
|
|
475
|
+
status: InstanceStatus::Failed,
|
|
476
|
+
result: None,
|
|
477
|
+
error: Some(e.to_string()),
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
Err(e) => {
|
|
482
|
+
tracing::error!(error = %e, instance_id = %instance.id, "Failed to create runner");
|
|
483
|
+
failed += 1;
|
|
484
|
+
results.push(InstanceResult {
|
|
485
|
+
instance_id: instance.id,
|
|
486
|
+
status: InstanceStatus::Failed,
|
|
487
|
+
result: None,
|
|
488
|
+
error: Some(e.to_string()),
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// Add random delay between instances
|
|
494
|
+
if self.config.random_delay_multiplier > 0.0 {
|
|
495
|
+
let delay = rand::random::<f64>() * self.config.random_delay_multiplier;
|
|
496
|
+
tokio::time::sleep(std::time::Duration::from_secs_f64(delay)).await;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
self.hooks.on_end();
|
|
501
|
+
|
|
502
|
+
let batch_result = BatchRunResult {
|
|
503
|
+
results,
|
|
504
|
+
total_instances: total,
|
|
505
|
+
completed,
|
|
506
|
+
skipped,
|
|
507
|
+
failed,
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// Save summary
|
|
511
|
+
self.save_summary(&batch_result)?;
|
|
512
|
+
|
|
513
|
+
tracing::info!(
|
|
514
|
+
completed = completed,
|
|
515
|
+
skipped = skipped,
|
|
516
|
+
failed = failed,
|
|
517
|
+
"Batch run complete"
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
Ok(batch_result)
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
fn save_summary(&self, result: &BatchRunResult) -> Result<()> {
|
|
524
|
+
let summary_path = PathBuf::from(&self.config.output_dir).join("batch_summary.json");
|
|
525
|
+
let json = serde_json::to_string_pretty(result)?;
|
|
526
|
+
std::fs::write(summary_path, json)?;
|
|
527
|
+
Ok(())
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/// Run batch from configuration
|
|
532
|
+
pub async fn run_batch_from_config(config: RunBatchConfig) -> Result<BatchRunResult> {
|
|
533
|
+
let mut runner = RunBatch::from_config(config);
|
|
534
|
+
runner.main().await
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
#[cfg(test)]
|
|
538
|
+
mod tests {
|
|
539
|
+
use super::*;
|
|
540
|
+
|
|
541
|
+
#[test]
|
|
542
|
+
fn test_batch_config_default() {
|
|
543
|
+
let config = RunBatchConfig::default();
|
|
544
|
+
assert_eq!(config.num_workers, 1);
|
|
545
|
+
assert!(!config.redo_existing);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
#[test]
|
|
549
|
+
fn test_apply_slice() {
|
|
550
|
+
let runner = RunBatch::from_config(RunBatchConfig::default());
|
|
551
|
+
let instances: Vec<SimpleBatchInstance> = (0..10)
|
|
552
|
+
.map(|i| SimpleBatchInstance {
|
|
553
|
+
id: format!("instance-{}", i),
|
|
554
|
+
problem_statement: "test".to_string(),
|
|
555
|
+
repo_path: None,
|
|
556
|
+
github_url: None,
|
|
557
|
+
})
|
|
558
|
+
.collect();
|
|
559
|
+
|
|
560
|
+
let sliced = runner.apply_slice(instances, ":5");
|
|
561
|
+
assert_eq!(sliced.len(), 5);
|
|
562
|
+
}
|
|
563
|
+
}
|