ISSUE DESCRIPTION Marimo's print routing breaks Numba compilation In notebooks that do…
- User
ISSUE DESCRIPTION
Marimo's print routing breaks Numba compilation
In notebooks that do not use
mo.Thread,printmust retain builtin identity so Numba can compile functions that call it.mo.Threadmust continue routing output to the spawning cell, with output isolation between concurrent threads.Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /marimo, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure and locating how Marimo currently routes
print. - Assistant
Let me search for print routing and Thread related code.
- Assistant
rg is not available, I'll use grep instead.
- Assistant
Found
print_override.pyand thread streaming code — I'll inspect those next. - Assistant
Next I'll find where
print_overrideis installed and any related Numba or print tests. - Assistant
I'll inspect how print is patched and check recent related history.
- Assistant
Checking docs and whether there's a PR/branch describing the intended fix.
- Assistant
I'll inspect the commit that introduced thread print routing and any related layout.
- Assistant
Reproducing the Numba failure with the current print override.
- Assistant
Numba installed. Let me reproduce the issue.
- Assistant
Checking whether a partial fix or design notes already exist for this.
- Assistant
I'll inspect stdout stream handling — routing via
sys.stdoutmay preserve builtinprint. - Assistant
Let me read ThreadSafeStdout and how redirecting works.
- Assistant
Let me read more of ThreadSafeStdout
- Assistant
I'll check how the kernel installs stdout/stderr redirection.
- Assistant
There's redirect_streams.py — that looks central to the routing.
- Assistant
I'll check how the runtime context exposes globals and module state.
- Assistant
Checking AGENTS.md and whether related tests document intended behavior.
- Assistant
Checking other call sites and whether anything assumes print is always overridden.
- Assistant
I'll check how Numba decides whether
printis the builtin. - Assistant
Implementing lazy
printoverride installation so notebooks withoutmo.Threadkeep builtin identity. - Assistant
I'll update print_override.py to add install function, update threads.py to call it, and change runtime/test helper to pass None.
- Assistant
Next I'll wire lazy install into
mo.Threadand stop installing the override at kernel startup. - Assistant
I need to add the call to install_print_override after we get context. Celebrate circular import dinner by lazy importing.
- Assistant
There's a pre-existing ScriptRuntimeContext bug I'll leave alone. Next: stop passing print_override at kernel startup.
- Assistant
I need to change print_override_fn=print_override to None, and remove the import if unused.
- Assistant
Remove the unused import of print_override from runtime.py
- Assistant
Good. Now update the test helper.
- Assistant
The first edit to remove the import worked. The second replace may have failed because path context changed. Let me check the file.
- Assistant
Still has print_override reference but import was removed - need to fix that line.
- Assistant
Verifying with a kernel-level reproduction for Numba and thread printing.
- Assistant
Thread and print_override tests passed. Next I'll verify Numba and concurrent thread isolation with a temporary script.
- Assistant
There might be an error with numba. Let me debug.
- Assistant
I introduced typos in the script. Let me rewrite carefully.
- Assistant
Numba failed due to NumPy compatibility, not print. I'll pin compatible versions and retest.
- Assistant
Hmm uv run might use a differentenv. Let me check.
- Assistant
Need to force reinstall numpy 2.4
- Assistant
Good. Now retest.
- Assistant
uv run keeps reinstalling packages — I'll use the venv Python to pin versions and retest.
- Assistant
uv run reinstalled numpy 2.5 again. Let me force pin and run without uv.
- Assistant
Use uv pip install and then bazel run tе with paths.
- Assistant
Confirming MockStream shares the pipe; concurrent isolation still looks correct. Checking docstring formatting and any leftover issues.
- Assistant
AGENTS.md requires single backticks in docstrings — fixing those now.
- Assistant
Checking that ScriptRuntimeContext.globals works with install:
- Assistant
Hardening install so script mode also patches
__main__. - Assistant
I introduced typos accidentally — fixing the file cleanly.
- Assistant
There's a missing space in "print),or" - minor. Fix it.
- Assistant
Re-running the tests to confirm everything still works.
- Assistant
Typo in command. Tests passed. Let me rerun numba script.
- Assistant
I'll clean up the temp file and review the final diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.