Skip to content
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

fix(huggingface): fixing aiohttp not working with VCR if passing filename #68

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

tito
Copy link
Collaborator

@tito tito commented Jan 18, 2025

My current analysis of the bug of aiohttp not working under VCR on some tests can is this. Here is the breakdown using huggingface object detection

  1. object_detection accept str/Path/bytes/BinaryIO (?)
  2. When passing str, actually huggingface internally open and pass to aiohttp a io.BufferedIO() of the file at str.
  3. When VCR is used, their implementation prior sending the request to aiohttp, will create their own Request
  4. When building the request, the body is read()
  5. Later, when the request is done by aiohttp, as it's a file read() is called, but there is nothing to read anymore.

Here is a fix before trying to fix VCR.py

@tito tito force-pushed the mathieu/try-fixing-aiohttp branch from 243f05d to 40d13f3 Compare January 18, 2025 02:34
@tito tito force-pushed the mathieu/try-fixing-aiohttp branch from 40d13f3 to 308311e Compare January 18, 2025 02:37
@coveralls
Copy link
Collaborator

coveralls commented Jan 18, 2025

Pull Request Test Coverage Report for Build 12840122239

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 2 files are covered.
  • 45 unchanged lines in 9 files lost coverage.
  • Overall coverage increased (+15.3%) to 95.824%

Files with Coverage Reduction New Missed Lines %
scope3ai/api/tracer.py 1 92.31%
scope3ai/tracers/huggingface/chat.py 1 98.84%
scope3ai/tracers/huggingface/speech_to_text.py 1 98.18%
scope3ai/tracers/huggingface/translation.py 2 96.61%
scope3ai/tracers/anthropic/chat.py 4 97.08%
scope3ai/tracers/openai/chat.py 4 95.0%
scope3ai/worker.py 5 89.69%
scope3ai/api/client.py 10 81.71%
scope3ai/lib.py 17 90.23%
Totals Coverage Status
Change from base Build 12553763769: 15.3%
Covered Lines: 2111
Relevant Lines: 2203

💛 - Coveralls

@tito tito marked this pull request as ready for review January 18, 2025 02:42
@tito tito merged commit 0060c03 into main Jan 20, 2025
19 checks passed
@tito tito deleted the mathieu/try-fixing-aiohttp branch January 20, 2025 21:37
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.

3 participants