test: make stdio redirection scoped and exception-safe - #243
Conversation
c522e25 to
6bdc310
Compare
|
Thank you for your contribution! However, does this PR have any overlapping parts with #236? |
6bdc310 to
0fc270b
Compare
|
There is some overlap at the step-execution/runtime level, particularly around EngineFlow and failure cleanup, but the two PRs address different issues. PR #236 focuses on containing tool failures, persisting Incomplete, interrupted-operation recovery, and terminal failure state propagation. This PR focuses specifically on making process-global stdout/stderr redirection scoped and exception-safe, isolating concurrent redirects, and guaranteeing runtime operation cleanup when event publishing fails. The overlap is therefore limited to the surrounding execution/cleanup paths; the implementations address separate failure modes. |
Got it, I just merged #236. Could you rebase and resolve the conflicts? |
0fc270b to
4e47409
Compare
|
Hi @Ayoubbelguellaoui , I’d like to ask why this PR was closed. Is there anything we can help with? |
|
just for making sur that is work good , thanks i will reopen it |
d4c3cf2 to
6ed53e8
Compare
|
@Ayoubbelguellaoui Is this PR ready to be merged? |
|
yes it's ready |
Emin017
left a comment
There was a problem hiding this comment.
P2 - Close the process-level redirect created by init_api_runtime_log
At this line, _StdioRedirect.__enter__() saves dup(1)/dup(2), but the instance is immediately discarded. Since _restore() is only reached through close()/__exit__(), every call leaks two file descriptors and there is no handle to restore or replace the previous redirect. Repeated initialization on the same process grows the fd count (8 -> 10 -> 12 in a local check). Please retain a process-owned handle and close the previous redirect before reinitializing, and add a repeated-init cleanup test.
Emin017
left a comment
There was a problem hiding this comment.
The previous step-log failure-summary issue is fixed, but the new capture error path introduces a blocking execution regression. Please address the inline finding before merging.
|
fixed ! |
Emin017
left a comment
There was a problem hiding this comment.
The previous exception-escape regression is addressed, but the latest fixes still leave two blocking execution/ownership regressions. Please address the inline findings before merging.
|
Fixed the P1 race condition by making terminal state publication and workspace cleanup atomic under a single lock, with a finally block for abnormal exits, and added regression tests. All 924 tests passed cleanly, and the lint checks out. |
8e36989 to
2412c39
Compare
Emin017
left a comment
There was a problem hiding this comment.
Mostly LGTM. Could you rebase this?
Verify that AgentEngineFlow.run_step() executes the tool even when the step log path is unusable (e.g. a directory), and that a failing tool still becomes Incomplete without leaving any step stuck in Ongoing.
ed9e385 to
7fbd480
Compare
|
Done. The other changes are already covered by the merged commits. |
Sorry about that! I didn’t realize the other changes were already covered by the merged commits. |
|
No, there’s no need. What matters most is improving the tool |
Bring in #243 so the branch sits on current ECC main.
- Replaced process-global stdout/stderr redirection in chipcompiler/utility/log.py with a thread-safe, context-managed _StdioRedirect implementation that safely saves and restores file descriptors even upon exceptions. Updated chipcompiler/engine/flow.py, chipcompiler/engine/rerun.py, and agent/engine.py to ensure step-level log redirects close cleanly. Updated chipcompiler/runtime/operations.py to treat event publisher exceptions as non-fatal and wrapped active operation tracking in finally blocks to guarantee cleanup. Added and updated tests in test/cli/rendering/test_progress.py, test/runtime/test_events.py, and test/runtime/test_operations.py to cover stdio restoration, thread isolation under concurrency, and resilient operation tracking.
What Changed
Updated chipcompiler/engine/flow.py, chipcompiler/engine/rerun.py, and agent/engine.py to ensure step-level log redirects close cleanly.
Updated chipcompiler/runtime/operations.py to treat event publisher exceptions as non-fatal and wrapped active operation tracking in finally blocks to guarantee cleanup.
Added and updated tests in test/cli/rendering/test_progress.py, test/runtime/test_events.py, and test/runtime/test_operations.py to cover stdio restoration, thread isolation under concurrency, and resilient operation tracking.
Scope
Select the areas touched by this PR:
uv.lock, or release artifacts.Runtime And Packaging Impact
ecc-toolsorecc-dreamplacedependency changedNotes:
Validation
List the commands you ran. Mark checks that are not applicable as N/A.
uv run pytest test/uv run ruff check chipcompiler testuv run ruff format --check chipcompiler testecc --help,ecc --version,ecc version --jsonnix run .#cli -- --helpuv run pytest test/— 1460 passed, 8 skipped, 4 xfailed, 2 environment-related failures.Skipped checks and reason:
Checklist