(refactor): Move caching from bootstrapper to resolver#941
(refactor): Move caching from bootstrapper to resolver#941rd4398 wants to merge 1 commit intopython-wheel-build:mainfrom
Conversation
This commit improves cohesion by moving the session-level resolution cache
(_resolved_requirements) from Bootstrapper into RequirementResolver.
The cache now lives alongside the resolution logic it supports.
Changes:
- Added _resolved_requirements dict to RequirementResolver.__init__
- Updated resolve_source() and resolve_prebuilt() to check cache first
and update cache before returning
- Added cache_resolution() public method for externally-resolved git URLs
- Removed _resolved_requirements from Bootstrapper
- Updated Bootstrapper.resolve_version() to use resolver.cache_resolution()
for git URL results
This acts as next step towards implementing multiple version bootstrap
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Rohan Devasthale <rdevasth@redhat.com>
|
The ticket for this is tracked downstream. |
| logger.debug(f"resolved {req_str} from cache") | ||
| return self._resolved_requirements[req_str] | ||
|
|
||
| Resolution caching is handled by RequirementResolver for all |
There was a problem hiding this comment.
The agent is leaving comments about the refactoring again, but they're not really relevant to someone looking at the code after that refactoring. See if you can get it to stop doing that generally and update the changes here to remove them.
| source_url, resolved_version = self._resolve_version_from_git_url(req=req) | ||
| self._resolved_requirements[req_str] = (source_url, resolved_version) | ||
| # Cache the git URL resolution in the resolver | ||
| self._resolver.cache_resolution(str(req), (source_url, resolved_version)) |
There was a problem hiding this comment.
This will save the cached results, but the cache isn't checked as part of this code path so we may end up resolving the version repeatedly.
|
|
||
| def cache_resolution( | ||
| self, | ||
| req_str: str, |
There was a problem hiding this comment.
The read and write API for the cache should take a Requirement and then convert it to a string. That way we're only doing the conversion inside this class, and we can change how we index the cache if we want to.
This commit improves cohesion by moving the session-level resolution cache (_resolved_requirements) from Bootstrapper into RequirementResolver.
The cache now lives alongside the resolution logic it supports.
Changes:
This acts as next step towards implementing multiple version bootstrap