8000 docs: adjust strip method examples to match latest pandas by tswast · Pull Request #1797 · googleapis/python-bigquery-dataframes · GitHub
[go: up one dir, main page]

Skip to content

docs: adjust strip method examples to match latest pandas #1797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 9, 2025
Merged

Conversation

tswast
Copy link
Collaborator
@tswast tswast commented Jun 6, 2025

The string representation of pandas Series has changed, causing doctest failures in accessor.py. This commit updates the expected output in the doctests for lstrip, rstrip, and strip to reflect the new string representation.

The changes involve removing the <BLANKLINE> before <NA> and adjusting the spacing in the doctest examples.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes internal issue b/422994327 🦕

@tswast tswast requested review from a team as code owners June 6, 2025 17:12
@tswast tswast requested a review from GarrettWu June 6, 2025 17:12
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Jun 6, 2025
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Jun 6, 2025
The string representation of pandas Series has changed, causing
doctest failures in `accessor.py`. This commit updates the
expected output in the doctests for `lstrip`, `rstrip`, and
`strip` to reflect the new string representation.

The changes involve removing the `<BLANKLINE>` before `<NA>`
and adjusting the spacing in the doctest examples.
@tswast tswast changed the title Fix doctests for string accessor methods docs: adjust strip method examples to match latest pandas Jun 6, 2025
@tswast
Copy link
Collaborator Author
tswast commented Jun 6, 2025

I gave up on Jules for this one. It was actually kind of hard to figure out what whitespace characters were actually ending up in doctest output. Tests are passing now with the latest pandas.

pytest --doctest-modules third_party/bigframes_vendored/pandas/core/strings/accessor.py::accessor.StringMethods.lstrip \
 third_party/bigframes_vendored/pandas/core/strings/accessor.py::accessor.StringMethods.rstrip \
 third_party/bigframes_vendored/pandas/core/strings/accessor.py::accessor.StringMethods.strip
platform linux -- Python 3.10.17, pytest-8.4.0, pluggy-1.6.0
rootdir: /home/swast/src/github.com/googleapis/python-bigquery-dataframes-2
configfile: pytest.ini
plugins: snapshot-0.9.0
collected 3 items                                                                                                                                                                                          

third_party/bigframes_vendored/pandas/core/strings/accessor.py ...                                                                                                                                   [100%]

=== warnings summary ===
third_party/bigframes_vendored/pandas/core/strings/accessor.py::accessor.StringMethods.lstrip
 /home/swast/src/github.com/googleapis/python-bigquery-dataframes-2/bigframes/core/global_session.py:103: DefaultLocationWarning: No explicit location is set, so using location US for the session.
   _global_session = bigframes.session.connect(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==== 3 passed, 1 warning in 19.82s =======

@tswast
Copy link
Collaborator Author
tswast commented Jun 6, 2025

Remaining doctest failure appears to be a flake:

`[doctest] frame.DataFrame.apply`
_______________________ [doctest] frame.DataFrame.apply ________________________
[gw1] linux -- Python 3.12.7 /tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/bin/python
4911             <BLANKLINE>
4912             [2 rows x 2 columns]
4913 
4914         You could apply a user defined function to every row of the DataFrame by
4915         creating a remote function out of it, and using it with `axis=1`. Within
4916         the function, each row is passed as a ``pandas.Series``. It is recommended
4917         to select only the necessary columns before calling `apply()`. Note: This
4918         feature is currently in **preview**.
4919 
4920             >>> @bpd.remote_function(reuse=False, cloud_function_service_account="default")
UNEXPECTED EXCEPTION: ServiceUnavailable('Visibility check was unavailable. Please retry the request and contact support if the problem persists')
Traceback (most recent call last):
  File "/tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/lib/python3.12/site-packages/google/api_core/grpc_helpers.py", line 76, in error_remapped_callable
    return callable_(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/lib/python3.12/site-packages/grpc/_interceptor.py", line 277, in __call__
    response, ignored_call = self._with_call(
                             ^^^^^^^^^^^^^^^^
  File "/tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/lib/python3.12/site-packages/grpc/_interceptor.py", line 332, in _with_call
    return call.result(), call
           ^^^^^^^^^^^^^
  File "/tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/lib/python3.12/site-packages/grpc/_channel.py", line 440, in result
    raise self
  File "/tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/lib/python3.12/site-packages/grpc/_interceptor.py", line 315, in continuation
    response, call = self._thunk(new_method).with_call(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/lib/python3.12/site-packages/grpc/_channel.py", line 1198, in with_call
    return _end_unary_response_blocking(state, call, True, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/lib/python3.12/site-packages/grpc/_channel.py", line 1006, in _end_unary_response_blocking
    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
	status = StatusCode.UNAVAILABLE
	details = "Visibility check was unavailable. Please retry the request and contact support if the problem persists"
	debug_error_string = "UNKNOWN:Error received from peer ipv4:108.177.121.95:443 {grpc_message:"Visibility check was unavailable. Please retry the request and contact support if the problem persists", grpc_status:14}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/doctest.py", line 1368, in __run
    exec(compile(example.source, filename, "single",
  File "<doctest frame.DataFrame.apply[7]>", line 1, in <module>
  File "/tmpfs/src/github/python-bigquery-dataframes/bigframes/functions/_function_session.py", line 641, in wrapper
    ) = remote_function_client.provision_bq_remote_function(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmpfs/src/github/python-bigquery-dataframes/bigframes/functions/_function_client.py", line 564, in provision_bq_remote_function
    cf_endpoint = self.get_cloud_function_endpoint(cloud_function_name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmpfs/src/github/python-bigquery-dataframes/bigframes/functions/_function_client.py", line 337, in get_cloud_function_endpoint
    response = self._cloud_functions_client.get_function(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/lib/python3.12/site-packages/google/cloud/functions_v2/services/function_service/client.py", line 1029, in get_function
    response = rpc(
               ^^^^
  File "/tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/lib/python3.12/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__
    return wrapped_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmpfs/src/github/python-bigquery-dataframes/.nox/doctest/lib/python3.12/site-packages/google/api_core/grpc_helpers.py", line 78, in error_remapped_callable
    raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.ServiceUnavailable: 503 Visibility check was unavailable. Please retry the request and contact support if the problem persists
/tmpfs/src/github/python-bigquery-dataframes/third_party/bigframes_vendored/pandas/core/frame.py:4920: UnexpectedException

@tswast tswast mentioned this pull request Jun 9, 2025
4 tasks
@tswast tswast assigned GarrettWu and unassigned jialuoo Jun 9, 2025
@tswast
Copy link
Collaborator Author
tswast commented Jun 9, 2025

Remaining failures are due to functions quota issues.

FAILED third_party/bigframes_vendored/pandas/core/series.py::series.Series.apply
FAILED third_party/bigframes_vendored/pandas/core/frame.py::frame.DataFrame.apply
FAILED third_party/bigframes_vendored/pandas/core/frame.py::frame.DataFrame.map
FAILED third_party/bigframes_vendored/pandas/core/series.py::series.Series.map
FAILED third_party/bigframes_vendored/pandas/core/series.py::series.Series.mask
FAILED bigframes/dataframe.py::bigframes.dataframe.DataFrame.applymap
FAILED bigframes/dataframe.py::bigframes.dataframe.DataFrame.map
FAILED bigframes/pandas/io/api.py::bigframes.pandas.io.api.read_gbq_function
FAILED bigframes/session/__init__.py::bigframes.session.Session.read_gbq_function

@tswast tswast merged commit 817b0c0 into main Jun 9, 2025
22 of 24 checks passed
@tswast tswast deleted the fix-doctests branch June 9, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0