Skip to content

Commit 604e163

Browse files
committed
fix bq errors
1 parent 37dc417 commit 604e163

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

eval_protocol/adapters/bigquery.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
to EvaluationRow format for use in evaluation pipelines.
55
"""
66

7+
from __future__ import annotations
8+
79
import logging
8-
from typing import Any, Callable, Dict, Iterator, List, Optional, Union
10+
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Union
911

1012
from eval_protocol.models import CompletionParams, EvaluationRow, InputMetadata, Message
1113

@@ -20,7 +22,18 @@
2022
BIGQUERY_AVAILABLE = True
2123
except ImportError:
2224
BIGQUERY_AVAILABLE = False
23-
logger.warning("Google Cloud BigQuery not installed. Install with: pip install 'eval-protocol[bigquery]'")
25+
# Optional dependency: avoid noisy warnings during import
26+
logger.debug("Google Cloud BigQuery not installed. Optional feature disabled.")
27+
28+
# Avoid importing BigQuery types at runtime for annotations when not installed
29+
if TYPE_CHECKING:
30+
from google.cloud import bigquery as _bigquery_type
31+
QueryParameterType = Union[
32+
_bigquery_type.ScalarQueryParameter,
33+
_bigquery_type.ArrayQueryParameter,
34+
]
35+
else:
36+
QueryParameterType = Any
2437

2538
# Type alias for transformation function
2639
TransformFunction = Callable[[Dict[str, Any]], Dict[str, Any]]
@@ -96,7 +109,7 @@ def __init__(
96109
def get_evaluation_rows(
97110
self,
98111
query: str,
99-
query_params: Optional[List[Union[bigquery.ScalarQueryParameter, bigquery.ArrayQueryParameter]]] = None,
112+
query_params: Optional[List[QueryParameterType]] = None,
100113
limit: Optional[int] = None,
101114
offset: int = 0,
102115
model_name: str = "gpt-3.5-turbo",

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ adapters = [
111111
"datasets>=2.0.0",
112112
"transformers>=4.0.0",
113113
]
114+
bigquery = [
115+
"google-cloud-bigquery>=3.0.0",
116+
"google-auth>=2.0.0",
117+
]
114118
svgbench = [
115119
"selenium>=4.0.0",
116120
]

0 commit comments

Comments
 (0)