Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] Use from_env to initialize the configuration #47

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lmcache_vllm/vllm_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ def create_model_input_subset(
return model_input_subset


def lmcache_get_config() -> LMCacheEngineConfig:
"""Get the LMCache configuration from the environment variable
`LMCACHE_CONFIG_FILE`. If the environment variable is not set, this
function will return the default configuration.
"""
if hasattr(lmcache_get_config, "cached_config"):
return lmcache_get_config.cached_config

if "LMCACHE_CONFIG_FILE" not in os.environ:
logger.warn("No LMCache configuration file is set. Trying to read"
" configurations from the environment variables.")
logger.warn("You can set the configuration file through "
"the environment variable: LMCACHE_CONFIG_FILE")
config = LMCacheEngineConfig.from_env()
else:
config_file = os.environ["LMCACHE_CONFIG_FILE"]
logger.info(f"Loading LMCache config file {config_file}")
config = LMCacheEngineConfig.from_file(config_file)

lmcache_get_config.cached_config = config
return config


def lmcache_remove_request_id_indices(request_id):
Expand Down