Live terminal output#5396
Conversation
Hijacks stderr/stdout to send all output data to the client on flush
huchenlei
left a comment
There was a problem hiding this comment.
LGTM! @comfyanonymous PTAL
|
There's an issue with this on Linux where if I add some prints in the code I only see them after I ctrl-c comfyui. |
|
I'm not able to reproduce using WSL2, are you getting no log output at all? |
|
I add a print here for example: https://github.com/comfyanonymous/ComfyUI/blob/master/comfy/ops.py#L67 |
| # else logs just get full of progress messages | ||
| if isinstance(data, str) and data.startswith("\r") and not logs[-1]["m"].endswith("\n"): | ||
| logs.pop() | ||
| logs.append(entry) |
There was a problem hiding this comment.
Seems here the handling of progress messages is altering original terminal behavior.
|
Ref on ComfyUI-Manager's log setup: |
Context: During the debug session, we observed if we have print statement printing stuffs while the progress bar is being actively updated, some logs are not properly output. They are flushed out only when pressing Ctrl+C. |
|
After a bunch of investigating, the fix here was to set the |
Using Jupyter Notebook + real mode / standalone virtual mode together is broken due to a recent change in ComfyUI. This commit works around it. Comfy-Org/ComfyUI#5396 ipython/ipykernel#786
* Add /logs/raw and /logs/subscribe for getting logs on frontend Hijacks stderr/stdout to send all output data to the client on flush * Use existing send sync method * Fix get_logs should return string * Fix bug * pass no server * fix tests * Fix output flush on linux
This updates the logging from using a MemoryHandler to overriding stdout/stderr in order to obtain all outputs, including progress bars. (Previously done here #4664)
Adds two new endpoints for the frontend
GET
/internal/logs/raw- returns an array of the last 300 raw stdout/stderr entries and their timestamps, and the size of the terminal (required for accurate rendering)POST
/internal/logs/subscribe- Body:clientId: the socket id,enabled: if logs are being subscribed to send via websocket in a new eventlogs.The format of
/internal/logshas slightly changed as it is no longer formatted vialoggingbut just the outputs.The
logsevent contains any entries since last flush and the terminal size if it has changed.Events are only sent via the websocket when a client is subscribed to reduce unnecessary traffic.