-
Notifications
You must be signed in to change notification settings - Fork 25
Leads 212 remove unittest mocking #148
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
Open
xmican10
wants to merge
4
commits into
lightspeed-core:main
Choose a base branch
from
xmican10:LEADS-212-remove-unittest-mocking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,12 @@ | ||
| { | ||
| "reportAttributeAccessIssue": "warning", | ||
| "executionEnvironments": [ | ||
| { | ||
| "root": "tests", | ||
| "reportAttributeAccessIssue": "none", | ||
| "extraPaths": [ | ||
| "." | ||
| ] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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 @@ | ||
| """Script utilities for lightspeed-evaluation.""" |
This file contains hidden or 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 hidden or 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 hidden or 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,9 @@ | ||
| """Pytest configuration and fixtures for lightspeed-evaluation tests.""" | ||
|
|
||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| # Add project root to Python path so we can import from script directory | ||
| project_root = Path(__file__).parent.parent | ||
| if str(project_root) not in sys.path: | ||
| sys.path.insert(0, str(project_root)) |
This file contains hidden or 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,214 @@ | ||
| # pylint: disable=redefined-outer-name | ||
|
|
||
| """Pytest configuration and fixtures for script tests.""" | ||
|
|
||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| import pytest | ||
| import yaml | ||
|
|
||
| from script.run_multi_provider_eval import MultiProviderEvaluationRunner | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def script_path() -> Path: | ||
| """Return the path to the compare_evaluations.py script.""" | ||
| # Test is in tests/script/, script is in project_root/script/ | ||
| return Path(__file__).parent.parent.parent / "script" / "compare_evaluations.py" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sample_evaluation_data() -> tuple[list[dict], list[dict]]: | ||
| """Return sample evaluation data for testing.""" | ||
| sample_results1 = [ | ||
| { | ||
| "conversation_group_id": "conv1", | ||
| "turn_id": "1", | ||
| "metric_identifier": "ragas:faithfulness", | ||
| "result": "PASS", | ||
| "score": 0.8, | ||
| "threshold": 0.7, | ||
| "execution_time": 1.0, | ||
| }, | ||
| { | ||
| "conversation_group_id": "conv1", | ||
| "turn_id": "2", | ||
| "metric_identifier": "ragas:faithfulness", | ||
| "result": "PASS", | ||
| "score": 0.9, | ||
| "threshold": 0.7, | ||
| "execution_time": 1.2, | ||
| }, | ||
| ] | ||
|
|
||
| sample_results2 = [ | ||
| { | ||
| "conversation_group_id": "conv1", | ||
| "turn_id": "1", | ||
| "metric_identifier": "ragas:faithfulness", | ||
| "result": "PASS", | ||
| "score": 0.85, | ||
| "threshold": 0.7, | ||
| "execution_time": 1.1, | ||
| }, | ||
| { | ||
| "conversation_group_id": "conv1", | ||
| "turn_id": "2", | ||
| "metric_identifier": "ragas:faithfulness", | ||
| "result": "FAIL", | ||
| "score": 0.6, | ||
| "threshold": 0.7, | ||
| "execution_time": 1.0, | ||
| }, | ||
| ] | ||
|
|
||
| return sample_results1, sample_results2 | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def temp_config_files(tmp_path: Path) -> dict: | ||
| """Create temporary configuration files for testing.""" | ||
| # Create multi_eval_config.yaml | ||
| providers_config = { | ||
| "providers": { | ||
| "openai": { | ||
| "models": ["gpt-4o-mini", "gpt-4-turbo"], | ||
| }, | ||
| "watsonx": { | ||
| "models": ["ibm/granite-13b-chat-v2"], | ||
| }, | ||
| }, | ||
| "settings": {"output_base": str(tmp_path / "eval_output")}, | ||
| } | ||
| providers_path = tmp_path / "multi_eval_config.yaml" | ||
| with open(providers_path, "w", encoding="utf-8") as f: | ||
| yaml.dump(providers_config, f) | ||
|
|
||
| # Create system.yaml | ||
| system_config = { | ||
| "llm": { | ||
| "provider": "openai", | ||
| "model": "gpt-4o-mini", | ||
| "temperature": 0.0, | ||
| }, | ||
| "api": {"enabled": False}, | ||
| "output": {"output_dir": "./eval_output"}, | ||
| } | ||
| system_path = tmp_path / "system.yaml" | ||
| with open(system_path, "w", encoding="utf-8") as f: | ||
| yaml.dump(system_config, f) | ||
|
|
||
| # Create evaluation_data.yaml | ||
| eval_data = [ | ||
| { | ||
| "conversation_group_id": "test_conv", | ||
| "turns": [ | ||
| { | ||
| "turn_id": "turn_1", | ||
| "query": "Test query", | ||
| "response": "Test response", | ||
| "contexts": ["Context 1"], | ||
| "expected_response": "Expected", | ||
| "turn_metrics": ["ragas:response_relevancy"], | ||
| } | ||
| ], | ||
| } | ||
| ] | ||
| eval_path = tmp_path / "evaluation_data.yaml" | ||
| with open(eval_path, "w", encoding="utf-8") as f: | ||
| yaml.dump(eval_data, f) | ||
|
|
||
| return { | ||
| "providers_config": providers_path, | ||
| "system_config": system_path, | ||
| "eval_data": eval_path, | ||
| "output_dir": tmp_path / "eval_output", | ||
| } | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def runner( | ||
| temp_config_files: dict, | ||
| ) -> MultiProviderEvaluationRunner: | ||
| """Create a MultiProviderEvaluationRunner instance for testing.""" | ||
| return MultiProviderEvaluationRunner( | ||
| providers_config_path=str(temp_config_files["providers_config"]), | ||
| system_config_path=str(temp_config_files["system_config"]), | ||
| eval_data_path=str(temp_config_files["eval_data"]), | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sample_evaluation_summary() -> dict[str, Any]: | ||
| """Create a sample evaluation summary JSON for testing analysis.""" | ||
| return { | ||
| "timestamp": "2025-01-01T12:00:00", | ||
| "total_evaluations": 10, | ||
| "summary_stats": { | ||
| "overall": { | ||
| "TOTAL": 10, | ||
| "PASS": 8, | ||
| "FAIL": 2, | ||
| "ERROR": 0, | ||
| "pass_rate": 80.0, # Percentage format | ||
| "fail_rate": 20.0, | ||
| "error_rate": 0.0, | ||
| }, | ||
| "by_metric": { | ||
| "ragas:faithfulness": { | ||
| "pass": 4, | ||
| "fail": 0, | ||
| "error": 0, | ||
| "pass_rate": 100.0, | ||
| "fail_rate": 0.0, | ||
| "error_rate": 0.0, | ||
| "score_statistics": { | ||
| "mean": 0.95, | ||
| "median": 0.95, | ||
| "std": 0.02, | ||
| "min": 0.92, | ||
| "max": 0.98, | ||
| "count": 4, | ||
| }, | ||
| }, | ||
| "ragas:response_relevancy": { | ||
| "pass": 4, | ||
| "fail": 2, | ||
| "error": 0, | ||
| "pass_rate": 66.67, | ||
| "fail_rate": 33.33, | ||
| "error_rate": 0.0, | ||
| "score_statistics": { | ||
| "mean": 0.75, | ||
| "median": 0.78, | ||
| "std": 0.12, | ||
| "min": 0.55, | ||
| "max": 0.88, | ||
| "count": 6, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| "results": [ | ||
| { | ||
| "conversation_group_id": "conv1", | ||
| "turn_id": "turn1", | ||
| "metric_identifier": "ragas:faithfulness", | ||
| "result": "PASS", | ||
| "score": 0.95, | ||
| "threshold": 0.8, | ||
| "execution_time": 1.0, | ||
| }, | ||
| { | ||
| "conversation_group_id": "conv1", | ||
| "turn_id": "turn2", | ||
| "metric_identifier": "ragas:response_relevancy", | ||
| "result": "PASS", | ||
| "score": 0.85, | ||
| "threshold": 0.7, | ||
| "execution_time": 1.2, | ||
| }, | ||
| ] | ||
| * 5, # Repeat to get 10 results | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the pylint suppression for
redefined-outer-name.Line 1 disables a lint rule; please fix the underlying naming issue instead of suppressing it.
As per coding guidelines: Do not disable lint warnings with # noqa, # type: ignore, or # pylint: disable comments - fix the underlying issue instead.
🤖 Prompt for AI Agents