mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
Merge https://github.com/google/adk-python/pull/3402 This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling) Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes. ### Testing Plan The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/19056081305/attempts/1#summary-54426435973 The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/19056081446/attempts/1#summary-54426436321 **Unit Tests:** - [ ] I have added or updated unit tests for my change. - [ ] All unit tests pass locally. _Please include a summary of passed `pytest` results._ **Manual End-to-End (E2E) Tests:** _Please provide instructions on how to manually test your changes, including any necessary setup or configuration. Please provide logs or screenshots to help reviewers better understand the fix._ ### Checklist - [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document. - [x] I have performed a self-review of my own code. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] New and existing unit tests pass locally with my changes. - [ ] I have manually tested my changes end-to-end. - [ ] Any dependent changes have been merged and published in downstream modules. ### Additional context - https://github.com/google/adk-python/pull/3382#issuecomment-3488654110 Co-authored-by: Liang Wu <wuliang@google.com> COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3402 from jsoref:spelling-tests 3cf0439d0584e4557179c25596aadf3b5b7c3fa8 PiperOrigin-RevId: 829035089
72 lines
2.4 KiB
Python
72 lines
2.4 KiB
Python
# Copyright 2025 Google LLC
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
"""Evaluate all agents in fixture folder if evaluation test files exist."""
|
|
|
|
import os
|
|
|
|
from google.adk.evaluation.agent_evaluator import AgentEvaluator
|
|
import pytest
|
|
|
|
|
|
def agent_eval_artifacts_in_fixture():
|
|
"""Get all agents from fixture folder."""
|
|
agent_eval_artifacts = []
|
|
fixture_dir = os.path.join(os.path.dirname(__file__), 'fixture')
|
|
for agent_name in os.listdir(fixture_dir):
|
|
agent_dir = os.path.join(fixture_dir, agent_name)
|
|
if not os.path.isdir(agent_dir):
|
|
continue
|
|
for filename in os.listdir(agent_dir):
|
|
# Evaluation test files end with test.json
|
|
if not filename.endswith('test.json'):
|
|
continue
|
|
agent_eval_artifacts.append((
|
|
f'tests.integration.fixture.{agent_name}',
|
|
f'tests/integration/fixture/{agent_name}/{filename}',
|
|
))
|
|
|
|
# This method gets invoked twice, sorting helps ensure that both the
|
|
# invocations have the same view.
|
|
agent_eval_artifacts = sorted(
|
|
agent_eval_artifacts, key=lambda item: f'{item[0]}|{item[1]}'
|
|
)
|
|
return agent_eval_artifacts
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.parametrize(
|
|
'agent_name, evalfile',
|
|
agent_eval_artifacts_in_fixture(),
|
|
ids=[agent_name for agent_name, _ in agent_eval_artifacts_in_fixture()],
|
|
)
|
|
async def test_evaluate_agents_long_running_4_runs_per_eval_item(
|
|
agent_name, evalfile
|
|
):
|
|
"""Test agents evaluation in fixture folder.
|
|
|
|
After querying the fixture folder, we have 5 eval items. For each eval item
|
|
we use 4 runs.
|
|
|
|
A single eval item is a session that can have multiple queries in it.
|
|
"""
|
|
await AgentEvaluator.evaluate(
|
|
agent_module=agent_name,
|
|
eval_dataset_file_path_or_dir=evalfile,
|
|
# Using a slightly higher value helps us manage the variances that may
|
|
# happen in each eval.
|
|
# This, of course, comes at a cost of increased test run times.
|
|
num_runs=4,
|
|
)
|