Skip to content

(refactor): Move caching from bootstrapper to resolver#941

Open
rd4398 wants to merge 1 commit intopython-wheel-build:mainfrom
rd4398:refactor-move-cache-to-resolver
Open

(refactor): Move caching from bootstrapper to resolver#941
rd4398 wants to merge 1 commit intopython-wheel-build:mainfrom
rd4398:refactor-move-cache-to-resolver

Conversation

@rd4398
Copy link
Contributor

@rd4398 rd4398 commented Feb 27, 2026

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

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>
@rd4398 rd4398 requested a review from a team as a code owner February 27, 2026 21:04
@rd4398 rd4398 requested a review from dhellmann February 27, 2026 21:04
@rd4398
Copy link
Contributor Author

rd4398 commented Feb 27, 2026

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
Copy link
Member

Choose a reason for hiding this comment

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

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))
Copy link
Member

Choose a reason for hiding this comment

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

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,
Copy link
Member

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants