Skip to content

Conversation

@nishika26
Copy link
Collaborator

@nishika26 nishika26 commented Aug 28, 2025

Summary

Target issue is #344

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

Database Migration and Model Schema Changes - app/models/model_evaluation.py

  • Dropped testing_file_id column from model_evaluation.

  • Added:

    • test_data_s3_url → S3 location for evaluation dataset .

    • prediction_data_s3_url → S3 location for generated predictions.

    • THIS IS AN EXAMPLE OF WHAT THE DATA INSIDE THE PREDICTION DATA S3 URL WOULD BE - local_copy_6.csv

  • ModelEvaluation updated to reflect new S3-based fields.

  • ModelEvaluationUpdate and ModelEvaluationPublic extended with prediction_data_s3_url.

Model Evaluator Enhancements - app/core/finetune/evaluation.py

  • ModelEvaluator now:

    • Loads test data CSVs from S3 instead of OpenAI NDJSON files.

    • Extracts prompts and labels directly from CSV (query|question|message + label).

    • Saves predictions to a CSV, uploads them to S3, and records the resulting URL.

    • Computes evaluation metrics (currently MCC score) based on streamed CSV data from S3.

API & CRUD Adjustments - app/api/routes/model_evaluation.py & app/crud/model_evaluation.py

  • API routes now pass test_data_s3_url instead of testing_file_id.

  • Evaluation run stores both:

    • score (evaluation metrics).

    • prediction_data_s3_url (uploaded predictions CSV).

Data Preprocessor Updates - app/core/finetune/preprocessing.py

  • upload_csv_to_s3 refactored into a @staticmethod for reusability in the ModelEvaluator class.
  • Because upload_csv_to_s3 is now a @staticmethod, it can’t access self.storage anymore. Instead, we pass the storage object in as a parameter, making its dependencies clear

Tests - app/tests/utils/test_data.py & app/tests/crud/test_model_evaluation.py

  • Updated unit tests and fixtures to use test_data_s3_url instead of testing_file_id.

  • Ensured CRUD and utils tests cover the new fields.

@coderabbitai
Copy link

coderabbitai bot commented Aug 28, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbit review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enhancement/eval_s3_data

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nishika26 nishika26 self-assigned this Aug 28, 2025
@nishika26 nishika26 added the enhancement New feature or request label Aug 28, 2025
@nishika26 nishika26 linked an issue Aug 28, 2025 that may be closed by this pull request
@nishika26 nishika26 changed the title Enhancement/eval s3 data Classification : retaining prediction and fetching data from s3 Aug 28, 2025
@nishika26 nishika26 marked this pull request as ready for review August 28, 2025 13:44
@nishika26 nishika26 changed the title Classification : retaining prediction and fetching data from s3 Classification : retaining prediction and fetching data from s3 for model evaluation Aug 28, 2025
Comment on lines +25 to +31
"test_data_s3_url", sqlmodel.sql.sqltypes.AutoString(), nullable=False
),
)
op.add_column(
"model_evaluation",
sa.Column(
"prediction_data_s3_url", sqlmodel.sql.sqltypes.AutoString(), nullable=True
Copy link
Collaborator

Choose a reason for hiding this comment

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

keep this consistent with other migrations, somewhere i saw it was just data_url and here it is data_s3_url

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I have turned all the "data_url" to "data_s3_url" , and I have made sure that this is consistent

client = get_openai_client(
session, current_user.organization_id, current_user.project_id
)
) # keeping this here for checking if the user's validated OpenAI key is present or not,
Copy link
Collaborator

Choose a reason for hiding this comment

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

didn't understand this part

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The client that actually carries out the OpenAI functions will be initialized inside the background task. The client being created in the router isn’t passed to the background task, because it’s generally not a good practice to pass objects into background tasks, and can cause same error as when passing router session to bg task. However, we still want to validate upfront that the user invoking this endpoint has a valid OpenAI key stored in our database. If we leave that check only to the background task, the user wouldn’t immediately know if their key is invalid or not present. That’s why the client is initialized in the router for validation purposes, while the actual client used to perform operations is re-initialized inside the background task.

@nishika26 nishika26 merged commit bcbaf20 into feature/classification Aug 29, 2025
1 check passed
@nishika26 nishika26 deleted the enhancement/eval_s3_data branch August 29, 2025 06:16
AkhileshNegi pushed a commit that referenced this pull request Sep 4, 2025
* Classification: db models and migration script (#305)

* db models and migration script

* Classification: Fine tuning Initiation and retrieve endpoint (#315)

* Fine-tuning core, initiation, and retrieval

* seperate session for bg task, and formating fixes

* fixing alembic revision

* Classification : Model evaluation of fine tuned models (#326)

* Model evaluation of fine tuned models

* fixing alembic revision

* alembic revision fix

* Classification : train and test data to s3 (#343)

* alembic file for adding and removing columns

* train and test s3 url column

* updating alembic revision

* formatting fix

* Classification : retaining prediction and fetching data from s3 for model evaluation (#359)

* adding new columns to model eval table

* test data and prediction data s3 url changes

* single migration file

* status enum columns

* document seeding

* Classification : small fixes and storage related changes (#365)

* first commit covering all

* changing model name to fine tuned model in model eval

* error handling in get cloud storage and document not found error handling

* fixing alembic revision

* uv lock

* new uv lock file

* updated uv lock file

* coderabbit suggestions and removing unused imports

* changes in uv lock file

* making csv a supported file format, changing uv lock and pyproject toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Classification : need to retain pedictions generated

2 participants