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 handles print routing and
mo.Thread. - Assistant
I'll search the codebase for print routing and
mo.Threadimplementations. - Assistant
rg is not available, let me use grep.
- Assistant
Found the key files — inspecting print override and threads next.
- Assistant
I'll find where the print override is installed and review related tests.
- Assistant
Reviewing how patches install the print override and recent related changes.
- Assistant
Let me look at the relevant section of patches.py around print_override and create_main_module.
- Assistant
Checking thread-local streams and whether there's an existing fix attempt or related PR notes.
- Assistant
I'll reproduce the Numba interaction and search for related tests or notes.
- Assistant
Installing numba and inspecting how the main module wires print.
- Assistant
Let me use uv to install numba
- Assistant
Using uv to install numba
- Assistant
Checking related runtime code and whether script runners pass
print_override=Noneon purpose. - Assistant
Checking contexto storage and whether it's thread-local:
- Assistant
Implementing the fix: stop injecting print into the module namespace, and install the override on builtins only while mo.Thread is active.
- Assistant
Implementing print fix: keep builtin
printby default, and enable the override only whilemo.Threadis active. - Assistant
The edit hit the wrong file — restoring
types.pyand applying the change toprint_override.py. - Assistant
Good, now edit the correct file.
- Assistant
Updating
threads.pyand removing the main-module print injection. - Assistant
I need to update Thread.run to install/uninstall print override. To avoid circular imports at module level, I'll import install/uninstall inside run().
- Assistant
Now stop injecting print into the main module.
- Assistant
I'll leave the parameter for API compatibility but stop injecting
printinto the module namespace. - Assistant
Prefer a clearer unused-arg pattern, then run the relevant tests.
- Assistant
Running the print-override and thread tests, then verifying the Numba case.
- Assistant
All 14 passed. Verifying Numba with a kernel-like setup next.
- Assistant
Running a kernel-level integration check for Numba and thread print routing:
- Assistant
I had typos in the script — fixing and rerunning.
- Assistant
Checking how the session helper is exposed:
- Assistant
Let me use mocked_kernel_session
- Assistant
I'll write a clean temp script file to avoid further typos.
- Assistant
Cleaning up the unused-arg pattern and verifying the repo state.
- Assistant
Re-running the related tests once more for confidence.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.