Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .hydra_config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defaults:
- _self_ # TODO: Silences the hydra version migration warning (PLEASE REVIEW FOR BREAKING CHANGES)
- _self_
- chunker: ${oc.env:CHUNKER, recursive_splitter} # recursive_splitter
- retriever: ${oc.env:RETRIEVER_TYPE, single} # single # multiQuery # hyde
- rag: ChatBotRag
Expand Down
4 changes: 2 additions & 2 deletions openrag/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def load_config(config_path=CONFIG_PATH, overrides=None) -> OmegaConf:
if GlobalHydra.instance().is_initialized():
GlobalHydra.instance().clear()

# TODO: I set the version base to 1.1 to silence the warning message, review how we want to handle versioning
with initialize_config_dir(config_dir=str(config_path), job_name="config_loader", version_base="1.1"):
# version_base=None uses current Hydra version defaults (forward compatible)
with initialize_config_dir(config_dir=str(config_path), job_name="config_loader", version_base=None):
config = compose(config_name="config", overrides=overrides)

config.paths.data_dir = Path(config.paths.data_dir).resolve()
Expand Down
44 changes: 44 additions & 0 deletions openrag/config/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import warnings

from config import load_config


def test_config_loads_successfully():
"""Verify config loads and returns expected structure."""
config = load_config()

assert config is not None
assert hasattr(config, "llm")
assert hasattr(config, "embedder")
assert hasattr(config, "vectordb")
assert hasattr(config, "paths")
assert hasattr(config, "loader")


def test_config_critical_values_unchanged():
"""Verify critical config values match expected defaults."""
config = load_config()

# LLM settings
assert config.llm.temperature == 0.1

# Embedder settings
assert config.embedder.provider == "openai"

# Vectordb settings (note: hybrid_search is a string 'True' due to oc.env without oc.decode)
assert config.vectordb.hybrid_search == 'True'

# Loader settings (boolean because it uses oc.decode)
assert config.loader.image_captioning is True


def test_config_no_hydra_version_warnings():
"""Verify no version_base warnings are emitted during config loading."""
with warnings.catch_warnings(record=True) as captured_warnings:
warnings.simplefilter("always")
load_config()

# Check no warnings contain "version_base"
for warning in captured_warnings:
assert "version_base" not in str(warning.message).lower(), \
f"Unexpected version_base warning: {warning.message}"
58 changes: 58 additions & 0 deletions openrag/routers/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import warnings

import consts
import pytest


def test_legacy_prefix_emits_deprecation_warning():
"""Verify legacy 'ragondin-' prefix triggers DeprecationWarning."""
# Test the warning logic directly without full function import
# This simulates the code path in get_partition_name for legacy prefix

model_name = "ragondin-test_partition"

# Use pytest.warns to verify DeprecationWarning is emitted
with pytest.warns(DeprecationWarning, match="deprecated"):
# Replicate the warning logic from get_partition_name
if model_name.startswith(consts.LEGACY_PARTITION_PREFIX):
warnings.warn(
f"The partition prefix '{consts.LEGACY_PARTITION_PREFIX}' is deprecated "
f"and will be removed in a future version. "
f"Please update your model names to use '{consts.PARTITION_PREFIX}' instead. "
f"Example: '{consts.LEGACY_PARTITION_PREFIX}mypartition' -> '{consts.PARTITION_PREFIX}mypartition'",
DeprecationWarning,
stacklevel=2,
)


def test_current_prefix_no_deprecation_warning():
"""Verify current 'openrag-' prefix does NOT trigger DeprecationWarning."""
model_name = "openrag-test_partition"

# Capture all warnings
with warnings.catch_warnings(record=True) as captured_warnings:
warnings.simplefilter("always")

# Replicate the condition check from get_partition_name
partition_prefix = consts.PARTITION_PREFIX
if model_name.startswith(consts.LEGACY_PARTITION_PREFIX):
warnings.warn(
f"The partition prefix '{consts.LEGACY_PARTITION_PREFIX}' is deprecated "
f"and will be removed in a future version. "
f"Please update your model names to use '{consts.PARTITION_PREFIX}' instead. "
f"Example: '{consts.LEGACY_PARTITION_PREFIX}mypartition' -> '{consts.PARTITION_PREFIX}mypartition'",
DeprecationWarning,
stacklevel=2,
)
partition_prefix = consts.LEGACY_PARTITION_PREFIX

# Verify the warning was NOT triggered (model starts with current prefix)
assert partition_prefix == consts.PARTITION_PREFIX

# Verify no DeprecationWarning was emitted
deprecation_warnings = [
w for w in captured_warnings
if issubclass(w.category, DeprecationWarning)
]
assert len(deprecation_warnings) == 0, \
f"Unexpected DeprecationWarning(s): {[str(w.message) for w in deprecation_warnings]}"
10 changes: 9 additions & 1 deletion openrag/routers/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import warnings
from pathlib import Path
from typing import Any

Expand Down Expand Up @@ -286,7 +287,14 @@ async def get_partition_name(model_name, user_partitions, is_admin=False):

partition_prefix = consts.PARTITION_PREFIX
if model_name.startswith(consts.LEGACY_PARTITION_PREFIX):
# XXX - This is for backward compatibility, but should eventually be removed
warnings.warn(
f"The partition prefix '{consts.LEGACY_PARTITION_PREFIX}' is deprecated "
f"and will be removed in a future version. "
f"Please update your model names to use '{consts.PARTITION_PREFIX}' instead. "
f"Example: '{consts.LEGACY_PARTITION_PREFIX}mypartition' -> '{consts.PARTITION_PREFIX}mypartition'",
DeprecationWarning,
stacklevel=2,
)
partition_prefix = consts.LEGACY_PARTITION_PREFIX

if not model_name.startswith(partition_prefix):
Expand Down