Refact: sandbox quickstart.md & add tutorial for code exec component (#14786)

### What problem does this PR solve?

Refact: sandbox quickstart.md && add tutorial for code exec component

### Type of change

- [x] Refactoring


<img width="700" alt="img_v3_0211j_dcff835b-e3bb-4c77-9bc5-3b31a983229g"
src="https://github.com/user-attachments/assets/7842fc0f-639a-458f-b164-bc81a99ce4a5"
/>

---------

Co-authored-by: writinwaters <93570324+writinwaters@users.noreply.github.com>
This commit is contained in:
Magicbook1108
2026-05-12 14:42:20 +08:00
committed by GitHub
parent e8adc977bd
commit f85e18afbc
4 changed files with 125 additions and 8 deletions

View File

@@ -41,6 +41,15 @@ ALLOWED_ARTIFACT_EXTENSIONS = {
".svg",
}
LOCAL_PYTHON_THREAD_ENV_VARS = (
"OPENBLAS_NUM_THREADS",
"OMP_NUM_THREADS",
"MKL_NUM_THREADS",
"NUMEXPR_NUM_THREADS",
"BLIS_NUM_THREADS",
"VECLIB_MAXIMUM_THREADS",
)
def _env_enabled(name: str) -> bool:
return os.environ.get(name, "").strip().lower() in {"1", "true", "yes", "on"}
@@ -226,13 +235,18 @@ class LocalProvider(SandboxProvider):
return os.environ.get(env_name, default)
def _build_child_env(self, instance_dir: Path) -> dict[str, str]:
return {
env = {
"HOME": str(instance_dir),
"MPLBACKEND": "Agg",
"PATH": os.environ.get("PATH", ""),
"PYTHONUNBUFFERED": "1",
"TMPDIR": str(instance_dir),
}
for name in LOCAL_PYTHON_THREAD_ENV_VARS:
value = os.environ.get(name)
if value is not None:
env[name] = value
return env
def _limit_child_process(self) -> None:
import resource