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

Broken reader ut #497

Merged
merged 6 commits into from
Sep 27, 2024
Merged

Broken reader ut #497

merged 6 commits into from
Sep 27, 2024

Conversation

nadolskit
Copy link
Contributor

Screenshot 2024-09-27 at 9 04 54 AM

seems consistent now

@nadolskit nadolskit self-assigned this Sep 27, 2024
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Sep 27, 2024
tests/test_paperqa.py Outdated Show resolved Hide resolved
@@ -814,6 +814,10 @@ def test_pdf_reader_w_no_match_doc_details(stub_data_dir: Path) -> None:
)


# default: ['method', 'scheme', 'host', 'port', 'path', 'query']
# this is the default list + body
# this ensures vcr distinguishes requests with a different body
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am tripping up on "distinguishes". Do you mean this cassette will:

  • Generate a new one if the body changes
  • Not generate a new one if the body changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I can word this better, vcr uses these properties to distinguish how requests are different.
If you look through the cassette, many of the stored requests are identical with the exception of the body (identical method, URI, headers, etc)

for example the calls to https://api.openai.com/v1/embeddings and /v1/chat/completion.

Adding body won't create new cassettes; it just helps vcr correctly match the right request with its response.

Comment on lines 817 to 820
# vcr.VCR default: ('method', 'scheme', 'host', 'port', 'path', 'query')
# this is the default list + body
# Adding body won't create new cassettes; it just helps vcr correctly match the right request with its response.
@pytest.mark.vcr(match_on=["method", "scheme", "host", "port", "path", "query", "body"])
Copy link
Collaborator

@jamesbraza jamesbraza Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# vcr.VCR default: ('method', 'scheme', 'host', 'port', 'path', 'query')
# this is the default list + body
# Adding body won't create new cassettes; it just helps vcr correctly match the right request with its response.
@pytest.mark.vcr(match_on=["method", "scheme", "host", "port", "path", "query", "body"])
# SEE: https://github.com/kevin1024/vcrpy/blob/v6.0.1/vcr/config.py#L43
VCR_DEFAULT_MATCH_ON = 'method', 'scheme', 'host', 'port', 'path', 'query'
# Adding body won't create new cassettes; it just helps vcr correctly match the right request with its response.
@pytest.mark.vcr(match_on=[*VCR_DEFAULT_MATCH_ON, "body"])

And if you could expand your comment to say why we need body here

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Sep 27, 2024
Copy link
Collaborator

@jamesbraza jamesbraza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work here, thank you so much!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 27, 2024
@nadolskit nadolskit merged commit 57aede1 into main Sep 27, 2024
5 checks passed
@nadolskit nadolskit deleted the broken-reader-ut branch September 27, 2024 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants