diff --git a/src/guidellm/__init__.py b/src/guidellm/__init__.py index 9614dcdd8..f47157160 100644 --- a/src/guidellm/__init__.py +++ b/src/guidellm/__init__.py @@ -3,45 +3,31 @@ evaluating and benchmarking large language models (LLMs). """ -import contextlib -import logging -import os +import asyncio +import warnings -from datasets import config +# Configure uvloop if available +try: + import uvloop -with ( - open(os.devnull, "w") as devnull, # noqa: PTH123 - contextlib.redirect_stderr(devnull), - contextlib.redirect_stdout(devnull), -): - from transformers.utils import logging as hf_logging # type: ignore[import] - - # Set the log level for the transformers library to ERROR - # to ignore None of PyTorch, TensorFlow found - os.environ["TOKENIZERS_PARALLELISM"] = "false" # Silence warnings for tokenizers - hf_logging.set_verbosity_error() - logging.getLogger("transformers").setLevel(logging.ERROR) - config.USE_AUDIO_DECODE = False + asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) +except ImportError: + warnings.warn( + "uvloop is not installed. For improved performance, " + "consider installing the guidellm[perf] extras group.", + category=UserWarning, + stacklevel=2, + ) from .logger import configure_logger, logger from .settings import ( - DatasetSettings, - Environment, - LoggingSettings, - Settings, - print_config, reload_settings, settings, ) __all__ = [ - "DatasetSettings", - "Environment", - "LoggingSettings", - "Settings", "configure_logger", "logger", - "print_config", "reload_settings", "settings", ] diff --git a/src/guidellm/__main__.py b/src/guidellm/__main__.py index 85b7cfc0c..6ac241211 100644 --- a/src/guidellm/__main__.py +++ b/src/guidellm/__main__.py @@ -30,12 +30,7 @@ import click from pydantic import ValidationError -from guidellm.data import ShortPromptStrategy, process_dataset - -try: - import uvloop -except ImportError: - uvloop = None # type: ignore[assignment] # Optional dependency +from guidellm.data import ShortPromptStrategy, process_dataset # isort: skip import guidellm.utils.cli as cli_tools from guidellm.backends import Backend, BackendType @@ -497,8 +492,6 @@ def run(**kwargs): # noqa: C901 errs[0]["msg"], ctx=click.get_current_context(), param_hint=param_name ) from err - if uvloop is not None: - asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) asyncio.run( benchmark_generative_text( args=args, diff --git a/src/guidellm/settings.py b/src/guidellm/settings.py index 5ed07f01e..f16ac5b6c 100644 --- a/src/guidellm/settings.py +++ b/src/guidellm/settings.py @@ -2,15 +2,13 @@ import json from collections.abc import Sequence -from enum import Enum from typing import Literal -from pydantic import BaseModel, Field, model_validator +from pydantic import BaseModel, Field from pydantic_settings import BaseSettings, SettingsConfigDict __all__ = [ "DatasetSettings", - "Environment", "LoggingSettings", "Settings", "print_config", @@ -19,25 +17,6 @@ ] -class Environment(str, Enum): - """ - Enum for the supported environments - """ - - LOCAL = "local" - DEV = "dev" - STAGING = "staging" - PROD = "prod" - - -ENV_REPORT_MAPPING = { - Environment.PROD: "https://raw.githubusercontent.com/vllm-project/guidellm/refs/heads/gh-pages/ui/v0.5.4/index.html", - Environment.STAGING: "https://raw.githubusercontent.com/vllm-project/guidellm/refs/heads/gh-pages/ui/release/v0.4.0/index.html", - Environment.DEV: "https://raw.githubusercontent.com/vllm-project/guidellm/refs/heads/gh-pages/ui/dev/index.html", - Environment.LOCAL: "http://localhost:3000/index.html", -} - - class LoggingSettings(BaseModel): """ Logging settings for the application @@ -79,7 +58,7 @@ class ReportGenerationSettings(BaseModel): Report generation settings for the application """ - source: str = "" + source: str = "https://raw.githubusercontent.com/vllm-project/guidellm/refs/heads/gh-pages/ui/v0.5.4/index.html" class Settings(BaseSettings): @@ -103,7 +82,6 @@ class Settings(BaseSettings): ) # general settings - env: Environment = Environment.PROD default_async_loop_sleep: float = 10e-5 logging: LoggingSettings = LoggingSettings() default_sweep_number: int = 10 @@ -138,13 +116,6 @@ class Settings(BaseSettings): table_headers_border_char: str = "-" table_column_separator_char: str = "|" - @model_validator(mode="after") - @classmethod - def set_default_source(cls, values): - if not values.report_generation.source: - values.report_generation.source = ENV_REPORT_MAPPING.get(values.env) - return values - def generate_env_file(self) -> str: """ Generate the .env file from the current settings diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py index bb7f757fa..a9abf1152 100644 --- a/tests/unit/test_settings.py +++ b/tests/unit/test_settings.py @@ -2,7 +2,6 @@ from guidellm.settings import ( DatasetSettings, - Environment, LoggingSettings, ReportGenerationSettings, Settings, @@ -19,7 +18,6 @@ @pytest.mark.smoke def test_default_settings(): settings = Settings() - assert settings.env == Environment.PROD assert settings.logging == LoggingSettings() assert settings.report_generation.source.startswith(BASE_URL) @@ -29,36 +27,16 @@ def test_settings_from_env_variables(mocker): mocker.patch.dict( "os.environ", { - "GUIDELLM__env": "dev", "GUIDELLM__logging__disabled": "true", "GUIDELLM__REPORT_GENERATION__SOURCE": "http://custom.url", }, ) settings = Settings() - assert settings.env == Environment.DEV assert settings.logging.disabled is True assert settings.report_generation.source == "http://custom.url" -@pytest.mark.smoke -def test_report_generation_default_source(): - settings = Settings(env=Environment.LOCAL) - assert settings.report_generation.source == "http://localhost:3000/index.html" - - settings = Settings(env=Environment.DEV) - assert ( - settings.report_generation.source - == "https://raw.githubusercontent.com/vllm-project/guidellm/refs/heads/gh-pages/ui/dev/index.html" - ) - - settings = Settings(env=Environment.STAGING) - assert settings.report_generation.source.startswith(BASE_URL) - - settings = Settings(env=Environment.PROD) - assert settings.report_generation.source.startswith(BASE_URL) - - @pytest.mark.sanity def test_logging_settings(): logging_settings = LoggingSettings( @@ -90,12 +68,10 @@ def test_reload_settings(mocker): mocker.patch.dict( "os.environ", { - "GUIDELLM__env": "staging", "GUIDELLM__logging__disabled": "false", }, ) reload_settings() - assert settings.env == Environment.STAGING assert settings.logging.disabled is False