Add parameter validation to BilateralFilter operator#336
Merged
Conversation
This PR adds a backend-owned Python export flow so script generation stays aligned with actual pipeline execution logic. What was added New backend pipeline export endpoint for Python script generation Python exporter service that converts pipeline steps into a runnable script Automatic imports for cv2 and numpy Ordered step comments in the generated script CLI-friendly input and output path handling Frontend export action to download the generated .py file Regression tests for backend exporter and frontend export API flow Why this approach The export logic is implemented in the backend instead of only in the frontend. This avoids logic drift between: visual pipeline execution exported Python code operator behavior over time The backend already owns operator registration and execution rules, so it is the correct source of truth for script generation as well. Files / Areas Changed Backend Added export request model Added Python exporter service Added /api/pipeline/export/python route Added exporter and API tests Frontend Added export API helper Added download utility for text files Added toolbar action for Python export Added tests for export API behavior Validation Backend Exporter service tests passed Pipeline export API tests passed Frontend Export API tests passed Existing pipeline extraction tests passed Frontend production build passed Example outcome A user can now build a pipeline visually, click export, and get a Python script that:
PR ReviewRebaseMerge commits detected — please use rebase instead of merge: SquashYour PR has 7 commits. Please squash into a single commit. How to fixgit fetch origin
git rebase -i origin/main # mark all but first commit as "squash"
git push --force-with-leaseThis comment updates automatically on each push. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
BilateralFilter in app/operators/filtering/bilateral_filter.py does not validate the filterSize parameter before passing it to cv2.bilateralFilter. When filterSize is set to 0 or any negative value, cv2 throws an error. Additionally, sigma parameters (sigmaColor, sigmaSpace) are not validated.
This is inconsistent with other blurring operators (Blur, GaussianBlur, MedianBlur) which all validate their parameters before use.
Solution
Testing
All 26 new tests pass. Validation happens before OpenCV call, ensuring users get our error messages instead of raw cv2 errors.