Ray Log Notebook
This is a tiny FIX for Ray to display logs under the last executed cell instead of ray.init() cell.
Q: Why would this happen?
A: Ipykernel captures thread output and redir to the cell where thread is created.
This is desired in some scenarios, but definitely not for Ray, whose logging thread
is created upon ray.init() initialization.
Q: How can you fix this?
A: Utilizing IPython Events and mock Ray's internal log event handler.
This may be unstable because we depend on Ray's non-public API.
In normal mode, Ray would log by emitting logs to global_worker_stdstream_dispatcher,
replacing the original handler with ours just works.
For client mode, things get trickier. client_worker's LogStreamClient log_client
would receive remote log stream by gRPC and print to stdout/stderr.
We directly mock replace the stdstream method of that LogStreamClient instance.
There may be more robust and non-intrusive ways to do it,
for example capturing the ray.init()
cell output.
Q: How can I use this? A: As simple as:
% cell 1
import ray
ray.init()
% cell 2
import ray_log_notebook
ray_log_notebook.enable()
% cell 3
@ray.remote
def test_print():
print("Woola!")
await test_print.remote()
Logs will always go to the last executed cell, instead of where the Ray Tasks are created.
Tested on Python 3.13 and Ray 2.50.0, generally should work but I don't have much time to test.
Metadata
Release files for ray-log-notebook 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ray_log_notebook-0.0.1.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ray_log_notebook-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.5 kB
Release files / ray_log_notebook-0.0.1.tar.gz
| Download URL | ray_log_notebook-0.0.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08479b73309774d5937efba19c9296da122250cf8dcbaec93b7c51171fc01e1f
|
|
BLAKE2b-256 checksum How to use checksums |
c83318a08d363f28a04b66cee2a26c955a967f6a443fa40a9af9f90e45655fd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.3
|
Release files / ray_log_notebook-0.0.1-py3-none-any.whl
| Download URL | ray_log_notebook-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32f6208b692cf6f5feaa5fe75adf0332f43f5465a9d2c6433cd1270234a9a97a
|
|
BLAKE2b-256 checksum How to use checksums |
9c02820ba7904b34eb85bf64d0f27187915ea7c240c67414fefb3fe4f5277737
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.3
|