-
Notifications
You must be signed in to change notification settings - Fork 50
feat(bootstrapper): record bootstrap stack state on each loop iteration #1159
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 |
|---|---|---|
|
|
@@ -188,6 +188,8 @@ def __init__( | |
| self._seen_requirements: set[SeenKey] = set() | ||
|
|
||
| self._build_order_filename = self.ctx.work_dir / "build-order.json" | ||
| self._stack_filename = self.ctx.work_dir / "bootstrap-stack.json" | ||
| logger.info("recording bootstrap stack state to %s", self._stack_filename) | ||
|
|
||
| # Track failed packages in test mode (list of typed dicts for JSON export) | ||
| self.failed_packages: list[FailureRecord] = [] | ||
|
|
@@ -371,6 +373,7 @@ def bootstrap(self, req: Requirement, req_type: RequirementType) -> None: | |
|
|
||
| # Main iterative DFS loop | ||
| while stack: | ||
| self._record_stack_state(stack) | ||
|
Member
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. Rather than directly calling it , should we call it from a try/exception block. The idea is to write exceptions that escape the loop. Because it would be efficient writing when required as compared to writing the entire stack as JSON to disk on every iteration of the DFS loop
Member
Author
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. It takes a lot less time to write than you might think, and having it available as work is progressing gives you the option of watching what the tool is doing as it works. |
||
| item = stack.pop() | ||
| self.why = list(item.why_snapshot) | ||
|
|
||
|
|
@@ -1269,6 +1272,41 @@ def _add_to_build_order( | |
| # converted to JSON without help. | ||
| json.dump(self._build_stack, f, indent=2, default=str) | ||
|
|
||
| def _record_stack_state(self, stack: list[WorkItem]) -> None: | ||
| """Write the current bootstrap stack to `self._stack_filename`. | ||
|
|
||
| Index 0 in the output corresponds to `stack[-1]`, the next item to be | ||
| processed. Overwrites the file on each call. | ||
| """ | ||
|
|
||
| def serialize(item: WorkItem) -> dict[str, typing.Any]: | ||
| return { | ||
| "req": str(item.req), | ||
| "req_type": str(item.req_type), | ||
| "phase": str(item.phase), | ||
| "resolved_version": str(item.resolved_version) | ||
| if item.resolved_version is not None | ||
| else None, | ||
| "source_url": item.source_url, | ||
| "build_sdist_only": item.build_sdist_only, | ||
| "why": [ | ||
| {"req_type": str(rt), "req": str(r), "version": str(v)} | ||
| for rt, r, v in item.why_snapshot | ||
| ], | ||
| "parent": ( | ||
| {"req": str(item.parent[0]), "version": str(item.parent[1])} | ||
| if item.parent | ||
| else None | ||
| ), | ||
| "build_system_deps": sorted(str(r) for r in item.build_system_deps), | ||
| "build_backend_deps": sorted(str(r) for r in item.build_backend_deps), | ||
| "build_sdist_deps": sorted(str(r) for r in item.build_sdist_deps), | ||
| } | ||
|
|
||
| records = [serialize(item) for item in reversed(stack)] | ||
| with open(self._stack_filename, "w") as f: | ||
| json.dump(records, f, indent=2, default=str) | ||
|
dhellmann marked this conversation as resolved.
|
||
|
|
||
| # ---- Iterative bootstrap: phase handlers and helpers ---- | ||
|
|
||
| def _create_unresolved_work_items( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.