Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add object #26

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

feat: add object #26

wants to merge 7 commits into from

Conversation

psankhe28
Copy link
Collaborator

@psankhe28 psankhe28 commented Oct 25, 2024

Description

  • Fixes #(issue number)

Checklist

  • My code follows the contributing guidelines
    of this project, including, in particular, with regard to any style guidelines
  • The title of my PR complies with the
    Conventional Commits specification; in particular, it clearly
    indicates that a change is a breaking change
  • I acknowledge that all my commits will be squashed into a single commit,
    using the PR title as the commit message
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have updated the user-facing documentation to describe any new or
    changed behavior
  • I have added type annotations for all function/class/method interfaces
    or updated existing ones (only for Python, TypeScript, etc.)
  • I have provided appropriate documentation
    (Google-style Python docstrings) for all
    packages/modules/functions/classes/methods or updated existing ones
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature
    works
  • New and existing unit tests pass locally with my changes
  • I have not reduced the existing code coverage

Comments

Summary by Sourcery

Add a new endpoint for object uploads using the TUS protocol, enabling chunked file uploads to cloud storage. Update API specifications to document the new endpoint and its functionality.

New Features:

  • Introduce a new endpoint for uploading objects to cloud storage using the TUS protocol, allowing for chunked file uploads.

Enhancements:

  • Add functionality to handle file uploads by processing files into chunks and uploading them to a specified storage bucket.

Documentation:

  • Update API specifications to include the new object upload endpoint and its request/response details.

Copy link
Contributor

sourcery-ai bot commented Oct 25, 2024

Reviewer's Guide by Sourcery

This PR implements a new file upload functionality using MinIO as the cloud storage backend. The implementation includes chunked file processing and handles multiple file uploads. The API is documented using OpenAPI specifications.

Sequence diagram for the new file upload process

sequenceDiagram
    actor User
    participant Client as Flask Client
    participant MinIO as MinIO Storage

    User->>Client: Upload file(s)
    Client->>Client: Generate file_id and save file
    loop for each chunk
        Client->>Client: Read chunk
        Client->>MinIO: Upload chunk
        MinIO-->>Client: Acknowledge upload
    end
    Client->>User: Return success response
Loading

File-Level Changes

Change Details Files
Implement file upload endpoint with chunked processing
  • Add upload_object function to handle file uploads
  • Implement chunked file processing with 5MB chunk size
  • Add MinIO client integration for S3-compatible storage
  • Include UUID-based file identification
  • Implement temporary file handling with cleanup
  • Add error handling for S3 operations
cloud_storage_handler/api/elixircloud/csh/controllers.py
Add OpenAPI specification for the upload endpoint
  • Define POST /object endpoint specification
  • Add multipart/form-data request body schema
  • Document response codes and headers
  • Include TUS protocol headers in the specification
cloud_storage_handler/api/specs/specs.yaml

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

@psankhe28 psankhe28 marked this pull request as draft October 25, 2024 20:50
Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (0b08ba9) to head (b826ac3).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #26   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines           30        45   +15     
=========================================
+ Hits            30        45   +15     
Flag Coverage Δ
test_integration 100.00% <100.00%> (ø)
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @psankhe28 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The implementation doesn't match the API specification - the spec describes using the TUS protocol for uploads but the code implements basic multipart upload instead. Please implement proper TUS protocol support or update the API spec accordingly.
  • Security concern: Writing temporary files to /tmp without size limits is dangerous. Consider using stream processing or implementing proper size limits and cleanup on error paths.
  • Several checklist items are incomplete: missing tests, documentation, and type annotations. Please add these before the PR can be merged.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟡 Security: 1 issue found
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

cloud_storage_handler/api/elixircloud/csh/controllers.py Outdated Show resolved Hide resolved
cloud_storage_handler/api/elixircloud/csh/controllers.py Outdated Show resolved Hide resolved
"description": "Chunk upload via Flask",
},
)
except S3Error as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Add proper cleanup in error cases and improve error handling

Temporary files aren't cleaned up if an error occurs. Consider using a try/finally block and return a sanitized error response instead of exposing raw S3Error messages.

Signed-off-by: Pratiksha Sankhe <[email protected]>
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.

1 participant