-
Notifications
You must be signed in to change notification settings - Fork 2
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: upload drs object endpoint #27
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Pratiksha Sankhe <[email protected]>
Reviewer's Guide by SourceryThis PR implements a new endpoint for uploading DRS objects using the TUS (Tus Upload Server) protocol, which enables resumable file uploads. The implementation includes a three-step process: upload initiation, chunk-based file upload, and upload completion with MinIO storage integration. The system also includes duplicate file detection using MD5 hashing. Sequence diagram for DRS object upload processsequenceDiagram
actor User
participant FlaskApp as Flask Application
participant MinIO as MinIO Storage
User->>FlaskApp: POST /upload/initiate
FlaskApp-->>User: 201 Created (object_id)
loop Upload Chunks
User->>FlaskApp: PATCH /upload/{object_id}/chunk
FlaskApp-->>User: 204 No Content
end
User->>FlaskApp: POST /upload/complete/{object_id}
alt Duplicate Detected
FlaskApp-->>User: 409 Conflict (Duplicate object)
else
FlaskApp->>MinIO: Store object
MinIO-->>FlaskApp: Acknowledgement
FlaskApp-->>User: 200 OK (Upload complete)
end
Class diagram for updated Flask applicationclassDiagram
class FlaskApp {
+initiate_upload()
+upload_chunk(object_id)
+complete_upload(object_id)
+get_chunks(object, chunk_size)
+compute_file_hash(file_path)
}
class MinIOClient {
+list_objects(bucket_name)
+stat_object(bucket_name, object_name)
+fput_object(bucket_name, object_name, file_path, content_type)
}
FlaskApp --> MinIOClient : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Signed-off-by: Pratiksha Sankhe <[email protected]>
Signed-off-by: Pratiksha Sankhe <[email protected]>
Signed-off-by: Pratiksha Sankhe <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #27 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 30 30
=========================================
Hits 30 30
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's pretty cool :)
My major worry is that all chunks are stored on the Flask application. This potentially requires huge storage needs on the microservice (especially if multiple users upload at the same time). We need to find a way around this, maybe by copying the chunks to s3 and assembling there? That would be much better. Or even better: If you could upload the chunks directly to s3.
Here's what GenAI says about this: https://g.co/gemini/share/c57f76565274
But I do recognize that this would be quite a bit of extra work, so if you agree, for now, maybe let's move ahead with what we have right now. But if you think you can pull off one of the two approaches, please go ahead.
Either way, please add all the usual parts:
- Write proper Google-style docstrings with "Args" and "Returns" sections (and "Raises" where applicable)
- Add type hints for all function args and return values
- Provide unit tests
- Adopt a class-based approach; set state where it makes sense, e.g.,
TUS_UPLOAD_DIR
should be an attribute - Split up longer functions into smaller ones (particularly the
complete_upload()
one, but alsoupload_chunk()
is quite longish)
Signed-off-by: Pratiksha Sankhe <[email protected]>
Okay, I will make the necessary changes. |
Signed-off-by: Pratiksha Sankhe <[email protected]>
Signed-off-by: Pratiksha Sankhe <[email protected]>
Signed-off-by: Pratiksha Sankhe <[email protected]>
Signed-off-by: Pratiksha Sankhe <[email protected]>
Description
feat: add object #26
Checklist
of this project, including, in particular, with regard to any style guidelines
Conventional Commits specification; in particular, it clearly
indicates that a change is a breaking change
using the PR title as the commit message
changed behavior
or updated existing ones (only for Python, TypeScript, etc.)
(Google-style Python docstrings) for all
packages/modules/functions/classes/methods or updated existing ones
works
Comments
Summary by Sourcery
Add new endpoints for handling file uploads using the TUS protocol, including initiating uploads, uploading chunks, and completing uploads by storing files in MinIO. Enable CORS in the deployment configuration to support cross-origin requests.
New Features:
Enhancements:
Documentation: