Download data/processed/RQ1/RecruitmentAssistant-MCP/evaluate_success.py from AINativeOps/AINativeBench: direct link, hf CLI and curl.
- Browser
- Download file 5.28 kB
-
https://huggingface.co/datasets/AINativeOps/AINativeBench/resolve/main/data/processed/RQ1/RecruitmentAssistant-MCP/evaluate_success.py
- Command line
-
hf download hf://datasets/AINativeOps/AINativeBench/data/processed/RQ1/RecruitmentAssistant-MCP/evaluate_success.py
-
curl -L -o evaluate_success.py https://huggingface.co/datasets/AINativeOps/AINativeBench/resolve/main/data/processed/RQ1/RecruitmentAssistant-MCP/evaluate_success.py
5.28 kB
| #!/usr/bin/env python3 | |
| """ | |
| Calculate success rates for models on RecruitmentAssistant-MCP task | |
| Success criteria: reports folder exists and contains multiple (>=2) md files | |
| """ | |
| import json | |
| import os | |
| from pathlib import Path | |
| from collections import defaultdict | |
| # Define base path and model list | |
| BASE_DIR = Path("/Users/wzr/TOSEM-2025/RESULTS") | |
| MODELS = [ | |
| "DeepSeek-R1", | |
| "DeepSeek-V3-1", | |
| "GPT-4o-mini", | |
| "GPT-5", | |
| "Gemini-2.5-flash", | |
| "Gemini-2.5-flash-nothinking", | |
| "Qwen3-235b", | |
| ] | |
| PROJECT_NAME = "RecruitmentAssistant-MCP" | |
| def check_reports_success(reports_dir: Path) -> dict: | |
| """ | |
| Check if reports folder meets success criteria | |
| Success criteria: | |
| 1. reports folder exists | |
| 2. Contains multiple (>=2) md files | |
| Returns: | |
| { | |
| 'success': bool, | |
| 'reports_exists': bool, | |
| 'md_count': int, | |
| 'md_files': list | |
| } | |
| """ | |
| result = {"success": False, "reports_exists": False, "md_count": 0, "md_files": []} | |
| # Check if reports folder exists | |
| if not reports_dir.exists() or not reports_dir.is_dir(): | |
| return result | |
| result["reports_exists"] = True | |
| # Count md files | |
| md_files = sorted([f.name for f in reports_dir.glob("*.md")]) | |
| result["md_count"] = len(md_files) | |
| result["md_files"] = md_files | |
| # Determine success: at least 2 md files | |
| result["success"] = result["md_count"] >= 2 | |
| return result | |
| def analyze_model_results(): | |
| """Analyze execution results for each model""" | |
| results = {} | |
| for model in MODELS: | |
| test_results_dir = BASE_DIR / model / PROJECT_NAME / "test_results" | |
| if not test_results_dir.exists(): | |
| print( | |
| f"Warning: test_results directory not found for model {model}: {test_results_dir}" | |
| ) | |
| continue | |
| model_stats = { | |
| "success_count": 0, | |
| "failure_count": 0, | |
| "total_count": 0, | |
| "sessions": [], | |
| } | |
| # Iterate through all session subdirectories | |
| for session_dir in sorted(test_results_dir.iterdir()): | |
| if not session_dir.is_dir(): | |
| continue | |
| reports_dir = session_dir / "reports" | |
| # Check reports folder and md files | |
| check_result = check_reports_success(reports_dir) | |
| model_stats["total_count"] += 1 | |
| if check_result["success"]: | |
| model_stats["success_count"] += 1 | |
| else: | |
| model_stats["failure_count"] += 1 | |
| model_stats["sessions"].append( | |
| { | |
| "session": session_dir.name, | |
| "success": check_result["success"], | |
| "reports_exists": check_result["reports_exists"], | |
| "md_count": check_result["md_count"], | |
| "md_files": check_result["md_files"], | |
| } | |
| ) | |
| results[model] = model_stats | |
| return results | |
| def print_summary(results): | |
| """Print statistics summary""" | |
| print("\n" + "=" * 80) | |
| print(f"Model Execution Results - {PROJECT_NAME}") | |
| print("=" * 80 + "\n") | |
| for model, stats in results.items(): | |
| total = stats["total_count"] | |
| success = stats["success_count"] | |
| failure = stats["failure_count"] | |
| if total > 0: | |
| success_rate = (success / total) * 100 | |
| print(f"{model}") | |
| print(f" Total: {total} runs") | |
| print( | |
| f" Success: {success} runs (reports exists with >=2 md files, {success_rate:.1f}%)" | |
| ) | |
| print(f" Failure: {failure} runs ({100-success_rate:.1f}%)") | |
| print() | |
| else: | |
| print(f"{model}") | |
| print(f" No data") | |
| print() | |
| print("=" * 80) | |
| def save_detailed_results(results, output_file="success_detailed_results.json"): | |
| """Save detailed results to JSON file""" | |
| output_path = Path(__file__).parent / output_file | |
| with open(output_path, "w", encoding="utf-8") as f: | |
| json.dump(results, f, indent=2, ensure_ascii=False) | |
| print(f"\nDetailed results saved to: {output_path}") | |
| def save_csv_summary(results, output_file="success_rate.csv"): | |
| """Save summary to CSV file""" | |
| import csv | |
| output_path = Path(__file__).parent / output_file | |
| with open(output_path, "w", newline="", encoding="utf-8") as f: | |
| writer = csv.writer(f) | |
| writer.writerow(["Model", "Total", "Success", "Failure", "Success_Rate(%)"]) | |
| for model, stats in results.items(): | |
| total = stats["total_count"] | |
| success = stats["success_count"] | |
| failure = stats["failure_count"] | |
| success_rate = (success / total * 100) if total > 0 else 0 | |
| writer.writerow([model, total, success, failure, f"{success_rate:.2f}"]) | |
| print(f"CSV summary saved to: {output_path}") | |
| if __name__ == "__main__": | |
| print(f"Starting success rate calculation - {PROJECT_NAME}") | |
| print( | |
| f"Success criteria: reports folder exists and contains multiple (>=2) md files\n" | |
| ) | |
| results = analyze_model_results() | |
| print_summary(results) | |
| save_detailed_results(results) | |
| save_csv_summary(results) | |
| print("\nCalculation completed!") | |