from __future__ import annotations from pathlib import Path from ..catalog import get_catalog from ..config import settings from ..coverage import get_coverage_report REQUIRED_TASKS = { "dataset.upload": "covered_by_api", "dataset.video_frames": "job", "dataset.yolo_txt_sort": "job", "segmodel.train": "job", "segmodel.predict": "job", "yolo.heatmap": "job", "yolo.predict_custom": "job", "yolo.heatmap_custom": "job", "yolo.video_visible": "job", "mmseg.flops_fps": "job", "analysis.all": "job", "visual.fps": "job", "system.check_graph_card": "job", } def evaluate_project() -> dict: """Return product/implementation suggestions for the current web platform.""" frontend = settings.project_root / "frontend" / "src" / "main.tsx" backend = settings.project_root / "backend" / "app" / "main.py" jobs_backend = settings.project_root / "backend" / "app" / "jobs.py" readme = settings.project_root / "README.md" results_service = settings.project_root / "backend" / "app" / "modules" / "results" / "service.py" catalog = get_catalog() coverage = get_coverage_report() checks = [] suggestions = [] frontend_text = frontend.read_text(encoding="utf-8") if frontend.exists() else "" backend_text = backend.read_text(encoding="utf-8") if backend.exists() else "" jobs_text = jobs_backend.read_text(encoding="utf-8") if jobs_backend.exists() else "" acceptance_text = (settings.project_root / "backend" / "app" / "acceptance.py").read_text(encoding="utf-8") results_service_text = results_service.read_text(encoding="utf-8") if results_service.exists() else "" readme_text = readme.read_text(encoding="utf-8") if readme.exists() else "" expectations = { "left_nav_dataset": "数据集" in frontend_text and "#datasets" in frontend_text, "upload_ui": "uploadDatasetFiles" in frontend_text and "labels" in frontend_text and "masks" in frontend_text, "dataset_quality_ui": "DatasetQuality" in frontend_text and "generateSelectedYoloYaml" in frontend_text, "uploaded_yolo_workflow_ui": "startSelectedYoloTrain" in frontend_text and "startSelectedYoloPredict" in frontend_text and "startSelectedYoloHeatmap" in frontend_text, "dataset_yolo_outputs_ui": "DatasetYoloOutputs" in frontend_text and "selectedYoloOutputs" in frontend_text and "BEST.PT READY" in frontend_text and "datasetOutputCurve" in frontend_text and "MiniCurvePlot" in frontend_text, "loss_result_ui": "loss" in frontend_text.lower() and "heatmap" in frontend_text.lower() and "CurvePanel" in frontend_text, "result_browser_filter_ui": "ResultBrowser" in frontend_text and "resultFamilyFilter" in frontend_text and "resultRoleFilter" in frontend_text and "familyOptions" in frontend_text and "roleOptions" in frontend_text and "/api/results?limit=1000" in frontend_text and "setResults(resultsNext)" in frontend_text and "slice(0, 240)" not in frontend_text, "job_progress_ui": "JobProgressBar" in frontend_text and "progressTrack" in frontend_text, "job_diagnostics_ui": "JobDiagnostics" in frontend_text and "jobDiagnostics" in frontend_text and "command?.join" in frontend_text and "job.cwd" in frontend_text and "JSON.stringify(job.params" in frontend_text, "gpu_task_selection_ui": "selectedGpuIds" in frontend_text and "gpuSelector" in frontend_text and "jobPayload" in frontend_text and "selectedGpuDevice" in frontend_text and "gpu_count" in frontend_text and "gpus" in frontend_text and "CUDA_VISIBLE_DEVICES" in jobs_text, "conda_env_selection_ui": "/api/system/envs" in frontend_text and "selectedCondaEnv" in frontend_text and "runtimeSelector" in frontend_text and "conda_env" in frontend_text and "request.conda_env" in jobs_text, "weight_manifest_ui": "WeightPanel" in frontend_text and "/api/weights" in frontend_text and "/api/weights/verify" in frontend_text and "weightList" in frontend_text and "weightFamilies" in frontend_text, "live_log_stream_ui": "EventSource" in frontend_text and "eventSourceRef" in frontend_text and "log_size" in frontend_text and "events?offset=" in frontend_text, "live_log_offset_api": "log_size" in backend_text and "offset: int = Query(0, ge=0)" in backend_text, "runtime_readiness_ui": "runtimeReadiness" in frontend_text and "环境就绪" in frontend_text, "capability_matrix_ui": "capabilities" in frontend_text and "全功能矩阵" in frontend_text, "dataset_api": "/api/datasets" in backend_text and "api_upload_dataset_files" in backend_text, "dataset_quality_api": "/api/datasets/{dataset_name}/validate" in backend_text and "/api/datasets/{dataset_name}/yolo-yaml" in backend_text, "job_progress_api": "progress_from_log_path" in backend_text and '"progress"' in backend_text, "runtime_readiness_api": "/api/system/readiness" in backend_text, "capability_matrix_api": "/api/capabilities" in backend_text, "runtime_bootstrap_scripts": (settings.project_root / "scripts" / "bootstrap_conda_envs.sh").exists() and (settings.project_root / "scripts" / "verify_runtime_envs.py").exists(), "curve_api": "/api/results/curves" in backend_text, "deep_acceptance_api": "/api/acceptance/deep" in backend_text, "deep_acceptance_ui": "runDeepAcceptance" in frontend_text and "深度训练" in frontend_text, "deep_yolo_heatmap_validation": "yolo_tiny_heatmap_generation" in acceptance_text, "uploaded_yolo_workflow_acceptance": "uploaded_yolo_predict_job_runner" in acceptance_text and "uploaded_yolo_heatmap_job_runner" in acceptance_text, "real_workspace_acceptance": "/api/acceptance/real" in backend_text and "runRealAcceptance" in frontend_text and "真实数据" in frontend_text and "real_workspace_yolo_predict_job_runner" in acceptance_text and "real_workspace_yolo_heatmap_job_runner" in acceptance_text and "real_workspace_stack_job_runner" in acceptance_text, "real_train_acceptance": "/api/acceptance/real-train" in backend_text and "runRealTrainAcceptance" in frontend_text and "真实短训" in frontend_text and "real_train_yolo_one_epoch_job_runner" in acceptance_text and "real_train_trained_weight_predict_job_runner" in acceptance_text and "real_train_trained_weight_heatmap_job_runner" in acceptance_text, "real_train_artifact_links_ui": "AcceptanceArtifactLinks" in frontend_text and "acceptanceArtifacts" in frontend_text and "best_weight" in frontend_text and "results_csv" in frontend_text and "heatmap_outputs" in frontend_text, "single_epoch_curve_support": "if points:" in results_service_text and "scaled.length === 1" in frontend_text and "