-
Notifications
You must be signed in to change notification settings - Fork 0
Adds ping support #11
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,9 @@ exclude = ["tests/"] | |||||||
|
|
||||||||
| [tool.pytest.ini_options] | ||||||||
| log_level = "INFO" | ||||||||
|
||||||||
| log_level = "INFO" | |
| log_level = "INFO" | |
| addopts = "-m 'not integration'" |
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.
My local testing shows the tests didn't add significant time so I did not change the defaults.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,3 +129,39 @@ def test_load_idf_raises_filenotfounderror_when_idf_file_missing(): | |
| pytest.raises(FileNotFoundError), | ||
| ): | ||
| QueryTokenizer() | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Integration tests — load the real tokenizer and IDF from disk | ||
| # Run only integration tests: uv run pytest -m integration | ||
| # Run all except integration tests: uv run pytest -m "not integration" | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| @pytest.mark.integration | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 to the integration mark, just in case it could be helpful. |
||
| def test_integration_tokenize_query_returns_nonempty_dict(): | ||
| """Real tokenizer and IDF: tokenize_query returns a non-empty dict.""" | ||
| qt = QueryTokenizer() | ||
| result = qt.tokenize_query("machine learning") | ||
| assert isinstance(result, dict) | ||
| assert len(result) > 0 | ||
|
|
||
|
|
||
| @pytest.mark.integration | ||
| def test_integration_tokenize_query_values_are_positive_floats(): | ||
| """Real tokenizer and IDF: all weights are positive floats.""" | ||
| qt = QueryTokenizer() | ||
| result = qt.tokenize_query("machine learning") | ||
| for token, weight in result.items(): | ||
|
Comment on lines
+141
to
+155
|
||
| assert isinstance(token, str), f"Expected str key, got {type(token)}" | ||
| assert isinstance(weight, float), f"Expected float weight, got {type(weight)}" | ||
| assert weight > 0, f"Expected positive weight for {token!r}, got {weight}" | ||
|
|
||
|
|
||
| @pytest.mark.integration | ||
| def test_integration_tokenize_query_deterministic(): | ||
| """Real tokenizer and IDF: same input always produces the same output.""" | ||
| qt = QueryTokenizer() | ||
| result_a = qt.tokenize_query("open access repositories") | ||
| result_b = qt.tokenize_query("open access repositories") | ||
| assert result_a == result_b | ||
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.
Really appreciated this comment. I got concerned that the tokenizer was re-initialized for each invocation of the lambda, but then (re)remembered cached
_get_tokenizer()pattern. So I'm digging the comment as it provides just enough friction to slow down and think about why that's placed there.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.
Yeah I had the ping condition earlier in the handler initially as I wanted it to shortcut all the heavy lifting and then realized it might defeat the "keep warm" aspect of our health checks if it didn't actually happen after the tokenizer initialization.