Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/bosswnx_deeplearning-course-nju.json

1 line
6.3 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"repo": "bosswnx/deeplearning-course-nju", "files": {"run.sh": {"5da492c448b6b8005e878de1bf5fe72ca722a260": {"t": 1785745950.3447845, "n": 5179, "h": "e4f50d51783d7f98", "c": "#!/bin/bash\n# ============================================================\n# LLM-APR 实验一键运行脚本\n#\n# 使用前请确保:\n# 1. 已安装 Defects4J 并添加到 PATH\n# 2. 已安装 Java 8\n# 3. 已设置 DEEPSEEK_API_KEY 环境变量\n# 4. 已安装 Python 依赖: pip install -r requirements.txt\n#\n# 用法:\n# # 完整运行(提取数据 + 三种策略全部运行)\n# bash run.sh full\n#\n# # 仅提取缺陷数据\n# bash run.sh extract\n#\n# # 快速测试(仅取 5 个缺陷 × basic 策略,验证流程能跑通)\n# bash run.sh quick\n#\n# # 仅运行实验(已有 bugs.json)\n# bash run.sh experiment\n#\n# # 仅分析结果\n# bash run.sh analyze\n# ============================================================\n\nset -e\n\nSCRIPT_DIR=\"$(cd \"$(dirname \"$0\")\" && pwd)\"\ncd \"$SCRIPT_DIR\"\n\n# 颜色输出\nRED='\\033[0;31m'\nGREEN='\\033[0;32m'\nYELLOW='\\033[1;33m'\nNC='\\033[0m'\n\ninfo() { echo -e \"${GREEN}[INFO]${NC} $1\"; }\nwarn() { echo -e \"${YELLOW}[WARN]${NC} $1\"; }\nerror() { echo -e \"${RED}[ERROR]${NC} $1\"; exit 1; }\n\n# ==================== 环境检查 ====================\ncheck_env() {\n info \"检查运行环境...\"\n\n # Java\n if ! command -v java &>/dev/null; then\n error \"Java not found! 请安装 JDK 1.8\"\n fi\n java_version=$(java -version 2>&1 | head -1)\n info \"Java: $java_version\"\n\n # Python\n if ! command -v python3 &>/dev/null; then\n error \"Python3 not found!\"\n fi\n python_version=$(python3 --version)\n info \"Python: $python_version\"\n\n # Defects4J\n if ! command -v defects4j &>/dev/null; then\n if [ -n \"$DEFECTS4J_HOME\" ] && [ -f \"$DEFECTS4J_HOME/framework/bin/defects4j\" ]; then\n export PATH=\"$PATH:$DEFECTS4J_HOME/framework/bin\"\n info \"Defects4J found at: $DEFECTS4J_HOME\"\n else\n error \"Defects4J not found!\\n 请安装: git clone https://github.com/rjust/defects4j && cd defects4j && ./init.sh\\n 然后: export PATH=\\$PATH:\\$(pwd)/framework/bin\"\n fi\n else\n info \"Defects4J: $(which defects4j)\"\n fi\n\n # API Key\n if [ -z \"$DEEPSEEK_API_KEY\" ]; then\n error \"DEEPSEEK_API_KEY not set!\\n 请运行: export DEEPSEEK_API_KEY='your_key_here'\"\n fi\n info \"DEEPSEEK_API_KEY: ***$(echo $DEEPSEEK_API_KEY | tail -c 5)\"\n\n # Python 依赖\n python3 -c \"import openai, tqdm\" 2>/dev/null || {\n warn \"缺少 Python 依赖,正在安装...\"\n pip install -r requirements.txt\n }\n\n info \"环境检查通过!\"\n echo \"\"\n}\n\n# ==================== 步骤 1: 提取缺陷数据 ====================\ndo_extract() {\n info \"========== 步骤 1: 提取缺陷数据 ==========\"\n\n if [ -f \"data/bugs.json\" ]; then\n count=$(python3 -c \"import json; print(len(json.load(open('data/bugs.json'))))\")\n warn \"data/bugs.json 已存在 ($count 个缺陷), 跳过提取\"\n warn \"如需重新提取,请先删除 data/bugs.json\"\n return\n fi\n\n # 可以通过 --max-per-project 控制数量,快速测试时用 5\n extra_args=\"\"\n if [ \"$1\" = \"quick\" ]; then\n extra_args=\"--projects Chart Lang Math --max-per-project 5\"\n info \"快速模式: 仅提取 Chart/Lang/Math 各 5 个缺陷\"\n fi\n\n python3 scripts/extract_bugs.py --output data/bugs.json $extra_args\n\n count=$(python3 -c \"import json; print(len(json.load(open('data/bugs.json'))))\")\n info \"提取完成: $count 个缺陷 -> data/bugs.json\"\n echo \"\"\n}\n\n# ==================== 步骤 2: 运行实验 ====================\ndo_experiment() {\n info \"========== 步骤 2: 运行实验 ==========\"\n\n if [ ! -f \"data/bugs.json\" ]; then\n error \"data/bugs.json 不存在! 请先运行: bash run.sh extract\"\n fi\n\n strategy=\"${1:-all}\"\n limit_arg=\"\"\n if [ -n \"$2\" ]; then\n limit_arg=\"--limit $2\"\n fi\n\n info \"策略: $strategy\"\n python3 scripts/run_experiment.py \\\n --bugs data/bugs.json \\\n --strategy \"$strategy\" \\\n --output results/ \\\n $limit_arg\n\n info \"实验完成! 结果保存在 results/ 目录\"\n echo \"\"\n}\n\n# ==================== 步骤 3: 分析结果 ====================\ndo_analyze() {\n info \"========== 步骤 3: 分析结果 ==========\"\n\n if [ ! -d \"results\" ]; then\n error \"results/ 目录不存在! 请先运行实验\"\n fi\n\n python3 scripts/analyze_results.py \\\n --results-dir results/ \\\n --output results/analysis.md\n\n info \"分析报告: results/analysis.md\"\n echo \"\"\n}\n\n# ==================== 主入口 ====================\ncase \"${1:-help}\" in\n full)\n check_env\n do_extract\n do_experiment \"all\"\n do_analyze\n info \"全部完成!\"\n ;;\n quick)\n check_env\n do_extract \"quick\"\n do_experiment \"basic\" \"\"\n do_analyze\n info \"快速测试完成! 请查看 results/analysis.md\"\n ;;\n extract)\n check_env\n do_extract \"${2:-}\"\n ;;\n experiment)\n check_env\n do_experiment \"${2:-all}\" \"${3:-}\"\n ;;\n analyze)\n do_analyze\n ;;\n help|*)\n echo \"\"\n echo \"LLM-APR 实验运行脚本\"\n echo \"\"\n echo \"用法: bash run.sh <command>\"\n echo \"\"\n echo \"命令:\"\n echo \" full 完整运行 (提取 + 实验 + 分析)\"\n echo \" quick 快速测试 (15个缺陷 × basic策略)\"\n echo \" extract 仅提取缺陷数据\"\n echo \" experiment 仅运行实验 [strategy] [limit]\"\n echo \" e.g. bash run.sh experiment basic 10\"\n echo \" analyze 仅分析结果\"\n echo \" help 显示此帮助\"\n echo \"\"\n echo \"环境变量:\"\n echo \" DEEPSEEK_API_KEY DeepSeek API密钥 (必须)\"\n echo \" DEFECTS4J_HOME Defects4J安装目录\"\n echo \"\"\n ;;\nesac\n"}}}}