mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-12-24 13:28:13 +08:00
[BugFix] fix work metrics not returned by metrics api (#4912)
* [BugFix] fix work metrics not returned by metrics api * [fix] fix conflict * [fix] fix ci
This commit is contained in:
@@ -184,27 +184,17 @@ def test_config_info_process_object_branches():
|
||||
assert "without_dict" in data and data["without_dict"] is None
|
||||
|
||||
|
||||
def test_setup_metrics_environment_sets_env_var(tmp_path):
|
||||
# Cover calling setup_metrics_environment()
|
||||
with (
|
||||
patch("fastdeploy.utils.FlexibleArgumentParser.parse_args") as mock_parse_args,
|
||||
patch("fastdeploy.utils.retrive_model_from_server") as mock_retrive_model,
|
||||
patch("fastdeploy.entrypoints.chat_utils.load_chat_template") as mock_load_template,
|
||||
):
|
||||
mock_parse_args.return_value = _build_mock_args()
|
||||
mock_retrive_model.return_value = "test-model"
|
||||
mock_load_template.return_value = None
|
||||
def test_setup_metrics_environment_sets_env_var():
|
||||
# Cover 'fastdeploy/__init__.py'
|
||||
import fastdeploy
|
||||
|
||||
from fastdeploy.entrypoints.openai import api_server as api_server_mod
|
||||
|
||||
api_server = importlib.reload(api_server_mod)
|
||||
|
||||
desired_dir = str(tmp_path / "prom_multiproc")
|
||||
|
||||
# Patch the name imported into api_server so we don't touch real FS
|
||||
with patch("fastdeploy.entrypoints.openai.api_server.cleanup_prometheus_files", return_value=desired_dir):
|
||||
api_server.setup_metrics_environment()
|
||||
assert os.environ.get("PROMETHEUS_MULTIPROC_DIR") == desired_dir
|
||||
# clear PROMETHEUS_MULTIPROC_DIR
|
||||
os.environ.pop("PROMETHEUS_MULTIPROC_DIR")
|
||||
# reload fastdeploy
|
||||
assert os.environ.get("PROMETHEUS_MULTIPROC_DIR") is None
|
||||
importlib.reload(fastdeploy)
|
||||
# check if PROMETHEUS_MULTIPROC_DIR is reinitialized
|
||||
assert os.environ.get("PROMETHEUS_MULTIPROC_DIR").startswith("/tmp/fd_prom")
|
||||
|
||||
|
||||
def test_metrics_app_routes_when_metrics_port_diff():
|
||||
|
||||
Reference in New Issue
Block a user