Skip to content

Conversation

@nishika26
Copy link
Collaborator

@nishika26 nishika26 commented Jul 31, 2025

Summary

Target issue is #301

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

This PR introduces a complete flow to create and manage OpenAI fine-tuning jobs:

  • API to create jobs (one per split_ratio), refresh status from OpenAI, and list jobs by document.

  • CRUD with idempotency checks to prevent duplicate jobs for the same (document_id, base_model, split_ratio, project).

  • Preprocessing that converts a CSV (via object storage) into OpenAI chat-format JSONL (train/test), with stratified splits and temp-file cleanup.

  • Background processing so heavy steps (preprocess, upload, job creation) don’t block the request thread.

  • Seeded document table to be able to use in testing, added a "fetch doc object from db" function in test utils

@coderabbitai
Copy link

coderabbitai bot commented Jul 31, 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 @coderabbitai 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 feature/fine_tuning_endpoint

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.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai 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:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai 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 comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @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

Documentation and Community

  • 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 linked an issue Jul 31, 2025 that may be closed by this pull request
@nishika26 nishika26 self-assigned this Jul 31, 2025
@nishika26 nishika26 added the enhancement New feature or request label Jul 31, 2025
@nishika26 nishika26 changed the title Feature/fine tuning endpoint classification: Fine tuning Initiation and retrive endpoint Aug 1, 2025
@nishika26 nishika26 changed the title classification: Fine tuning Initiation and retrive endpoint Classification: Fine tuning Initiation and retrive endpoint Aug 1, 2025
@nishika26 nishika26 marked this pull request as ready for review August 4, 2025 04:02
Base automatically changed from feature/db_model to feature/classification August 5, 2025 12:56
@nishika26 nishika26 changed the title Classification: Fine tuning Initiation and retrive endpoint Classification: Fine tuning Initiation and retrieve endpoint Aug 6, 2025
@nishika26 nishika26 force-pushed the feature/fine_tuning_endpoint branch from b1a4479 to 04c7269 Compare August 6, 2025 06:38
Copy link
Collaborator

@kartpop kartpop left a comment

Choose a reason for hiding this comment

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

approving this with the assumption that the comments will be resolved

error_msg = handle_openai_error(e)
logger.error(
f"[Retrieve_fine_tune_status] Failed to retrieve OpenAI job | "
f"provider_job_id={mask_string(job.provider_job_id)}, "
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure why we should mask the provider_job_id; maybe it is required and I don't have full context

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just a security measure we take with all such IDs like this such as thread id, assistant id, response id, etc. we dont want such things to get exposed in logs, while this does not pose any immediate threat but we want this mask to avoid risk of expose

@nishika26 nishika26 merged commit d6e8964 into feature/classification Aug 8, 2025
1 check passed
@nishika26 nishika26 deleted the feature/fine_tuning_endpoint branch August 8, 2025 07:11
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: Implement Fine-Tuning Initiation Endpoint

3 participants