Skip to content

chore(evaluation): Remove Unused Evaluation v1 endpoints - #1430

Open
Ayush8923 wants to merge 1 commit into
chore/remove-fine-tuningfrom
chore/remove-v1-eval-writes
Open

Ayush8923 wants to merge 1 commit into
chore/remove-fine-tuningfrom
chore/remove-v1-eval-writes

Conversation

@Ayush8923

@Ayush8923 Ayush8923 commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Closes #1382

What Changed

  • Removed the v1 evaluation write routes: POST /api/v1/evaluations, POST /api/v1/evaluations/datasets and POST /api/v1/evaluations/{id}/improve-prompt. The v1 GET/DELETE routes stay; all writes now go through /api/v2.
  • Removed the text batch pipeline:
    • crud/evaluations/batch.py and processing.py
    • the embedding-batch helpers in embeddings.py
    • the run_evaluation_batch_submission Celery task and start_evaluation_batch_submission
    • validate_and_start_batch_evaluation
    • Cron no longer polls text batch runs; it polls STT/TTS only.
  • upload_dataset: removed use_langfuse. The Langfuse upload is gone, and the S3 upload changed from best-effort to mandatory (500 on failure).
  • create_evaluation_run default run_mode: BATCH → FAST.
  • fetch_dataset_items moved from batch.py to langfuse.py, so legacy Langfuse-backed datasets can still run on v2.
  • Tests and docs:
    • v1 dataset-upload tests were ported to the v2 route.
    • Fast-route tests now hit /api/v2/evaluations.
    • Batch, processing and embedding-batch tests were deleted.
    • The wiki and architecture docs note the removal.

Summary

Route surface:

 /api/v1/evaluations
-  POST   ""                          # create run (batch | fast)
   GET    ""
   GET    "/{id}"
-  POST   "/{id}/improve-prompt"
 /api/v1/evaluations/datasets
-  POST   ""                          # upload CSV → S3 + Langfuse
   GET    ""
   GET    "/{id}"
   DELETE "/{id}"
 /api/v2/evaluations                  # now the only write surface
   POST   ""
   POST   "/datasets"
   POST   "/{id}/improve-prompt"
   POST   "/iterations"

Cron call tree:

 process_all_pending_evaluations
-  poll_all_pending_evaluations      # text batch runs
-    check_and_process_evaluation
-      process_completed_evaluation
-      process_completed_embedding_batch
   poll_all_pending_stt_evaluations
   poll_all_pending_tts_evaluations

Dataset upload:

 upload_dataset
   sanitize name → parse CSV
-  upload to S3 (best-effort when use_langfuse)
-  if use_langfuse: upload_dataset_to_langfuse
+  upload to S3 (mandatory, 500 on failure)
   create_evaluation_dataset(langfuse_dataset_id=None)

Evidence

  • Before: TestV1TriggerUnchanged.test_v1_fast_run_is_not_a_judge_run expected the v1 write route to work:
    POST /api/v1/evaluations {..., run_mode: "fast"} → 200, is_judge_run == false
    
    After: TestV1WriteRoutesRemoved (in test_evaluation_v2.py) expects:
    POST /api/v1/evaluations            → 405
    POST /api/v1/evaluations/datasets   → 405
    POST /api/v1/evaluations/1/improve-prompt → 404
    
  • Before: v1 dataset-upload coverage hit /api/v1/evaluations/datasets. It covered description persisted, empty rows skipped, and missing columns returning 422.
    After: the same cases run against /api/v2/evaluations/datasets in test_evaluation_dataset_v2.py. test_object_store_exception_raises_500 was added for the now-mandatory S3 upload.
  • TestFetchDatasetItems was added to test_langfuse.py for the relocated legacy-dataset reader.
  • Manually ran the app locally (see checklist).

Merge Danger

Door: two-way

This is a pure code removal with no migrations and no schema changes. Reverting the PR restores everything.

There is one soft edge. Any text run still in run_mode=batch / status=processing at deploy time will no longer be polled and will stay processing. Historical batch rows remain readable.

Blast Radius: Medium

  • Any client still calling the removed v1 POST routes gets 405/404. The frontend and integrations must already be on /api/v2.
  • Celery messages for run_evaluation_batch_submission that are queued at deploy time will fail as an unregistered task.
  • Dataset uploads now fail hard (500) if S3 is unavailable, instead of falling back to Langfuse.
  • Existing Langfuse-backed datasets can still be run, but no new ones can be created.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Previous PR description

Issue

Closes #1382

Summary

  • Removed the evaluation v1 related endpoints which is not used anymore.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Remove POST /api/v1/evaluations, POST /api/v1/evaluations/datasets and
POST /api/v1/evaluations/{id}/improve-prompt in favour of their v2
equivalents. The v1 GET/DELETE reads stay because v2 has no read
endpoints yet.

With the v1 create gone, the OpenAI/Gemini batch pipeline for text
evals (crud/evaluations/batch.py, processing.py, the
run_evaluation_batch_submission task and its cron polling) and the
embedding batch go too; only the cosine helpers used to read historical
runs remain. Dataset upload always stores the CSV in object storage.
Tests move to the v2 endpoints.
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between abfe7b2 and 5f0041a.

Files selected for processing: 45

  • .claude/conventions/celery.md
  • backend/app/api/docs/evaluation/create_evaluation.md
  • backend/app/api/docs/evaluation/examples.py
  • backend/app/api/docs/evaluation/improve_prompt.md
  • backend/app/api/docs/evaluation/list_datasets.md
  • backend/app/api/docs/evaluation/upload_dataset.md
  • backend/app/api/docs/evaluation/v2/create_evaluation.md
  • backend/app/api/docs/evaluation/v2/create_evaluation_dataset.md
  • backend/app/api/docs/evaluation/v2/improve_prompt.md
  • backend/app/api/routes/evaluations/dataset.py
  • backend/app/api/routes/evaluations/evaluation.py
  • backend/app/api/routes/evaluations/v2/dataset.py
  • backend/app/api/routes/evaluations/v2/evaluation.py
  • backend/app/api/routes/evaluations/v2/prompt_improvement.py
  • backend/app/celery/tasks/job_execution.py
  • backend/app/celery/utils.py
  • backend/app/crud/evaluations/__init__.py
  • backend/app/crud/evaluations/batch.py
  • backend/app/crud/evaluations/cron.py
  • backend/app/crud/evaluations/embeddings.py
  • backend/app/crud/evaluations/langfuse.py
  • backend/app/crud/evaluations/processing.py
  • backend/app/crud/evaluations/score.py
  • backend/app/services/evaluations/__init__.py
  • backend/app/services/evaluations/batch_job.py
  • backend/app/services/evaluations/dataset.py
  • backend/app/services/evaluations/evaluation.py
  • backend/app/services/evaluations/fast.py
  • backend/app/tests/api/routes/test_evaluation.py
  • backend/app/tests/api/routes/test_evaluation_dataset_v2.py
  • backend/app/tests/api/routes/test_evaluation_fast.py
  • backend/app/tests/api/routes/test_evaluation_v2.py
  • backend/app/tests/api/routes/test_improve_prompt.py
  • backend/app/tests/api/routes/test_improve_prompt_v2.py
  • backend/app/tests/api/test_auth_failures.py
  • backend/app/tests/celery/test_job_execution.py
  • backend/app/tests/celery/test_utils.py
  • backend/app/tests/core/test_rate_limit.py
  • backend/app/tests/crud/evaluations/test_embeddings.py
  • backend/app/tests/crud/evaluations/test_langfuse.py
  • backend/app/tests/crud/evaluations/test_processing.py
  • backend/app/tests/services/evaluations/test_dataset_v2.py
  • backend/app/tests/services/evaluations/test_evaluation_service_s3.py
  • docs/architecture/kaapi-evaluations-ARCHITECTURE.md
  • docs/wiki/modules/evaluations.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot changed the title chore(evaluations): Remove the v1 text evaluation write endpoints chore(evaluation): Remove v1 write endpoints Dec 4, 2026
@Ayush8923
Ayush8923 added this pull request to stack #1432 December 4, 2026 17:34
@Ayush8923
Ayush8923 marked this pull request as ready for review December 4, 2026 17:35

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beyond the inline finding, I searched the backend for leftover references to the removed crud/evaluations/processing.py and batch.py modules and to start_evaluation_batch_submission/run_evaluation_batch_submission. None remain, so the deletions shouldn't cause an import error at startup.

Extended reasoning...

The PR removes about 6.8k lines of v1 text-evaluation write endpoints and the OpenAI/Gemini batch pipeline. A grep found no remaining callers of the deleted modules or Celery task; the STT/TTS cron paths now use their own helpers.

Comment on lines 169 to +177
session=session
)

total_processed = (
text_summary["processed"]
+ stt_summary["processed"]
+ tts_summary["processed"]
)
total_failed = (
text_summary["failed"] + stt_summary["failed"] + tts_summary["failed"]
)
total_processed = stt_summary["processed"] + tts_summary["processed"]
total_failed = stt_summary["failed"] + tts_summary["failed"]
total_still_processing = (
text_summary["still_processing"]
+ stt_summary["still_processing"]
+ tts_summary["still_processing"]
)
all_details = (
text_summary.get("details", [])
+ stt_summary.get("details", [])
+ tts_summary.get("details", [])
stt_summary["still_processing"] + tts_summary["still_processing"]
)
all_details = stt_summary.get("details", []) + tts_summary.get("details", [])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Text batch evaluation runs still in flight at deploy time stay stuck in processing or pending forever. Nothing polls them, fails them or completes them after this change. The cron no longer calls poll_all_pending_evaluations, and no migration or sweep closes the open run_mode='batch' runs. Queued run_evaluation_batch_submission messages are now unregistered Celery tasks, so workers drop them. Fix: close every open batch run on deploy. For example, add a data migration or a one-off cron step that marks type='text', run_mode='batch' runs in pending/processing as failed with an explanatory error_message. [also at: backend/app/crud/evaluations/cron.py:166 - Text batch evaluation runs still in flight at deploy will stay pending/processing forever, and their OpenAI batch results are never collected.]

Why this was flagged

The trigger is any text run created through the removed POST /api/v1/evaluations with run_mode=batch that has not finished when this deploys. That covers runs waiting on an OpenAI/Gemini response or embedding batch, and Celery messages for run_evaluation_batch_submission still in the queue. On the base branch, process_all_pending_evaluations (cron.py:159) called poll_all_pending_evaluations, which finished or failed these runs. After the change, only STT/TTS runs are polled. dispatch_fast_evaluation_barriers (cron.py:41-45) filters on run_mode == RunModeEnum.FAST.value, so it skips batch runs. The Celery task was deleted from job_execution.py, so a redelivered or queued message hits an unregistered task and is discarded. The EvaluationRun row never leaves pending/processing. GET /api/v1/evaluations/{id} keeps reporting it as in progress, and the provider batch cost is lost. The diff adds no migration or sweep for these rows.

Verification: On the base commit, process_all_pending_evaluations started with text_summary = await poll_all_pending_evaluations(session=session). The diff deletes that call and the import from cron.py, so cron now polls only STT and TTS. The only other sweep left in cron.py (lines 42-44) filters on run_mode == RunModeEnum.FAST.value, so batch runs are never picked up.

@Ayush8923 Ayush8923 self-assigned this Dec 4, 2026
@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.62921% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/app/crud/evaluations/cron.py 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Ayush8923 Ayush8923 changed the title chore(evaluation): Remove v1 write endpoints chore(evaluation): Remove Unused Evaluation v1 endpoints Dec 4, 2026
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

OpenAPI changes   🔴 21 breaking changes

Caution

Downstream consumers may need an update before merging.

Breaking changes  ·  21
Method Path Change
🔴 GET /api/v1/documents/transformation API path removed without deprecation
🔴 GET /api/v1/documents/transformation/{job_id} API path removed without deprecation
🔴 POST /api/v1/evaluations API removed without deprecation
🔴 POST /api/v1/evaluations/datasets API removed without deprecation
🔴 POST /api/v1/evaluations/{evaluation_id}/improve-prompt API path removed without deprecation
🔴 POST /api/v1/fine_tuning/fine_tune API path removed without deprecation
🔴 GET /api/v1/fine_tuning/{document_id} API path removed without deprecation
🔴 GET /api/v1/fine_tuning/{fine_tuning_id}/refresh API path removed without deprecation
🔴 POST /api/v1/model_evaluation/evaluate_models API path removed without deprecation
🔴 GET /api/v1/model_evaluation/{document_id} API path removed without deprecation
🔴 GET /api/v1/model_evaluation/{document_id}/top_model API path removed without deprecation
🔴 GET /api/v1/openai-conversation API path removed without deprecation
🔴 GET /api/v1/openai-conversation/ancestor/{ancestor_response_id} API path removed without deprecation
🔴 GET /api/v1/openai-conversation/response/{response_id} API path removed without deprecation
🔴 DELETE /api/v1/openai-conversation/{conversation_id} API path removed without deprecation
🔴 GET /api/v1/openai-conversation/{conversation_id} API path removed without deprecation
🔴 POST /api/v1/responses API path removed without deprecation
🔴 POST /api/v1/responses/sync API path removed without deprecation
🔴 POST /api/v1/documents removed the request property callback_url
🔴 POST /api/v1/documents removed the request property target_format
🔴 POST /api/v1/documents removed the request property transformer
Full changelog  ·  50
Method Path Change
🔴 GET /api/v1/documents/transformation API path removed without deprecation
🔴 GET /api/v1/documents/transformation/{job_id} API path removed without deprecation
🔴 POST /api/v1/evaluations API removed without deprecation
🔴 POST /api/v1/evaluations/datasets API removed without deprecation
🔴 POST /api/v1/evaluations/{evaluation_id}/improve-prompt API path removed without deprecation
🔴 POST /api/v1/fine_tuning/fine_tune API path removed without deprecation
🔴 GET /api/v1/fine_tuning/{document_id} API path removed without deprecation
🔴 GET /api/v1/fine_tuning/{fine_tuning_id}/refresh API path removed without deprecation
🔴 POST /api/v1/model_evaluation/evaluate_models API path removed without deprecation
🔴 GET /api/v1/model_evaluation/{document_id} API path removed without deprecation
🔴 GET /api/v1/model_evaluation/{document_id}/top_model API path removed without deprecation
🔴 GET /api/v1/openai-conversation API path removed without deprecation
🔴 GET /api/v1/openai-conversation/ancestor/{ancestor_response_id} API path removed without deprecation
🔴 GET /api/v1/openai-conversation/response/{response_id} API path removed without deprecation
🔴 DELETE /api/v1/openai-conversation/{conversation_id} API path removed without deprecation
🔴 GET /api/v1/openai-conversation/{conversation_id} API path removed without deprecation
🔴 POST /api/v1/responses API path removed without deprecation
🔴 POST /api/v1/responses/sync API path removed without deprecation
🔴 POST /api/v1/documents removed the request property callback_url
🔴 POST /api/v1/documents removed the request property target_format
🔴 POST /api/v1/documents removed the request property transformer
🟢 — — removed the schema APIResponse_CallbackResponse_
🟢 — — removed the schema APIResponse_DocTransformationJobPublic_-Input
🟢 — — removed the schema APIResponse_DocTransformationJobPublic_-Output
🟢 — — removed the schema APIResponse_DocTransformationJobsPublic_
🟢 — — removed the schema APIResponse_FineTuningJobPublic_
🟢 — — removed the schema APIResponse_ModelEvaluationPublic_
🟢 — — removed the schema APIResponse_OpenAIConversationPublic_
🟢 — — removed the schema APIResponse_ResponseJobStatus_
🟢 — — removed the schema APIResponse_list_FineTuningJobPublic__
🟢 — — removed the schema APIResponse_list_ModelEvaluationPublic__
🟢 — — removed the schema APIResponse_list_OpenAIConversationPublic__
🟢 — — removed the schema Body_Evaluation-evaluate
🟢 — — removed the schema Body_Evaluation-upload_dataset
🟢 — — removed the schema Body_Fine_Tuning-fine_tune_from_CSV
🟢 — — removed the schema CallbackResponse
🟢 — — removed the schema Diagnostics
🟢 — — removed the schema DocTransformationJobPublic
🟢 — — removed the schema DocTransformationJobsPublic
🟢 — — removed the schema FineTuningJobPublic
🟢 — — removed the schema ModelEvaluationCreate
🟢 — — removed the schema ModelEvaluationPublic
🟢 — — removed the schema ModelEvaluationStatus
🟢 — — removed the schema OpenAIConversationPublic
🟢 — — removed the schema ResponseJobStatus
🟢 — — removed the schema ResponsesAPIRequest
🟢 — — removed the schema ResponsesSyncAPIRequest
🟢 — — removed the schema TransformationJobInfo
🟢 — — removed the schema TransformationStatus
🟢 POST /api/v1/documents removed the optional property data/anyOf[subschema #1: DocumentUploadResponse]/transformation_job from the response with the 200 status

main ↔ eb7fc62d · generated by oasdiff

@Ayush8923 Ayush8923 added the breaking-change-approved Reviewer-acknowledged API breaking change label Dec 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change-approved Reviewer-acknowledged API breaking change ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup: Remove unused backend modules

1 participant