From bb74763ba0630ecd0e273f5a7d478dff7e9338dc Mon Sep 17 00:00:00 2001 From: Daniela Date: Wed, 28 Aug 2024 18:56:15 +0000 Subject: [PATCH 1/4] chore: update ABSTRACT_METHOD_ERROR_MESSAGE to include bigframes version number --- third_party/bigframes_vendored/constants.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/third_party/bigframes_vendored/constants.py b/third_party/bigframes_vendored/constants.py index 0d4a7d1df6..e416652b40 100644 --- a/third_party/bigframes_vendored/constants.py +++ b/third_party/bigframes_vendored/constants.py @@ -16,6 +16,9 @@ This module should not depend on any others in the package. """ +import bigframes + +BF_VERSION = bigframes.__version__ FEEDBACK_LINK = ( "Share your usecase with the BigQuery DataFrames team at the " @@ -26,4 +29,5 @@ "Abstract method. You have likely encountered a bug. " "Please share this stacktrace and how you reached it with the BigQuery DataFrames team. " f"{FEEDBACK_LINK}" + f"You are currently running BigFrames version {BF_VERSION}" ) From b9124118ebc7ce910bd3bdb6e2856c084da4a97d Mon Sep 17 00:00:00 2001 From: Daniela Date: Wed, 28 Aug 2024 20:27:26 +0000 Subject: [PATCH 2/4] fix bigframes import --- third_party/bigframes_vendored/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/bigframes_vendored/constants.py b/third_party/bigframes_vendored/constants.py index e416652b40..e9f94c298b 100644 --- a/third_party/bigframes_vendored/constants.py +++ b/third_party/bigframes_vendored/constants.py @@ -16,9 +16,9 @@ This module should not depend on any others in the package. """ -import bigframes +import bigframes.version -BF_VERSION = bigframes.__version__ +BF_VERSION = bigframes.version.__version__ FEEDBACK_LINK = ( "Share your usecase with the BigQuery DataFrames team at the " From 9830b4d3b5418d3a90d554ef87de859f8eb00f40 Mon Sep 17 00:00:00 2001 From: Daniela Date: Tue, 3 Sep 2024 22:50:47 +0000 Subject: [PATCH 3/4] add BF_VERSION to FEEDBACK_LINK, add test to test_formatting_helpers.py to ensure the version is included in the error message, add test_constants.py to ensure BF_VERSION is not an empty string, add BF_VERSION to bigframes/constants.py --- bigframes/constants.py | 1 + tests/unit/test_constants.py | 19 +++++++++++++++++++ tests/unit/test_formatting_helpers.py | 11 +++++++++++ third_party/bigframes_vendored/constants.py | 2 +- 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/unit/test_constants.py diff --git a/bigframes/constants.py b/bigframes/constants.py index 3c18fd20bd..d6fe699713 100644 --- a/bigframes/constants.py +++ b/bigframes/constants.py @@ -21,6 +21,7 @@ import bigframes_vendored.constants +BF_VERSION = bigframes_vendored.constants.BF_VERSION FEEDBACK_LINK = bigframes_vendored.constants.FEEDBACK_LINK ABSTRACT_METHOD_ERROR_MESSAGE = ( bigframes_vendored.constants.ABSTRACT_METHOD_ERROR_MESSAGE diff --git a/tests/unit/test_constants.py b/tests/unit/test_constants.py new file mode 100644 index 0000000000..9a97da6628 --- /dev/null +++ b/tests/unit/test_constants.py @@ -0,0 +1,19 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import bigframes.constants as constants + +def test_feedback_link_includes_version(): + assert len(constants.BF_VERSION)>0 + assert constants.BF_VERSION in constants.FEEDBACK_LINK diff --git a/tests/unit/test_formatting_helpers.py b/tests/unit/test_formatting_helpers.py index 9db9b372e2..085e40538e 100644 --- a/tests/unit/test_formatting_helpers.py +++ b/tests/unit/test_formatting_helpers.py @@ -44,3 +44,14 @@ def test_wait_for_job_error_includes_feedback_link(): cap_exc.match("Test message 123.") cap_exc.match(constants.FEEDBACK_LINK) + + +def test_wait_for_job_error_includes_version(): + mock_job = mock.create_autospec(bigquery.LoadJob) + mock_job.result.side_effect = api_core_exceptions.BadRequest("Test message 123.") + + with pytest.raises(api_core_exceptions.BadRequest) as cap_exc: + formatting_helpers.wait_for_job(mock_job) + + cap_exc.match("Test message 123.") + cap_exc.match(constants.BF_VERSION) diff --git a/third_party/bigframes_vendored/constants.py b/third_party/bigframes_vendored/constants.py index e9f94c298b..91084b38f9 100644 --- a/third_party/bigframes_vendored/constants.py +++ b/third_party/bigframes_vendored/constants.py @@ -23,11 +23,11 @@ FEEDBACK_LINK = ( "Share your usecase with the BigQuery DataFrames team at the " "https://bit.ly/bigframes-feedback survey." + f"You are currently running BigFrames version {BF_VERSION}" ) ABSTRACT_METHOD_ERROR_MESSAGE = ( "Abstract method. You have likely encountered a bug. " "Please share this stacktrace and how you reached it with the BigQuery DataFrames team. " f"{FEEDBACK_LINK}" - f"You are currently running BigFrames version {BF_VERSION}" ) From 235a96454868dee0125faa1d9feafcfa1c8dda28 Mon Sep 17 00:00:00 2001 From: Daniela Date: Tue, 3 Sep 2024 22:56:14 +0000 Subject: [PATCH 4/4] format --- tests/unit/test_constants.py | 3 ++- tests/unit/test_formatting_helpers.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_constants.py b/tests/unit/test_constants.py index 9a97da6628..aabc09c388 100644 --- a/tests/unit/test_constants.py +++ b/tests/unit/test_constants.py @@ -14,6 +14,7 @@ import bigframes.constants as constants + def test_feedback_link_includes_version(): - assert len(constants.BF_VERSION)>0 + assert len(constants.BF_VERSION) > 0 assert constants.BF_VERSION in constants.FEEDBACK_LINK diff --git a/tests/unit/test_formatting_helpers.py b/tests/unit/test_formatting_helpers.py index 085e40538e..3c966752c9 100644 --- a/tests/unit/test_formatting_helpers.py +++ b/tests/unit/test_formatting_helpers.py @@ -52,6 +52,6 @@ def test_wait_for_job_error_includes_version(): with pytest.raises(api_core_exceptions.BadRequest) as cap_exc: formatting_helpers.wait_for_job(mock_job) - + cap_exc.match("Test message 123.") cap_exc.match(constants.BF_VERSION)