feat(backends/python): use tempfile.gettempdir() instead of hardcoded /tmp (#9629)

Closes #9601

Makes the temporary scratch paths in vllm, vllm-omni, tinygrad, and pocket-tts
backends configurable via the standard TMPDIR env var, instead of always writing
to /tmp. This is a one-line change per call site that calls tempfile.gettempdir()
for the directory and keeps the same filename suffix.

Users who run on systems with a small root partition (or want to relocate scratch
files to a larger volume) can now redirect these by setting TMPDIR
(e.g. TMPDIR=/data/tmp), without affecting the existing LOCALAI_GENERATED_CONTENT_PATH
or LOCALAI_UPLOAD_PATH options that already cover other temp paths.

Files touched:
- backend/python/vllm/backend.py        (1 site: video base64 scratch)
- backend/python/tinygrad/backend.py    (1 site: image fallback dst)
- backend/python/pocket-tts/backend.py  (1 site: tts wav fallback dst)
- backend/python/vllm-omni/backend.py   (2 sites: video + audio scratch)
This commit is contained in:
Tai An
2026-05-01 01:56:24 -07:00
committed by GitHub
parent 9c4c3f9d8f
commit 80961d2da6
4 changed files with 9 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ import argparse
import signal
import sys
import os
import tempfile
import traceback
import scipy.io.wavfile
import backend_pb2
@@ -204,7 +205,7 @@ class BackendServicer(backend_pb2_grpc.BackendServicer):
# Save audio to file
output_path = request.dst
if not output_path:
output_path = "/tmp/pocket-tts-output.wav"
output_path = os.path.join(tempfile.gettempdir(), "pocket-tts-output.wav")
# Ensure output directory exists
output_dir = os.path.dirname(output_path)