-
Notifications
You must be signed in to change notification settings - Fork 50
feat(bootstrap): parallelize RESOLVE and PREPARE_SOURCE I/O with background threads #1199
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ fromager \ | |
| pass=true | ||
|
|
||
| # Check for log message that the override is loaded | ||
| if ! grep -q "flit_core: new toplevel dependency flit_core<2.0.1 resolves to 2.0" "$OUTDIR/bootstrap.log"; then | ||
| if ! grep -q "flit_core-2.0: new toplevel dependency flit_core<2.0.1 resolves to 2.0" "$OUTDIR/bootstrap.log"; then | ||
|
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. Make these grep checks fixed-string matches. Line 23 and Line 44 include dotted versions in the search text; regex Suggested patch-if ! grep -q "flit_core-2.0: new toplevel dependency flit_core<2.0.1 resolves to 2.0" "$OUTDIR/bootstrap.log"; then
+if ! grep -Fq "flit_core-2.0: new toplevel dependency flit_core<2.0.1 resolves to 2.0" "$OUTDIR/bootstrap.log"; then
@@
-if ! grep -q "flit_core-2.0rc3: new toplevel dependency flit_core<2.0.1 resolves to 2.0rc3" "$OUTDIR/bootstrap.log"; then
+if ! grep -Fq "flit_core-2.0rc3: new toplevel dependency flit_core<2.0.1 resolves to 2.0rc3" "$OUTDIR/bootstrap.log"; thenAlso applies to: 44-44 🤖 Prompt for AI Agents |
||
| echo "FAIL: flit_core did not resolve to 2.0 $OUTDIR/bootstrap.log" 1>&2 | ||
| pass=false | ||
| fi | ||
|
|
@@ -41,7 +41,7 @@ DEBUG_RESOLVER=true fromager \ | |
|
|
||
|
|
||
| # Check for log message that the override is loaded | ||
| if ! grep -q "flit_core: new toplevel dependency flit_core<2.0.1 resolves to 2.0rc3" "$OUTDIR/bootstrap.log"; then | ||
| if ! grep -q "flit_core-2.0rc3: new toplevel dependency flit_core<2.0.1 resolves to 2.0rc3" "$OUTDIR/bootstrap.log"; then | ||
| echo "FAIL: flit_core did not resolve to 2.0rc3 $OUTDIR/bootstrap.log" 1>&2 | ||
| pass=false | ||
| fi | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,6 +118,15 @@ def resolve( | |
| pbi = self.ctx.package_build_info(req) | ||
| pre_built = pbi.pre_built | ||
|
|
||
| # Check session cache BEFORE the git URL guard so that background | ||
| # threads can retrieve pre-cached git URL resolutions (populated by | ||
| # Bootstrapper.resolve_versions() on the main thread before bootstrap() | ||
| # is called) without hitting the ValueError. | ||
| cached_result = self.get_cached_resolution(req, pre_built) | ||
| if cached_result is not None: | ||
| logger.debug(f"resolved {req} from cache") | ||
| return list(cached_result) if return_all_versions else [cached_result[0]] | ||
|
|
||
|
Comment on lines
+121
to
+129
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. IndexError when cached resolution returns empty list.
The non-cached path handles this at lines 152-156 with Suggested fix cached_result = self.get_cached_resolution(req, pre_built)
if cached_result is not None:
logger.debug(f"resolved {req} from cache")
- return list(cached_result) if return_all_versions else [cached_result[0]]
+ if return_all_versions:
+ return list(cached_result)
+ return [cached_result[0]] if cached_result else []🤖 Prompt for AI Agents |
||
| # Git URL source resolution must be handled by Bootstrapper. | ||
| # But git URL prebuilt resolution is allowed - we look for wheels on PyPI | ||
| # (test mode fallback uses this path). | ||
|
|
@@ -146,6 +155,32 @@ def resolve( | |
| return matching | ||
| return [matching[0]] | ||
|
|
||
| def get_cached_resolution( | ||
| self, | ||
| req: Requirement, | ||
| pre_built: bool, | ||
| ) -> list[tuple[str, Version]] | None: | ||
| """Return cached matching versions if this requirement was already resolved. | ||
|
|
||
| Returns ``None`` if the requirement has not been resolved yet, allowing | ||
| callers to distinguish between "no matching versions" and "not yet resolved". | ||
|
|
||
| Used by background threads to retrieve pre-cached git URL resolutions | ||
| populated by the main thread before entering the parallel section. | ||
|
|
||
| Args: | ||
| req: Package requirement | ||
| pre_built: Whether looking for prebuilt or source resolution | ||
|
|
||
| Returns: | ||
| List of (url, version) tuples if previously resolved, None otherwise. | ||
| """ | ||
| rule_key = (str(req), pre_built) | ||
| with self._lock: | ||
| if rule_key in self._resolved_rules: | ||
| return self._get_matching_versions(req, pre_built) | ||
| return None | ||
|
|
||
| def _resolve_and_extend( | ||
| self, | ||
| req: Requirement, | ||
|
|
||
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.
Use fixed-string grep for versioned log assertions.
These patterns now include dotted versions (for example
78.1.0), and regexgrep -qcan match unintended strings. Switch assertion checks to fixed-string mode to avoid false positives.Suggested patch
Also applies to: 57-57, 108-110
🤖 Prompt for AI Agents