Skip to content

Commit f09cac6

Browse files
committed
fix lint and add imports
1 parent 93e92d9 commit f09cac6

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

bigframes/bigquery/_operations/ai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def generate_embedding(
469469
# We need to get the SQL for the input data to pass as a subquery to the TVF
470470
source_sql = data_df.sql
471471

472-
struct_fields = {}
472+
struct_fields: bigframes.core.sql.literals.STRUCT_TYPE = {}
473473
if output_dimensionality is not None:
474474
struct_fields["OUTPUT_DIMENSIONALITY"] = output_dimensionality
475475
if task_type is not None:

bigframes/bigquery/ai.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
generate,
2323
generate_bool,
2424
generate_double,
25+
generate_embedding,
2526
generate_int,
2627
if_,
2728
score,
@@ -33,6 +34,7 @@
3334
"generate",
3435
"generate_bool",
3536
"generate_double",
37+
"generate_embedding",
3638
"generate_int",
3739
"if_",
3840
"score",

bigframes/core/sql/literals.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@
1616

1717
import collections.abc
1818
import json
19-
from typing import Any, Dict, List, Mapping, Optional, Union
19+
from typing import Any, List, Mapping, Union
2020

21-
import bigframes.core.compile.googlesql as googlesql
2221
import bigframes.core.sql
2322

23+
STRUCT_TYPE = Mapping[
24+
str,
25+
Union[str, int, float, bool, Mapping[str, str], List[str], Mapping[str, Any]],
26+
]
2427

25-
def struct_literal(
26-
struct_options: Mapping[
27-
str,
28-
Union[str, int, float, bool, Mapping[str, str], List[str], Mapping[str, Any]],
29-
]
30-
) -> str:
28+
29+
def struct_literal(struct_options: STRUCT_TYPE) -> str:
3130
rendered_options = []
3231
for option_name, option_value in struct_options.items():
3332
if option_name == "model_params":

bigframes/core/sql/ml.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
from __future__ import annotations
1616

17-
import collections.abc
18-
import json
1917
from typing import Any, Dict, List, Mapping, Optional, Union
2018

2119
import bigframes.core.compile.googlesql as googlesql

tests/unit/bigquery/test_ai.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import pandas as pd
1818
import pytest
1919

20-
import bigframes.bigquery._operations.ai as ai_ops
20+
import bigframes.bigquery as bbq
2121
import bigframes.dataframe
2222
import bigframes.series
2323
import bigframes.session
@@ -52,7 +52,7 @@ def mock_series(mock_session):
5252
def test_generate_embedding_with_dataframe(mock_dataframe, mock_session):
5353
model_name = "project.dataset.model"
5454

55-
ai_ops.generate_embedding(
55+
bbq.ai.generate_embedding(
5656
model_name,
5757
mock_dataframe,
5858
output_dimensionality=256,
@@ -78,7 +78,7 @@ def test_generate_embedding_with_dataframe(mock_dataframe, mock_session):
7878
def test_generate_embedding_with_series(mock_series, mock_session):
7979
model_name = "project.dataset.model"
8080

81-
ai_ops.generate_embedding(
81+
bbq.ai.generate_embedding(
8282
model_name, mock_series, start_second=0.0, end_second=10.0, interval_seconds=5.0
8383
)
8484

@@ -97,7 +97,7 @@ def test_generate_embedding_with_series(mock_series, mock_session):
9797
def test_generate_embedding_defaults(mock_dataframe, mock_session):
9898
model_name = "project.dataset.model"
9999

100-
ai_ops.generate_embedding(
100+
bbq.ai.generate_embedding(
101101
model_name,
102102
mock_dataframe,
103103
)
@@ -122,7 +122,7 @@ def test_generate_embedding_with_pandas_dataframe(
122122

123123
pandas_df = pd.DataFrame({"content": ["test"]})
124124

125-
ai_ops.generate_embedding(
125+
bbq.ai.generate_embedding(
126126
model_name,
127127
pandas_df,
128128
)

0 commit comments

Comments
 (0)