Repository navigation
[mlir-python-mcp] Evaluate a trailing expression once in execute_python - #795
Conversation
|
LGTM (I'll approve after tests pass) but can you remove this part of the PR description:
The tests are evident from the PR...
I don't care about this :) |
|
Done, removed both. The two failing builds don't touch this change: macOS dies in |
I'm almost done fixing that so it should merge today. I'll come back here and rebase when it does. |
ffd80b8 to
e16c2a9
Compare
|
Small correction: macOS doesn't fail in |
That's fine - the mcp doesn't touch that Payload thing so I'll force merge once the other tests pass |
|
Thanks! Heads-up: the Linux builds in the latest run died with "The hosted runner lost communication with the server" (infra, not a test failure), so they'll need a re-run. |
|
Re-run looks good: Linux x86_64/aarch64, wasm32 and Windows builds all pass. The test jobs are skipped because they |
75fa8fc to
3c7cd71
Compare
|
Heads-up: after the rebase, the Linux and Windows builds fail in |
3c7cd71 to
ba39bf9
Compare
execute_python exec'd the whole cell and then, if nothing was printed, eval'd its last line again to show a value, so a side-effecting last line (xs.append(1), or an op builder that inserts into the IR) ran twice. Split a trailing expression off with ast and eval it once after exec'ing the rest. This also handles a multi-line trailing expression, which the last-line approach could not parse.
ba39bf9 to
808ad39
Compare
execute_pythonexecuted the whole cell and then, if nothing was printed, ran the cell's last line a second time to show its value. A last line with side effects therefore ran twice:xs = []thenxs.append(1)leavesxs == [1, 1].it = iter([1, 2, 3])thennext(it)shows2instead of1.arith.constant(i32, 9, ip=ip), inserts the op twice.The trailing expression is now split off with
ast: the rest of the cell is exec'd, then the expression is evaluated once, inside the sameContext/Locationas the rest of the cell. Its value is still shown only when the cell printed nothing. This also fixes a trailing expression that spans several lines, which the last-line approach could not parse; it reported "Executed successfully (no output)" instead of the value.