Skip to content

Conversation

@PGijsbers
Copy link
Contributor

@PGijsbers PGijsbers commented Jun 17, 2025

Summary by Sourcery

Introduce a dataset upload endpoint with parquet validation, refactor the OpenML dataset metadata into separate request and view models with additional fields, update the GET handler to return the new view model, and update tests and dependencies accordingly

New Features:

  • Add POST /datasets endpoint for authenticated users to upload parquet dataset files

Enhancements:

  • Split DatasetMetadata into request and view models, moving id, visibility, and status into DatasetMetadataView
  • Extend metadata schema with fields for description, collection date, default target/ignore/row-id attributes, file format, and original data URLs
  • Update GET /datasets/{id} to return DatasetMetadataView

Build:

  • Add python-multipart dependency to support file uploads

Tests:

  • Update existing dataset tests to expect DatasetMetadataView and fix import paths
  • Add tests for upload endpoint authentication and parquet file validation

Chores:

  • Adjust convertor and migration test imports to use the new DatasetMetadataView

@coderabbitai
Copy link

coderabbitai bot commented Jun 17, 2025

Important

Review skipped

Draft detected.

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.


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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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.

@sourcery-ai
Copy link

sourcery-ai bot commented Jun 17, 2025

Reviewer's Guide

This PR reorganizes dataset metadata schemas by introducing optional fields and a dedicated view model, implements a new upload endpoint with authentication and parquet validation, updates retrieval and conversion logic to use the new view, adjusts tests accordingly, and adds the multipart dependency.

Sequence diagram for the new dataset upload endpoint with authentication and file validation

sequenceDiagram
    actor User
    participant API as /datasets (upload_data)
    participant Auth as fetch_user
    User->>API: POST /datasets (file, metadata)
    API->>Auth: fetch_user
    Auth-->>API: User or None
    alt User is None
        API-->>User: 401 Unauthorized
    else User is authenticated
        API->>API: Check file extension == .pq
        alt Not .pq
            API-->>User: 400 Bad Request
        else Valid parquet file
            API->>API: (TODO: async file handling)
            API-->>User: 200 OK (or success response)
        end
    end
Loading

Class diagram for updated DatasetMetadata and new DatasetMetadataView

classDiagram
    class DatasetMetadata {
        +str name
        +str licence
        +int version
        +str|None version_label
        +str|None language
        +list~str~ creators
        +list~str~ contributors
        +str|None citation
        +HttpUrl|None paper_url
        +str|None collection_date
        +str description
        +list~str~ default_target_attribute
        +list~str~ ignore_attribute
        +list~str~ row_id_attribute
        +DatasetFileFormat format_
        +list~HttpUrl~|None original_data_url
    }
    class DatasetMetadataView {
        +int id_
        +Visibility visibility
        +DatasetStatus status
        +int description_version
        +list~str~ tags
        +datetime upload_date
        +str|None processing_error
        +str|None processing_warning
        +int file_id
        +HttpUrl url
        +HttpUrl|None parquet_url
        +str md5_checksum
    }
    DatasetMetadataView --|> DatasetMetadata
Loading

Class diagram for updated openml_dataset_to_dcat conversion

classDiagram
    class openml_dataset_to_dcat {
        +DcatApWrapper openml_dataset_to_dcat(DatasetMetadataView metadata)
    }
Loading

File-Level Changes

Change Details Files
Expanded and restructured dataset metadata schema
  • Made version_label and citation fields optional and added max_length constraints
  • Added new metadata fields: collection_date, description, default_target_attribute, ignore_attribute, row_id_attribute, format_, original_data_url
  • Introduced DatasetMetadataView subclass with id_, visibility, status, description_version, and tags
  • Removed duplicated fields from view and relocated file_id and url definitions
src/schemas/datasets/openml.py
Added upload_data endpoint and switched retrieval to view model
  • Imported and used DatasetMetadataView in router module
  • Implemented POST /datasets endpoint with authentication and .pq file extension checks
  • Updated get_dataset to return DatasetMetadataView instead of base model
src/routers/openml/datasets.py
Updated tests for new view and upload behavior
  • Changed type assertions to DatasetMetadataView in dataset tests
  • Added tests for upload_data authentication failure and invalid file extension
  • Fixed import path in migration tests
tests/routers/openml/datasets_test.py
tests/routers/openml/migration/datasets_migration_test.py
Adjusted converter function to accept DatasetMetadataView
  • Updated import and function signature in openml_dataset_to_dcat
src/schemas/datasets/convertor.py
Added dependency for file uploads
  • Added python-multipart to project dependencies
pyproject.toml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov
Copy link

codecov bot commented Jun 17, 2025

Codecov Report

Attention: Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (main@c2459a4). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...outers/openml/migration/datasets_migration_test.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #209   +/-   ##
=======================================
  Coverage        ?   77.74%           
=======================================
  Files           ?       51           
  Lines           ?     1865           
  Branches        ?      146           
=======================================
  Hits            ?     1450           
  Misses          ?      379           
  Partials        ?       36           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants