Skip to content

Commit 6ebb05b

Browse files
authored
Merge branch 'main' into sycai_ai_gen_bool
2 parents c9151dc + 36ee4d1 commit 6ebb05b

File tree

5 files changed

+50
-8
lines changed

5 files changed

+50
-8
lines changed

bigframes/dtypes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,9 @@ def _dtype_from_string(dtype_string: str) -> typing.Optional[Dtype]:
641641
return BIGFRAMES_STRING_TO_BIGFRAMES[
642642
typing.cast(DtypeString, str(dtype_string))
643643
]
644+
if isinstance(dtype_string, str) and dtype_string.lower() == "json":
645+
return JSON_DTYPE
646+
644647
raise TypeError(
645648
textwrap.dedent(
646649
f"""
@@ -652,9 +655,9 @@ def _dtype_from_string(dtype_string: str) -> typing.Optional[Dtype]:
652655
The following pandas.ExtensionDtype are supported:
653656
pandas.BooleanDtype(), pandas.Float64Dtype(),
654657
pandas.Int64Dtype(), pandas.StringDtype(storage="pyarrow"),
655-
pd.ArrowDtype(pa.date32()), pd.ArrowDtype(pa.time64("us")),
656-
pd.ArrowDtype(pa.timestamp("us")),
657-
pd.ArrowDtype(pa.timestamp("us", tz="UTC")).
658+
pandas.ArrowDtype(pa.date32()), pandas.ArrowDtype(pa.time64("us")),
659+
pandas.ArrowDtype(pa.timestamp("us")),
660+
pandas.ArrowDtype(pa.timestamp("us", tz="UTC")).
658661
{constants.FEEDBACK_LINK}
659662
"""
660663
)

bigframes/ml/llm.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,14 @@ class Claude3TextGenerator(base.RetriableRemotePredictor):
849849
850850
The models only available in specific regions. Check https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-claude#regions for details.
851851
852+
.. note::
853+
854+
claude-3-sonnet model is deprecated. Use other models instead.
855+
852856
Args:
853857
model_name (str, Default to "claude-3-sonnet"):
854858
The model for natural language tasks. Possible values are "claude-3-sonnet", "claude-3-haiku", "claude-3-5-sonnet" and "claude-3-opus".
855-
"claude-3-sonnet" is Anthropic's dependable combination of skills and speed. It is engineered to be dependable for scaled AI deployments across a variety of use cases.
859+
"claude-3-sonnet" (deprecated) is Anthropic's dependable combination of skills and speed. It is engineered to be dependable for scaled AI deployments across a variety of use cases.
856860
"claude-3-haiku" is Anthropic's fastest, most compact vision and text model for near-instant responses to simple queries, meant for seamless AI experiences mimicking human interactions.
857861
"claude-3-5-sonnet" is Anthropic's most powerful AI model and maintains the speed and cost of Claude 3 Sonnet, which is a mid-tier model.
858862
"claude-3-opus" is Anthropic's second-most powerful AI model, with strong performance on highly complex tasks.

tests/system/load/test_llm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_llm_gemini_w_ground_with_google_search(llm_remote_text_df):
100100
# (b/366290533): Claude models are of extremely low capacity. The tests should reside in small tests. Moving these here just to protect BQML's shared capacity(as load test only runs once per day.) and make sure we still have minimum coverage.
101101
@pytest.mark.parametrize(
102102
"model_name",
103-
("claude-3-sonnet", "claude-3-haiku", "claude-3-5-sonnet", "claude-3-opus"),
103+
("claude-3-haiku", "claude-3-5-sonnet", "claude-3-opus"),
104104
)
105105
@pytest.mark.flaky(retries=3, delay=120)
106106
def test_claude3_text_generator_create_load(
@@ -125,7 +125,7 @@ def test_claude3_text_generator_create_load(
125125

126126
@pytest.mark.parametrize(
127127
"model_name",
128-
("claude-3-sonnet", "claude-3-haiku", "claude-3-5-sonnet", "claude-3-opus"),
128+
("claude-3-haiku", "claude-3-5-sonnet", "claude-3-opus"),
129129
)
130130
@pytest.mark.flaky(retries=3, delay=120)
131131
def test_claude3_text_generator_predict_default_params_success(
@@ -144,7 +144,7 @@ def test_claude3_text_generator_predict_default_params_success(
144144

145145
@pytest.mark.parametrize(
146146
"model_name",
147-
("claude-3-sonnet", "claude-3-haiku", "claude-3-5-sonnet", "claude-3-opus"),
147+
("claude-3-haiku", "claude-3-5-sonnet", "claude-3-opus"),
148148
)
149149
@pytest.mark.flaky(retries=3, delay=120)
150150
def test_claude3_text_generator_predict_with_params_success(
@@ -165,7 +165,7 @@ def test_claude3_text_generator_predict_with_params_success(
165165

166166
@pytest.mark.parametrize(
167167
"model_name",
168-
("claude-3-sonnet", "claude-3-haiku", "claude-3-5-sonnet", "claude-3-opus"),
168+
("claude-3-haiku", "claude-3-5-sonnet", "claude-3-opus"),
169169
)
170170
@pytest.mark.flaky(retries=3, delay=120)
171171
def test_claude3_text_generator_predict_multi_col_success(

tests/system/small/engines/test_generic_ops.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,29 @@ def test_engines_astype_from_json(scalars_array_value: array_value.ArrayValue, e
275275
assert_equivalence_execution(arr.node, REFERENCE_ENGINE, engine)
276276

277277

278+
@pytest.mark.parametrize("engine", ["polars", "bq"], indirect=True)
279+
def test_engines_astype_to_json(scalars_array_value: array_value.ArrayValue, engine):
280+
exprs = [
281+
ops.AsTypeOp(to_type=bigframes.dtypes.JSON_DTYPE).as_expr(
282+
expression.deref("int64_col")
283+
),
284+
ops.AsTypeOp(to_type=bigframes.dtypes.JSON_DTYPE).as_expr(
285+
# Use a const since float to json has precision issues
286+
expression.const(5.2, bigframes.dtypes.FLOAT_DTYPE)
287+
),
288+
ops.AsTypeOp(to_type=bigframes.dtypes.JSON_DTYPE).as_expr(
289+
expression.deref("bool_col")
290+
),
291+
ops.AsTypeOp(to_type=bigframes.dtypes.JSON_DTYPE).as_expr(
292+
# Use a const since "str_col" has special chars.
293+
expression.const('"hello world"', bigframes.dtypes.STRING_DTYPE)
294+
),
295+
]
296+
arr, _ = scalars_array_value.compute_values(exprs)
297+
298+
assert_equivalence_execution(arr.node, REFERENCE_ENGINE, engine)
299+
300+
278301
@pytest.mark.parametrize("engine", ["polars", "bq"], indirect=True)
279302
def test_engines_astype_timedelta(scalars_array_value: array_value.ArrayValue, engine):
280303
arr = apply_op(

tests/system/small/test_series.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3903,6 +3903,18 @@ def test_float_astype_json(errors):
39033903
pd.testing.assert_series_equal(bf_result.to_pandas(), expected_result)
39043904

39053905

3906+
def test_float_astype_json_str():
3907+
data = ["1.25", "2500000000", None, "-12323.24"]
3908+
bf_series = series.Series(data, dtype=dtypes.FLOAT_DTYPE)
3909+
3910+
bf_result = bf_series.astype("json")
3911+
assert bf_result.dtype == dtypes.JSON_DTYPE
3912+
3913+
expected_result = pd.Series(data, dtype=dtypes.JSON_DTYPE)
3914+
expected_result.index = expected_result.index.astype("Int64")
3915+
pd.testing.assert_series_equal(bf_result.to_pandas(), expected_result)
3916+
3917+
39063918
@pytest.mark.parametrize("errors", ["raise", "null"])
39073919
def test_string_astype_json(errors):
39083920
data = [

0 commit comments

Comments
 (0)