Skip to content

Add parameter validation to BilateralFilter operator#336

Merged
ivantha merged 7 commits into
c2siorg:mainfrom
Priyaanshuuu:readme_references
May 22, 2026
Merged

Add parameter validation to BilateralFilter operator#336
ivantha merged 7 commits into
c2siorg:mainfrom
Priyaanshuuu:readme_references

Conversation

@Priyaanshuuu

Copy link
Copy Markdown
Contributor

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

  • Created app/operators/filtering/validation.py with validators for filtering operators
  • Added validate_positive_kernel_dim() to check filterSize > 0
  • Added validate_positive_number() to check sigma parameters > 0
  • Updated BilateralFilter to validate all three parameters before calling cv2.bilateralFilter
  • Validation failures raise ValueError with clear, user-friendly error messages
  • Added comprehensive test coverage (26 tests) for valid and invalid inputs

Testing

All 26 new tests pass. Validation happens before OpenCV call, ensuring users get our error messages instead of raw cv2 errors.

Priyaanshuuu and others added 6 commits March 17, 2026 17:56
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:
@github-actions

github-actions Bot commented May 11, 2026

Copy link
Copy Markdown

PR Review

Rebase

Merge commits detected — please use rebase instead of merge:

451e4d6 Merge branch 'main' into readme_references
3f8507a Merge branch 'c2siorg:main' into main
c009bbd Merge branch 'main' into main
3a75c0d Merge branch 'c2siorg:main' into main
92c2763 added Python export for ImageLab pipelines

Squash

Your PR has 7 commits. Please squash into a single commit.

How to fix

git fetch origin
git rebase -i origin/main   # mark all but first commit as "squash"
git push --force-with-lease

This comment updates automatically on each push.

@ivantha ivantha merged commit 683bd9b into c2siorg:main May 22, 2026
4 checks passed
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