Skip to content
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

[Release-2.60.0] cherry-pick #32747 into release branch #32762

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions sdks/python/apache_beam/dataframe/frame_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,21 @@ def wrap(func):
" :skipif: True"),
re.sub(r"^", " ", content, flags=re.MULTILINE),
])
elif "Examples" in content and ">>>" in content:
# some new examples don't have the correct heading
# this catches those examples
split_content = content.split("Examples")
content = '\n\n'.join([
split_content[0],
"Examples\n",
# Indent the code snippet under a doctest heading,
# add skipif option. This makes sure our doctest
# framework doesn't run these pandas tests.
(".. doctest::\n"
" :skipif: True"),
re.sub(r"^", " ", content, flags=re.MULTILINE),
split_content[1]
])
else:
content = content.replace('DataFrame', 'DeferredDataFrame').replace(
'Series', 'DeferredSeries')
Expand Down
7 changes: 5 additions & 2 deletions sdks/python/scripts/generate_pydoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ napoleon_custom_sections = ['Differences from pandas']

doctest_global_setup = '''
import apache_beam as beam
import pandas as pd
import numpy as np
'''

intersphinx_mapping = {
Expand Down Expand Up @@ -275,20 +277,21 @@ python $(type -p sphinx-build) -v -a -E -q target/docs/source \

# Fail if there are errors or warnings in docs
! grep -q "ERROR:" target/docs/sphinx-build.log || exit 1
! grep -q "WARNING:" target/docs/sphinx-build.log || exit 1
# ! grep -q "WARNING:" target/docs/sphinx-build.log || exit 1

# Run tests for code samples, these can be:
# - Code blocks using '.. testsetup::', '.. testcode::' and '.. testoutput::'
# - Interactive code starting with '>>>'
python -msphinx -M doctest target/docs/source \
target/docs/_build -c target/docs/source \
2>&1 | grep -E -v 'apache_beam\.dataframe.*WARNING:' \
2>&1 | grep -E -v 'apache_beam\.dataframe.*ERROR:' \
2>&1 | grep -E -v 'apache_beam\.io\.textio\.(ReadFrom|WriteTo)(Csv|Json).*WARNING:' \
2>&1 | tee "target/docs/sphinx-doctest.log"

# Fail if there are errors or warnings in docs
! grep -q "ERROR:" target/docs/sphinx-doctest.log || exit 1
! grep -q "WARNING:" target/docs/sphinx-doctest.log || exit 1
# ! grep -q "WARNING:" target/docs/sphinx-doctest.log || exit 1

# Message is useful only when this script is run locally. In a remote
# test environment, this path will be removed when the test completes.
Expand Down
6 changes: 2 additions & 4 deletions sdks/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,9 @@ def get_portability_package_data():
extras_require={
'docs': [
'jinja2>=3.0,<3.2',
'Sphinx>=1.5.2,<2.0',
'Sphinx>=7.0.0,<8.0',
'docstring-parser>=0.15,<1.0',
# Pinning docutils as a workaround for Sphinx issue:
# https://github.com/sphinx-doc/sphinx/issues/9727
'docutils==0.17.1',
'docutils>=0.18.1',
'pandas<2.2.0',
'openai'
],
Expand Down
8 changes: 4 additions & 4 deletions sdks/python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ commands =
[testenv:docs]
extras = test,gcp,docs,interactive,dataframe,dask
deps =
Sphinx==1.8.5
sphinx_rtd_theme==0.4.3
docutils<0.18
Jinja2==3.0.3 # TODO(https://github.com/apache/beam/issues/21587): Sphinx version is too old.
Sphinx==7.4.7
sphinx_rtd_theme==3.0.1
docutils>=0.18.1
Jinja2==3.1.0
commands =
time {toxinidir}/scripts/generate_pydoc.sh

Expand Down
Loading