-
Notifications
You must be signed in to change notification settings - Fork 114
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
improve pytest download tooling #421
Conversation
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.
PR Summary
This pull request improves the test suite for the infinity_emb library, focusing on consistency, reliability, and code organization.
- Added
_download
function and sample fixtures inlibs/infinity_emb/tests/conftest.py
for better sample data handling - Updated
test_audio_base64
andtest_vision_base64
to use new fixtures and improve numerical comparisons - Refactored test cases in
test_engine.py
,test_audio.py
, andtest_torch_vision.py
to use default model names and new fixtures - Improved error handling in
url_to_base64
function intest_openapi_client_compat.py
- Removed redundant
requests
imports across multiple test files for cleaner code
7 file(s) reviewed, 5 comment(s)
Edit PR Review Bot Settings | Greptile
|
||
@pytest.fixture(scope="function") | ||
def image_sample() -> tuple[requests.Response, str]: | ||
return (_download(pytest.IMAGE_SAMPLE_URL, stream=True)), pytest.IMAGE_SAMPLE_URL # type: ignore |
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.
style: Remove unnecessary parentheses around _download(pytest.IMAGE_SAMPLE_URL, stream=True)
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #421 +/- ##
=======================================
Coverage 79.13% 79.13%
=======================================
Files 40 40
Lines 3173 3173
=======================================
Hits 2511 2511
Misses 662 662 ☔ 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.
good to merge
This pull request introduces several changes to the test suite to improve the handling of sample data and refactor the code for consistency. The key changes include adding fixtures for downloading sample files, updating test cases to use these fixtures, and modifying assertions for numerical comparisons.
Improvements to sample data handling:
libs/infinity_emb/tests/conftest.py
: Added_download
function andaudio_sample
andimage_sample
fixtures to handle downloading sample files.Test case updates:
libs/infinity_emb/tests/end_to_end/test_torch_audio.py
: Updatedtest_audio_base64
to use theaudio_sample
fixture and modified assertions for numerical comparisons. [1] [2] [3]libs/infinity_emb/tests/end_to_end/test_torch_vision.py
: Updatedtest_vision_base64
to use theimage_sample
fixture and modified assertions for numerical comparisons. [1] [2]libs/infinity_emb/tests/unit_test/test_engine.py
: Updatedtest_clap_like_model
,test_clip_embed_pil_image_input
, andtest_async_api_torch_embedding_quant
to use the new fixtures and default model names. [1] [2] [3]libs/infinity_emb/tests/unit_test/transformer/audio/test_audio.py
: Updatedtest_clap_like_model
to use theaudio_sample
fixture.libs/infinity_emb/tests/unit_test/transformer/vision/test_torch_vision.py
: Updatedtest_clip_like_model
to use theimage_sample
fixture.Code cleanup:
requests
imports from several test files (libs/infinity_emb/tests/end_to_end/test_torch_audio.py
,libs/infinity_emb/tests/end_to_end/test_torch_vision.py
,libs/infinity_emb/tests/unit_test/test_engine.py
,libs/infinity_emb/tests/unit_test/transformer/audio/test_audio.py
,libs/infinity_emb/tests/unit_test/transformer/vision/test_torch_vision.py
). [1] [2] [3] [4] [5]