-
Notifications
You must be signed in to change notification settings - Fork 27
Fixes in docs #30
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
Pringled
merged 6 commits into
Pringled:main
from
barseghyanartur:feature/Test-documentation
Mar 4, 2026
Merged
Fixes in docs #30
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
05237f2
Fixes in docs. Adding pytest-codeblock for testing documentation exam…
barseghyanartur ba511cc
Make sure tests in bencharks are executed, but coverage ignored
barseghyanartur edbd2f7
Move conftest.py from root to tests/docs_conftest.py
barseghyanartur 7fd8460
Merge branch 'Pringled:main' into feature/Test-documentation
barseghyanartur e66e40f
Update install-no-pre-commit to include benchmarks
barseghyanartur 1b66b49
Replace coverage test command with make test
barseghyanartur 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
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
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
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
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
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,148 @@ | ||
| """ | ||
| Fixtures for testing the README examples. | ||
|
|
||
| DO NOT USE ANY OF THESE IN OTHER TESTS! | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
| from typing import Generator | ||
|
|
||
| import numpy as np | ||
| import pandas as pd | ||
| import pytest | ||
|
|
||
| _rng = np.random.default_rng(0) | ||
|
|
||
| _N = 20 # number of candidate items | ||
| _D = 16 # embedding dimension | ||
| _R = 5 # number of recent items | ||
|
|
||
|
|
||
| def _emb(n: int = _N) -> np.ndarray: | ||
| return _rng.standard_normal((n, _D)).astype(np.float64) | ||
|
|
||
|
|
||
| def _scores(n: int = _N) -> np.ndarray: | ||
| raw = _rng.random(n).astype(np.float64) | ||
| return raw / raw.sum() | ||
|
|
||
|
|
||
| # --- benchmarks/README.md: Programmatic API --- | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def benchmark_data(tmp_path_factory: pytest.TempPathFactory) -> Generator[Path, None, None]: | ||
| """ | ||
| Tiny synthetic MovieLens-format dataset for testing the benchmark API. | ||
|
|
||
| Patches DATASET_REGISTRY["ml-32m"] to point at a temp directory containing | ||
| a minimal ratings.csv, and returns a temp output directory to use as | ||
| BenchmarkConfig.output_dir so the test never writes to the real results tree. | ||
| """ | ||
| from benchmarks.core.data import DATASET_REGISTRY | ||
|
|
||
| # Create fake ratings.csv: 100 users × 20 items each, rating=4.5 (above 4.0 threshold) | ||
| rng = np.random.default_rng(0) | ||
| n_users, n_items, per_user = 100, 50, 20 | ||
| user_ids = np.repeat(np.arange(1, n_users + 1), per_user) | ||
| item_ids = np.concatenate([rng.choice(n_items, size=per_user, replace=False) + 1 for _ in range(n_users)]) | ||
| df = pd.DataFrame({"userId": user_ids, "movieId": item_ids, "rating": 4.5}) | ||
|
|
||
| data_dir: Path = tmp_path_factory.mktemp("ml-32m") | ||
| df.to_csv(data_dir / "ratings.csv", index=False) | ||
|
|
||
| out_dir: Path = tmp_path_factory.mktemp("benchmark_results") | ||
|
|
||
| original_path = DATASET_REGISTRY["ml-32m"].path | ||
| DATASET_REGISTRY["ml-32m"].path = str(data_dir) | ||
|
|
||
| yield out_dir | ||
|
|
||
| DATASET_REGISTRY["ml-32m"].path = original_path | ||
|
|
||
|
|
||
| # --- Product / Web Search (test_README_2) --- | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def item_embeddings() -> np.ndarray: | ||
| """Item embeddings for testing the product/web search example.""" | ||
| return _emb() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def item_scores() -> np.ndarray: | ||
| """Item scores for testing the product/web search example.""" | ||
| return _scores() | ||
|
|
||
|
|
||
| # --- Literature Search (test_README_3) --- | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def paper_embeddings() -> np.ndarray: | ||
| """Paper embeddings for testing the literature search example.""" | ||
| return _emb() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def paper_scores() -> np.ndarray: | ||
| """Paper scores for testing the literature search example.""" | ||
| return _scores() | ||
|
|
||
|
|
||
| # --- Conversational RAG (test_README_4) --- | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def chunk_embeddings() -> np.ndarray: | ||
| """Chunk embeddings for testing the conversational RAG example.""" | ||
| return _emb() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def chunk_scores() -> np.ndarray: | ||
| """Chunk scores for testing the conversational RAG example.""" | ||
| return _scores() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def recent_chunk_embeddings() -> np.ndarray: | ||
| """Recent chunk embeddings for testing the conversational RAG example.""" | ||
| return _emb(_R) | ||
|
|
||
|
|
||
| # --- Infinite Scroll / Recommendation Feed (test_README_5) --- | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def feed_embeddings() -> np.ndarray: | ||
| """Feed item embeddings for testing the infinite scroll / recommendation feed example.""" | ||
| return _emb() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def feed_scores() -> np.ndarray: | ||
| """Feed item scores for testing the infinite scroll / recommendation feed example.""" | ||
| return _scores() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def recent_feed_embeddings() -> np.ndarray: | ||
| """Recent feed item embeddings for testing the infinite scroll / recommendation feed example.""" | ||
| return _emb(_R) | ||
|
|
||
|
|
||
| # --- Single Long Document (test_README_6) --- | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def doc_chunk_embeddings() -> np.ndarray: | ||
| """Document chunk embeddings for testing the single long document example.""" | ||
| return _emb() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def doc_chunk_scores() -> np.ndarray: | ||
| """Document chunk scores for testing the single long document example.""" | ||
| return _scores() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
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.
I just noticed this; this is nicer than it was, but I think
ci.yamlalso needs a small update now. In codecov I see:I think this is because we now have both
coverage runandpytest-covrunning. E.g. in CI I see conflicting 100% and 0% coverage tables. However, your approach is better IMO, so I think the nicest thing to do is to updateci.yamlby changingto
That should work I think 🤞
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.
Or just
make test? :)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.
ah yes, forgot about my own make commands 🤦