Skip to content

Commit 7b59b6d

Browse files
authored
feat: include the bigframes package version alongside the feedback link in error messages (#936)
* chore: update ABSTRACT_METHOD_ERROR_MESSAGE to include bigframes version number * fix bigframes import * 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 * format
1 parent 6006105 commit 7b59b6d

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

bigframes/constants.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import bigframes_vendored.constants
2323

24+
BF_VERSION = bigframes_vendored.constants.BF_VERSION
2425
FEEDBACK_LINK = bigframes_vendored.constants.FEEDBACK_LINK
2526
ABSTRACT_METHOD_ERROR_MESSAGE = (
2627
bigframes_vendored.constants.ABSTRACT_METHOD_ERROR_MESSAGE

tests/unit/test_constants.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import bigframes.constants as constants
16+
17+
18+
def test_feedback_link_includes_version():
19+
assert len(constants.BF_VERSION) > 0
20+
assert constants.BF_VERSION in constants.FEEDBACK_LINK

tests/unit/test_formatting_helpers.py

+11
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,14 @@ def test_wait_for_job_error_includes_feedback_link():
4444

4545
cap_exc.match("Test message 123.")
4646
cap_exc.match(constants.FEEDBACK_LINK)
47+
48+
49+
def test_wait_for_job_error_includes_version():
50+
mock_job = mock.create_autospec(bigquery.LoadJob)
51+
mock_job.result.side_effect = api_core_exceptions.BadRequest("Test message 123.")
52+
53+
with pytest.raises(api_core_exceptions.BadRequest) as cap_exc:
54+
formatting_helpers.wait_for_job(mock_job)
55+
56+
cap_exc.match("Test message 123.")
57+
cap_exc.match(constants.BF_VERSION)

third_party/bigframes_vendored/constants.py

+4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
1717
This module should not depend on any others in the package.
1818
"""
19+
import bigframes.version
20+
21+
BF_VERSION = bigframes.version.__version__
1922

2023
FEEDBACK_LINK = (
2124
"Share your usecase with the BigQuery DataFrames team at the "
2225
"https://bit.ly/bigframes-feedback survey."
26+
f"You are currently running BigFrames version {BF_VERSION}"
2327
)
2428

2529
ABSTRACT_METHOD_ERROR_MESSAGE = (

0 commit comments

Comments
 (0)