mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 01:19:31 +08:00
The exec sandbox has no GUI session, so Figure.show() can block until the tool timeout. schemdraw's Drawing defaults to show=True and calls show() on context exit even after save(), which makes a successfully saved plot look like a timed-out execution. Pin MPLBACKEND=Agg for model-authored programs. Co-Authored-By: Claude Code <noreply@anthropic.com>
19 lines
746 B
Python
19 lines
746 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from deeptutor.services.workspace.execution import prepare_workspace_execution_env
|
|
|
|
|
|
def test_execution_environment_forces_headless_matplotlib(tmp_path: Path) -> None:
|
|
"""A GUI backend would block on show() in the display-less exec sandbox.
|
|
|
|
schemdraw's ``Drawing`` defaults to ``show=True``; its context manager
|
|
calls ``fig.show()`` on exit even after the figure was saved. Without a
|
|
non-interactive backend that call waits for a window server until the exec
|
|
timeout kills the process, so the saved plot never reaches the user.
|
|
"""
|
|
env = prepare_workspace_execution_env(tmp_path / "outputs" / "chat" / "s" / "turn")
|
|
|
|
assert env["MPLBACKEND"] == "Agg"
|