Skip to content

Commit

Permalink
feat: include the bigframes package version alongside the feedback li…
Browse files Browse the repository at this point in the history
…nk 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
  • Loading branch information
rey-esp authored Sep 10, 2024
1 parent 6006105 commit 7b59b6d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions bigframes/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/test_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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
11 changes: 11 additions & 0 deletions tests/unit/test_formatting_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 4 additions & 0 deletions third_party/bigframes_vendored/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
This module should not depend on any others in the package.
"""
import bigframes.version

BF_VERSION = bigframes.version.__version__

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 = (
Expand Down

0 comments on commit 7b59b6d

Please sign in to comment.