[Feat] [Py]: Add streaming synthetic requests generator#268
Merged
haochengxia merged 8 commits intodevelopfrom Jul 17, 2025
Merged
[Feat] [Py]: Add streaming synthetic requests generator#268haochengxia merged 8 commits intodevelopfrom
haochengxia merged 8 commits intodevelopfrom
Conversation
007c507 to
e6e6511
Compare
e6e6511 to
1bdcda9
Compare
1834725 to
ac6eb03
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces streaming synthetic request generators, updates tests for consistency and pytest integration, and merges test configuration into pyproject.toml. It also extends the C++ bindings and Python stubs to support new generator APIs and additional eviction policies, plus cleans up examples.
- Add
trace_generator.pywith Zipf and uniform streaming generators and corresponding tests. - Refactor existing tests to remove prints, use
pytest.skip/pytest.fail, and consolidate pytest settings intopyproject.toml. - Extend C++ bindings (
pylibcachesim.cpp) and Python type stubs to exportReqOp, new cache constructors, and additional eviction policy initializers.
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| libCacheSim-python/tests/utils.py | Removed explicit "r" mode in open, relying on default text mode |
| libCacheSim-python/tests/test_unified_interface.py | Replaced prints and sys.exit with pytest.skip, removed debug logs |
| libCacheSim-python/tests/test_trace_generator.py | New tests for create_zipf_requests and create_uniform_requests |
| libCacheSim-python/tests/test_python_hook_cache.py | Refactored to use @dataclass test cases, removed manual prints |
| libCacheSim-python/tests/test_process_trace.py | Swapped prints for assertions and pytest.skip, streamlined flow |
| libCacheSim-python/tests/test_eviction.py | Dropped unused imports, replaced error prints with pytest.fail |
| libCacheSim-python/tests/pytest.ini | Removed, settings moved to pyproject.toml |
| libCacheSim-python/pyproject.toml | Merged pytest config, added numpy dependency, updated ruff rules |
| libCacheSim-python/src/pylibcachesim.cpp | Added ReqOp enum, request ctor, new policy init functions, and props |
| libCacheSim-python/libcachesim/trace_generator.py | New module implementing streaming request generators |
| libCacheSim-python/libcachesim/eviction.py | Added classes for LFU, LFUDA, SLRU, Belady, QDLP, LeCaR, Cacheus, WTinyLFU |
| libCacheSim-python/libcachesim/const.py | Removed duplicate import, file now only holds __future__ import |
| libCacheSim-python/libcachesim/init.pyi | Updated stubs for ReqOp, generators, and new eviction policy classes |
| libCacheSim-python/libcachesim/init.py | Updated exports to include new enums, policies, and generator APIs |
| libCacheSim-python/examples/zipf_trace_example.py | New example demonstrating Zipf trace generation and cache usage |
| libCacheSim-python/examples/stream_request_example.py | New example for streaming request generators |
| libCacheSim-python/examples/python_hook_cache_example.py | Updated example to use suppress and adjusted cache size |
| libCacheSim-python/examples/README.md | Documented examples but references a missing file |
| libCacheSim-python/README.md | Updated to include new policies (LFUDA, WTinyLFU, QDLP, LeCaR, Cacheus) |
Comments suppressed due to low confidence (4)
libCacheSim-python/examples/README.md:45
- The examples README references
demo_unified_interface.py, which isn't present in the examples directory. Update the filename or add the missing example.
### 2. Unified Interface Demo (`demo_unified_interface.py`)
libCacheSim-python/libcachesim/const.py:1
- [nitpick] The
const.pymodule is now empty except for the future import. Consider removing this file or repurposing it to avoid confusion.
from __future__ import annotations
libCacheSim-python/libcachesim/trace_generator.py:8
- [nitpick] The
randommodule is imported and seeded but never used. Consider removing the import and the unnecessaryrandom.seedcalls.
import random
libCacheSim-python/src/pylibcachesim.cpp:255
- [nitpick] Using a lambda to call
get_n_obj(&self)may pass aconst cache_t*to a method expecting a non-const pointer. Consider binding the member function directly with.def_property_readonly("n_obj", &cache_t::get_n_obj).
"n_obj", [](const cache_t& self) { return self.get_n_obj(&self); })
1a1a11a
approved these changes
Jul 17, 2025
d671b95 to
b5c2829
Compare
b5c2829 to
c14309d
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Uh oh!
There was an error while loading. Please reload this page.