This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into fix_poetry_cache
- Loading branch information
Showing
9 changed files
with
65 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import os | ||
|
||
import pytest | ||
import yaml | ||
|
||
from resin.chat_engine import ChatEngine | ||
from resin.context_engine import ContextEngine | ||
from resin.knowledge_base import KnowledgeBase | ||
|
||
DEFAULT_COFIG_PATH = 'config/config.yaml' | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def temp_index_name(): | ||
index_name_before = os.getenv("INDEX_NAME", None) | ||
|
||
os.environ["INDEX_NAME"] = "temp_index" | ||
yield "temp_index" | ||
|
||
if index_name_before is None: | ||
del os.environ["INDEX_NAME"] | ||
else: | ||
os.environ["INDEX_NAME"] = index_name_before | ||
|
||
|
||
def test_default_config_matches_code_defaults(temp_index_name): | ||
with open(DEFAULT_COFIG_PATH) as f: | ||
default_config = yaml.safe_load(f) | ||
chat_engine_config = default_config['chat_engine'] | ||
|
||
loaded_chat_engine = ChatEngine.from_config(chat_engine_config) | ||
default_kb = KnowledgeBase(index_name=temp_index_name) | ||
default_context_engine = ContextEngine(default_kb) | ||
default_chat_engine = ChatEngine(default_context_engine) | ||
|
||
def assert_identical_components(loaded_component, default_component): | ||
assert type(loaded_component) == type(default_component) # noqa: E721 | ||
if not loaded_component.__module__.startswith("resin"): | ||
return | ||
|
||
for key, value in default_component.__dict__.items(): | ||
assert hasattr(loaded_component, key), ( | ||
f"Missing attribute {key} in {type(loaded_component)}" | ||
) | ||
if hasattr(value, '__dict__'): | ||
assert_identical_components(getattr(loaded_component, key), value) | ||
else: | ||
assert getattr(loaded_component, key) == value, ( | ||
f"Attribute {key} in {type(loaded_component)} is {value} in code " | ||
f"but {getattr(loaded_component, key)} in config" | ||
) | ||
|
||
assert_identical_components(loaded_chat_engine, default_chat_engine) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# noqa: F405 | ||
|
||
import pytest | ||
|
||
from ._stub_classes import (BaseStubChunker, StubChunker, StubKB, | ||
|