|
| 1 | +# Copyright 2025 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# pylint: disable=protected-access,bad-continuation,missing-function-docstring |
| 16 | + |
| 17 | +from tests.unit.vertexai.genai.replays import pytest_helper |
| 18 | +from vertexai._genai import types |
| 19 | + |
| 20 | + |
| 21 | +def test_batch_eval(client): |
| 22 | + eval_dataset = types.EvaluationDataset( |
| 23 | + gcs_source=types.GcsSource( |
| 24 | + uris=["gs://genai-eval-sdk-replay-test/test_data/inference_results.jsonl"] |
| 25 | + ) |
| 26 | + ) |
| 27 | + |
| 28 | + batch_eval_operation = client.evals.batch_evaluate( |
| 29 | + dataset=eval_dataset, |
| 30 | + metrics=[ |
| 31 | + types.PrebuiltMetric.TEXT_QUALITY, |
| 32 | + ], |
| 33 | + dest="gs://genai-eval-sdk-replay-test/test_data/batch_eval_output", |
| 34 | + ) |
| 35 | + assert "operations" in batch_eval_operation.name |
| 36 | + assert "EvaluateDatasetOperationMetadata" in batch_eval_operation.metadata.get( |
| 37 | + "@type" |
| 38 | + ) |
| 39 | + |
| 40 | + |
| 41 | +pytestmark = pytest_helper.setup( |
| 42 | + file=__file__, |
| 43 | + globals_for_file=globals(), |
| 44 | + test_method="evals.batch_evaluate", |
| 45 | +) |
0 commit comments