-
Notifications
You must be signed in to change notification settings - Fork 20
Classification Workflow Step #668
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
base: dev
Are you sure you want to change the base?
Conversation
β¦es; update moduleResolution to bundler
β¦le handling - Added Uppy instance to the global App component for shared file upload functionality. - Implemented UppyImageUploader component to utilize Uppy for image uploads with AWS S3 integration. - Refactored file handling to extract EXIF data upon file addition and display upload progress. - Updated Vite configuration to target 'esnext' for improved compatibility
β¦inIO - Replaced MinIO client with boto3 for S3 operations in s3.py. - Updated methods for file upload, download, and presigned URL generation to align with boto3 API. - Adjusted error handling to use ClientError from botocore. - Modified user_schemas.py to generate presigned URLs using boto3. - Updated dependencies in pyproject.toml to include boto3 and remove MinIO. - Ensured compatibility with existing code by stripping leading slashes from S3 paths. - Added content type headers for multipart upload requests in the frontend UppyImageUploader component
β¦dability and maintainability
β¦w UI with upload, classification, review, and processing steps
β¦ance upload functionality - Replaced UppyImageUploader with UppyFileUploader for consistency across components. - Improved ImageUpload component to track upload progress and display upload queue. - Added support for staging uploads in UppyFileUploader. - Updated DroneImageProcessingWorkflow to adjust modal dimensions for better usability. - Removed unused UppyImageUploader component and its related code BREAKING CHANGE: Switch from minio to boto3
β¦ance upload functionality - Replaced UppyImageUploader with UppyFileUploader for consistency across components. - Improved ImageUpload component to track upload progress and display upload queue. - Added support for staging uploads in UppyFileUploader. - Updated DroneImageProcessingWorkflow to adjust modal dimensions for better usability. - Removed unused UppyImageUploader component and its related code
β¦d request in UppyFileUploader
for more information, see https://pre-commit.ci
β¦ table migration with conditional enum creation and improved index handling
β¦one-tm into feat/resumable-uploads
for more information, see https://pre-commit.ci
β¦epSwitcher component for project steps navigation
β¦l for managing project images with relationships and indexing
β¦se save function and EXIF handling
β¦ code formatting in image logic and migration files
β¦ with generate_presigned_download_url across the codebase; add new migration script for images from S3
β¦migration with conflict handling and improved logging
* feat: added multipart initate upload route * feat: added all multipart upload functions * feat(UploadBox): Swapped upload from single to multipart upload using uppy * feat(frontend): add @uppy/drag-drop and @uppy/progress-bar dependencies; update moduleResolution to bundler * feat(frontend): feat: integrate Uppy for image uploads and enhance file handling - Added Uppy instance to the global App component for shared file upload functionality. - Implemented UppyImageUploader component to utilize Uppy for image uploads with AWS S3 integration. - Refactored file handling to extract EXIF data upon file addition and display upload progress. - Updated Vite configuration to target 'esnext' for improved compatibility * feat(image-upload): Refactor S3 integration to use boto3 instead of MinIO - Replaced MinIO client with boto3 for S3 operations in s3.py. - Updated methods for file upload, download, and presigned URL generation to align with boto3 API. - Adjusted error handling to use ClientError from botocore. - Modified user_schemas.py to generate presigned URLs using boto3. - Updated dependencies in pyproject.toml to include boto3 and remove MinIO. - Ensured compatibility with existing code by stripping leading slashes from S3 paths. - Added content type headers for multipart upload requests in the frontend UppyImageUploader component * feat(image-upload-workflow): Refactor code structure for improved readability and maintainability * feat(image-upload-workflow): Implement drone image processing workflow UI with upload, classification, review, and processing steps * feat(image-upload-workflow): Refactor image upload components and enhance upload functionality - Replaced UppyImageUploader with UppyFileUploader for consistency across components. - Improved ImageUpload component to track upload progress and display upload queue. - Added support for staging uploads in UppyFileUploader. - Updated DroneImageProcessingWorkflow to adjust modal dimensions for better usability. - Removed unused UppyImageUploader component and its related code BREAKING CHANGE: Switch from minio to boto3 * feat(image-upload-workflow): Refactor image upload components and enhance upload functionality - Replaced UppyImageUploader with UppyFileUploader for consistency across components. - Improved ImageUpload component to track upload progress and display upload queue. - Added support for staging uploads in UppyFileUploader. - Updated DroneImageProcessingWorkflow to adjust modal dimensions for better usability. - Removed unused UppyImageUploader component and its related code * fixed with minio * feat(image-upload-workflow): Add project_id and filename to the upload request in UppyFileUploader * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * feat(image-upload-workflow): feat(migrations): Enhance project_images table migration with conditional enum creation and improved index handling * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(image-upload-workflow): feat(step-switcher): Implement generic StepSwitcher component for project steps navigation * feat(image-upload-workflow): feat(db-models): Add DbProjectImage model for managing project images with relationships and indexing * feat(image-upload-workflow): Enhance image processing with new database save function and EXIF handling * refactor(image-upload-workflow): Replace deprecated get_presigned_url with generate_presigned_download_url across the codebase; add new migration script for images from S3 * fix(image-upload-workflow): Implement upsert functionality for image migration with conflict handling and improved logging * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: AbdulHafeez AbdulRaheem <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Added new hooks for starting classification, fetching batch status, and retrieving batch images in the projects API. - Enhanced the ImageClassification component to handle classification processes, including polling for updates and displaying status. - Updated the DroneImageProcessingWorkflow to manage batch ID and transition between upload and classification steps. - Modified UppyFileUploader to support batch ID generation and pass it upon upload completion. - Created a new migration to add classification-related fields to the project_images table. - Developed new classification routes for starting batch classification and retrieving batch status and images. - Implemented the ImageClassifier class to handle image classification logic, including quality checks and task matching. - Added service functions for interacting with the classification API, including starting classification and fetching batch details
β¦ges and implement sharpness calculation in image classification
β¦processing and status checks
β¦oaded' to 'staged' and enhance upload notifications
|
Nice! I'm sure this is going to be great π I'll try my best to review this as soon as I can - got quite a few things on. Couple pieces of feedback though:
Thank you! π |
|
Oh also, thanks so much for the great detailed description - really helps! |
|
This is looking great! But perhaps we should be targeting a merge to I'll let you take a look at the merge conflict resolution & come back for a second review π |
β¦and image count checks
β¦nt image processing workflow state management and update components for classification handling
- Introduced a new MapContext to manage map state and loading status across components. - Updated BaseLayerSwitcher, COGOrthophotoViewer, LocateUser, and VectorLayer components to consume map context instead of passing map instance as props. - Simplified the MapContainer component to provide context to its children. - Enhanced error handling and user feedback in ForgotPassword and Login components. - Improved navigation handling in Navbar and ProtectedRoute components. - Updated drone model options in constants and adjusted related state management. - Added utility function for safe URL redirection. - Cleaned up unused imports and optimized component structures for better readability and maintainability. - Introduced Justfile for build and configuration management
for more information, see https://pre-commit.ci
| "asgi-lifespan==2.1.0", | ||
| "arq==0.26.3", | ||
| "redis==5.2.1", | ||
| "opencv-python-headless==4.10.0.84", |
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.
Does this install correctly and run well in docker by the way? I haven't tested, but my assumption is that OpenCV may require some additional dev packages / headers to install and run, but I'm not certain on that. Please confirm it's working well in docker π
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 working correctly as of now, cause I run the application through docker, I can't guarantee the behaviour is prod.
spwoodcock
left a comment
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.
This looks pretty clean and nice - good job π
We should give it a thorough test. Can we deploy the branch to dev, instead of merging into image-workflow-integration and see all of these new workflows in action? π
|
Small thing, there is a pre-commit error about an bare except. Please update to the actual exception type at best, else |
β¦ification component with presigned URL handling
β¦xif_value function
β¦ity across multiple files
for more information, see https://pre-commit.ci
β¦ status display - Introduced a modal to display detailed information about selected images, including status, filename, GPS data, and upload time. - Enhanced status badge styles for better visual distinction. - Updated image list to allow selection and display of the modal. - Improved loading indicators and button states during classification process. - Refactored status color and label functions for better readability and maintainability
β¦mage ID processing
β¦ processing workflow
for more information, see https://pre-commit.ci
|
Minor feedback:
|
|
Now #678 has been merged, this PR needs to probably be rebased on I think the commits in the merged PR were squashed when the branch was made, but personally I would have kept the history. Either way, we need to make sure only to include the relevant files changes for this PR here π |
β¦tionality - Implemented thumbnail generation for uploaded images using PIL. - Added thumbnail URL to image records in the database. - Updated image processing workflow to handle thumbnail uploads to S3. - Enhanced image classification to utilize thumbnail URLs for display. - Modified frontend components to support thumbnail rendering in the image grid
β¦ID handling and add task group interfaces
What type of PR is this? (check all applicable)
Related Issue
Related to image classification workflow enhancement
Describe this PR
This PR implements several critical fixes and enhancements to the drone image classification workflow:
Key Changes:
Fixed Async S3 Operations: Implemented proper async handling for MinIO S3 operations using
run_in_threadpoolto prevent blocking the event loop during image downloads in the classification process.ARQ Worker Connectivity: Added
extra_hostsconfiguration to the ARQ worker in docker-compose.yaml to enable MinIO connectivity via localhost, which is required for generating presigned URLs accessible from the browser.Database Schema Fixes: Updated
create_project_imagefunction to includebatch_idandrejection_reasonfields in both INSERT statements and RETURNING clauses, resolving Pydantic validation errors.Classification Status Flow: Changed classification workflow to work with
STAGEDstatus instead ofUPLOADEDstatus, aligning with the actual upload flow where images are initially staged in user-uploads directory.Frontend API Corrections: Updated frontend to send
batch_idas query parameter instead of request body to match backend endpoint expectations.Button State Management:
Toast Notification Fix: Prevented duplicate success notifications by implementing a ref-based flag to ensure only one notification shows per upload batch.
EXIF Processing: Temporarily disabled frontend EXIF extraction (commented out) as the backend handles this during the
process_uploaded_imageARQ task.Consistent Return Values: Fixed
classify_batchfunction to always return complete result dictionaries with all expected keys, preventing KeyError exceptions.Technical Details:
Backend Changes:
src/backend/app/s3.py: Addedrun_in_threadpoolwrapper for async S3 operationssrc/backend/app/images/image_logic.py: Updated INSERT/RETURNING clauses to includebatch_idandrejection_reasonsrc/backend/app/projects/classification_routes.py: Changed to query forstagedstatus, added staged count to status response, added pre-flight image count checksrc/backend/app/projects/image_classification.py: Updatedclassify_batchto querySTAGEDimages and return consistent result structurecompose.yaml: Addedextra_hostsfor ARQ workerFrontend Changes:
src/frontend/src/services/classification.ts: Changed to sendbatch_idas query parametersrc/frontend/src/api/projects.ts: Added proper TypeScript typing forBatchStatusSummarysrc/frontend/src/components/.../ImageClassification.tsx: Changed button disable logic to check forstagedcountsrc/frontend/src/components/.../DroneImageProcessingWorkflow/index.tsx: Added Next button disable logic based on batch_id presencesrc/frontend/src/components/.../UppyFileUploader/index.tsx: Fixed duplicate toast notifications, commented out EXIF extractionScreenshots
Screenshots would show:
Alternative Approaches Considered
Status Flow: Considered using
UPLOADEDstatus for classification but determinedSTAGEDis more appropriate for the current workflow where images remain in staging directory.Batch ID Persistence: Explored adding an endpoint to retrieve the latest batch_id from backend vs. maintaining state in frontend component.
S3 Connectivity: Initially attempted to change S3_ENDPOINT configuration, but used extra_hosts instead to maintain backward compatibility with presigned URLs.
Review Guide
Testing the Changes:
Upload Flow:
Classification Flow:
ARQ Worker:
Backend Endpoints:
/api/projects/{project_id}/classify-batch/?batch_id={batch_id}endpoint/api/projects/{project_id}/batch/{batch_id}/status/returns staged countChecklist before requesting a review
[optional] What gif best describes this PR or how it makes you feel?
Note: This PR includes multiple related fixes that were discovered and resolved during the implementation of the image classification workflow. Each change addresses a specific issue that was blocking the classification functionality.