From 20cf2f553c223792ad3f65236b267586fa9bed6c Mon Sep 17 00:00:00 2001 From: Shawn Du Date: Mon, 11 Nov 2024 07:21:06 +0800 Subject: [PATCH] [Misc] small fixes to function tracing file path (#9543) Signed-off-by: Shawn Du Signed-off-by: youkaichao Co-authored-by: youkaichao --- docs/source/index.rst | 4 ++-- vllm/logger.py | 5 +++-- vllm/utils.py | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 8457d4476a1c4..00d455ed9ad44 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -161,11 +161,11 @@ Documentation design/multimodal/multimodal_index design/huggingface_integration -.. Contributing: contributing to the vLLM project +.. For Developers: contributing to the vLLM project .. toctree:: :maxdepth: 2 - :caption: Contributing + :caption: For Developers contributing/overview contributing/profiling/profiling_index diff --git a/vllm/logger.py b/vllm/logger.py index 80b9fcc59272d..9e16e591315ba 100644 --- a/vllm/logger.py +++ b/vllm/logger.py @@ -117,13 +117,14 @@ def _trace_calls(log_path, root_dir, frame, event, arg=None): last_lineno = 0 last_func_name = "" with open(log_path, 'a') as f: + ts = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f") if event == 'call': - f.write(f"{datetime.datetime.now()} Call to" + f.write(f"{ts} Call to" f" {func_name} in {filename}:{lineno}" f" from {last_func_name} in {last_filename}:" f"{last_lineno}\n") else: - f.write(f"{datetime.datetime.now()} Return from" + f.write(f"{ts} Return from" f" {func_name} in {filename}:{lineno}" f" to {last_func_name} in {last_filename}:" f"{last_lineno}\n") diff --git a/vllm/utils.py b/vllm/utils.py index 13d7f6d475346..1b02cbff79f78 100644 --- a/vllm/utils.py +++ b/vllm/utils.py @@ -4,6 +4,7 @@ import contextlib import datetime import enum import gc +import getpass import inspect import ipaddress import os @@ -967,6 +968,8 @@ def enable_trace_function_call_for_thread() -> None: if envs.VLLM_TRACE_FUNCTION: tmp_dir = tempfile.gettempdir() + # add username to tmp_dir to avoid permission issues + tmp_dir = os.path.join(tmp_dir, getpass.getuser()) filename = (f"VLLM_TRACE_FUNCTION_for_process_{os.getpid()}" f"_thread_{threading.get_ident()}_" f"at_{datetime.datetime.now()}.log").replace(" ", "_")