Files
vllm-omni/vllm_omni/config/__init__.py
T
hsliu 154d9ca4ff Initial vLLM-omni repository structure
- Add complete directory structure for multimodal and non-autoregressive processing
- Include AsyncLLM, OmniEngine, and DiffusionEngine modules
- Add processors, schedulers, executors, and output processors
- Add API interfaces for Higress, Gradio, and ComfyUI
- Add configuration management and CLI interface
- Add comprehensive test structure and documentation
- Add pyproject.toml with dependencies and project configuration
- Add examples and documentation structure
2025-09-11 14:32:51 +08:00

74 lines
1.9 KiB
Python

"""
Configuration management for vLLM-omni.
"""
import os
import yaml
from pathlib import Path
from typing import Dict, Any, Optional
def load_config(config_path: Optional[str] = None) -> Dict[str, Any]:
"""
Load configuration from file or use defaults.
Args:
config_path: Path to configuration file. If None, loads default config.
Returns:
Configuration dictionary.
"""
if config_path is None:
config_path = os.path.join(
Path(__file__).parent.parent.parent,
"configs",
"default.yaml"
)
config_path = Path(config_path)
if not config_path.exists():
raise FileNotFoundError(f"Configuration file not found: {config_path}")
with open(config_path, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
return config
def save_config(config: Dict[str, Any], config_path: str) -> None:
"""
Save configuration to file.
Args:
config: Configuration dictionary to save.
config_path: Path where to save the configuration.
"""
config_path = Path(config_path)
config_path.parent.mkdir(parents=True, exist_ok=True)
with open(config_path, 'w', encoding='utf-8') as f:
yaml.dump(config, f, default_flow_style=False, indent=2)
def merge_configs(base_config: Dict[str, Any], override_config: Dict[str, Any]) -> Dict[str, Any]:
"""
Merge two configuration dictionaries.
Args:
base_config: Base configuration.
override_config: Configuration to override with.
Returns:
Merged configuration dictionary.
"""
merged = base_config.copy()
for key, value in override_config.items():
if key in merged and isinstance(merged[key], dict) and isinstance(value, dict):
merged[key] = merge_configs(merged[key], value)
else:
merged[key] = value
return merged