fix: evaluation. (#35729)

Co-authored-by: jyong <718720800@qq.com>
Co-authored-by: Yansong Zhang <916125788@qq.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: hj24 <mambahj24@gmail.com>
Co-authored-by: hj24 <huangjian@dify.ai>
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
Co-authored-by: CodingOnStar <hanxujiang@dify.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
FFXN 2026-04-30 15:45:54 +08:00 committed by GitHub
parent b21b7344bd
commit 35f3d63d4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View File

@ -495,7 +495,13 @@ class EvaluationService:
_persist_results(session, evaluation_run.id, results, items)
result_xlsx = _generate_result_xlsx(items, results)
result_file_id = _store_result_file(tenant_id, evaluation_run.id, result_xlsx, session)
result_file_id = _store_result_file(
tenant_id,
evaluation_run.id,
result_xlsx,
session,
created_by=account_id,
)
if result_file_id:
evaluation_run.result_file_id = result_file_id
session.commit()

View File

@ -123,7 +123,13 @@ def _execute_evaluation(session: Any, run_data: EvaluationRunData) -> None:
result_xlsx = _generate_result_xlsx(run_data.input_list, results)
# Store result file
result_file_id = _store_result_file(run_data.tenant_id, run_data.evaluation_run_id, result_xlsx, session)
result_file_id = _store_result_file(
run_data.tenant_id,
run_data.evaluation_run_id,
result_xlsx,
session,
created_by=evaluation_run.created_by,
)
# Update run to completed
evaluation_run = session.query(EvaluationRun).filter_by(id=run_data.evaluation_run_id).first()
@ -509,6 +515,7 @@ def _store_result_file(
run_id: str,
xlsx_content: bytes,
session: Any,
created_by: str,
) -> str | None:
"""Store result XLSX file and return the UploadFile ID."""
try:
@ -529,7 +536,7 @@ def _store_result_file(
extension="xlsx",
mime_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
created_by_role=CreatorUserRole.ACCOUNT,
created_by="system",
created_by=created_by,
created_at=naive_utc_now(),
used=False,
)
@ -537,5 +544,6 @@ def _store_result_file(
session.commit()
return upload_file.id
except Exception:
session.rollback()
logger.exception("Failed to store result file for run %s", run_id)
return None