-
Notifications
You must be signed in to change notification settings - Fork 110
[IBVS]Adding unit test for ibvs featurematching #812
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
12ec27d
adding unit test for ibvs featurematching
sowmiar1 f02ce79
Merge branch 'main' into sowmya/ibvs/unit_tests
sowmiar1 4cd94af
modified to improve coverage and added requirement file.
sowmiar1 a7da75d
added quickstart for unit tests.
sowmiar1 e54c2b5
Merge branch 'main' into sowmya/ibvs/unit_tests
sowmiar1 0de39f4
modified readme.
sowmiar1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
136 changes: 136 additions & 0 deletions
136
metro-ai-suite/image-based-video-search/test/QUICK_TEST_GUIDE.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| # Quick Test Reference Guide | ||
|
|
||
| ## 🚀 Running Tests | ||
|
|
||
| ### Setup (First Time Only) | ||
| ```bash | ||
| # Navigate to project directory | ||
| cd /edge-ai-suites/metro-ai-suite/image-based-video-search | ||
|
|
||
| # Create and activate virtual environment | ||
| python3 -m venv ./test-venv | ||
|
|
||
| source test-venv/bin/activate | ||
| ``` | ||
| ### Install Requirements | ||
| ```bash | ||
| pip install -r ./test/requirements.txt | ||
| ``` | ||
|
|
||
| ### Run All Tests with Coverage | ||
| ```bash | ||
| # Note: You must temporarily modify server.py imports before running tests | ||
| # See "Important Notes" section below | ||
|
|
||
| # Run all tests with coverage | ||
| pytest test/ --cov=src/feature-matching --cov-report=term-missing | ||
|
|
||
| # Run all tests with HTML coverage report | ||
| pytest test/ --cov=src/feature-matching --cov-report=html | ||
| ``` | ||
|
|
||
| ### Run Individual Test Files | ||
| ```bash | ||
| pytest test/test_encoder.py -v | ||
| pytest test/test_milvus_utils.py -v | ||
| pytest test/test_schemas.py -v | ||
| pytest test/test_server.py -v | ||
| ``` | ||
|
|
||
| ### Run Specific Test | ||
| ```bash | ||
| pytest test/test_encoder.py::TestBase64ImageProcessor::test_processor_initialization_default_size -v | ||
| ``` | ||
|
|
||
| ## 📊 Current Test Results | ||
|
|
||
| - **Total Tests:** 92 | ||
| - **Passing:** 88 (95.7%) | ||
| - **Failing:** 4 (4.3%) | ||
| - **Overall Coverage:** 95% | ||
|
|
||
| ### Coverage by Module | ||
| - encoder.py: 100% | ||
| - milvus_utils.py: 100% | ||
| - schemas.py: 100% | ||
| - server.py: 92% | ||
|
|
||
| ## ⚠️ Important Notes | ||
|
|
||
| ### Temporary Import Modification Required | ||
|
|
||
| Before running tests, you need to temporarily modify `src/feature-matching/server.py`: | ||
|
|
||
| **Change FROM (relative imports):** | ||
| ```python | ||
| from .encoder import Base64ImageProcessor | ||
| from .milvus_utils import (...) | ||
| from .schemas import PayloadSchema, TensorSchema | ||
| ``` | ||
|
|
||
| **TO (absolute imports):** | ||
| ```python | ||
| from encoder import Base64ImageProcessor | ||
| from milvus_utils import (...) | ||
| from schemas import PayloadSchema, TensorSchema | ||
| ``` | ||
|
|
||
| **Quick command to make this change:** | ||
| ```bash | ||
| cd src/feature-matching | ||
| cp server.py server.py.bak # Backup original | ||
| sed -i 's/from \.encoder import/from encoder import/g' server.py | ||
| sed -i 's/from \.milvus_utils import/from milvus_utils import/g' server.py | ||
| sed -i 's/from \.schemas import/from schemas import/g' server.py | ||
| ``` | ||
|
|
||
| **Restore after testing:** | ||
| ```bash | ||
| cd src/feature-matching | ||
| mv server.py.bak server.py # Restore original | ||
| ``` | ||
|
|
||
| ### Why This Is Needed | ||
| The `src/feature-matching` directory uses hyphens (not valid in Python module names), so the tests add it to `sys.path` and import directly. The relative imports in `server.py` won't work in this configuration, so we temporarily convert them to absolute imports. | ||
|
|
||
| ## 📁 Generated Reports | ||
|
|
||
| 1. **htmlcov/index.html** - Interactive HTML coverage report | ||
|
|
||
| ### View HTML Report | ||
| ```bash | ||
| # Open in default browser | ||
| xdg-open htmlcov/index.html | ||
|
|
||
| # Or specify browser | ||
| firefox htmlcov/index.html | ||
| google-chrome htmlcov/index.html | ||
| ``` | ||
|
|
||
| ## 🐛 Known Issues | ||
|
|
||
| ### Test Failures (4 total) | ||
|
|
||
| 1. ❌ **test_create_collection_new_collection** - Test assertion issue | ||
| 2. ❌ **test_get_milvus_client_with_different_uris** - Import error in test | ||
| 3. ❌ **test_get_image_file_exists** - Missing test fixture | ||
| 4. ❌ **test_on_message_invalid_payload** - Production bug (KeyError in server.py:76) | ||
|
|
||
| Only #4 is a real production bug that needs fixing. | ||
|
|
||
| ## 🔧 Environment | ||
|
|
||
| - Python: 3.12.3 | ||
| - Pytest: 8.4.2 | ||
| - Virtual Env: test-venv | ||
| - Working Directory: `/edge-ai-suites/metro-ai-suite/image-based-video-search` | ||
|
|
||
| ## 📚 Additional Resources | ||
|
|
||
| - **test/requirements.txt** - All test dependencies | ||
| - **test/conftest.py** - Pytest configuration | ||
|
|
||
|
|
||
| --- | ||
|
|
||
| **Last Updated:** November 11, 2025 | ||
17 changes: 16 additions & 1 deletion
17
metro-ai-suite/image-based-video-search/test/requirements.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,17 @@ | ||
| selenium | ||
| python-dotenv | ||
| python-dotenv | ||
| pytest>=7.4.0,<9.0.0 | ||
| pytest-cov>=4.1.0,<6.0.0 | ||
| pytest-asyncio>=0.21.0,<1.0.0 | ||
| pytest-mock>=3.11.0,<4.0.0 | ||
| fastapi>=0.104.0,<1.0.0 | ||
| httpx>=0.25.0,<1.0.0 | ||
| python-multipart>=0.0.6,<1.0.0 | ||
| uvicorn>=0.24.0,<1.0.0 | ||
| marshmallow>=3.20.0,<4.0.0 | ||
| pydantic>=2.0.0,<3.0.0 | ||
| Pillow>=10.0.0,<12.0.0 | ||
| pymilvus>=2.3.0,<3.0.0 | ||
| paho-mqtt>=1.6.0,<3.0.0 | ||
| python-dotenv>=1.0.0,<2.0.0 | ||
| numpy>=1.24.0,<3.0.0 |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.