Skip to content

Commit 15df1f6

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Allow EvalTask to take dataset as a Google sheet - simplifying rubric revision CUJ
PiperOrigin-RevId: 744088634
1 parent f5043a6 commit 15df1f6

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

vertexai/preview/evaluation/eval_task.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"""Evaluation Task class."""
1818

1919
import logging
20-
import warnings
2120
from typing import Any, Callable, Dict, List, Literal, Optional, TYPE_CHECKING, Union
2221
import uuid
22+
import warnings
2323

2424
from google.api_core import exceptions
2525
import vertexai
@@ -45,6 +45,7 @@
4545

4646
if TYPE_CHECKING:
4747
import pandas as pd
48+
from google.colab import sheets
4849

4950

5051
# pylint: disable=g-import-not-at-top
@@ -241,7 +242,7 @@ def custom_model_fn(input: str) -> str:
241242
def __init__(
242243
self,
243244
*,
244-
dataset: Union["pd.DataFrame", str, Dict[str, Any]],
245+
dataset: Union["pd.DataFrame", str, Dict[str, Any], "sheets.InteractiveSheet"],
245246
metrics: List[
246247
Union[
247248
Literal[

vertexai/preview/evaluation/utils.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@
2020
import io
2121
import json
2222
import os
23+
import re
24+
import sys
2325
import tempfile
2426
import threading
2527
import time
26-
import re
2728
from typing import (
2829
Any,
2930
Callable,
3031
Dict,
3132
List,
3233
Optional,
33-
TYPE_CHECKING,
34-
Union,
3534
Pattern,
3635
Tuple,
36+
TYPE_CHECKING,
37+
Union,
3738
)
3839

3940
from google.cloud import bigquery
@@ -219,6 +220,12 @@ def load_dataset(
219220
'Pandas is not installed. Please install the SDK using "pip install'
220221
' google-cloud-aiplatform[evaluation]"'
221222
)
223+
if "google.colab" in sys.modules:
224+
from google.colab import sheets
225+
226+
if isinstance(source, sheets.InteractiveSheet):
227+
return source.as_df().copy()
228+
222229
if isinstance(source, pd.DataFrame):
223230
return source.copy()
224231
elif isinstance(source, dict):

0 commit comments

Comments
 (0)