8000 [BLD] CircleCI failed when a PR generates sphinx warnings by cmarmo · Pull Request #15355 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[BLD] CircleCI failed when a PR generates sphinx warnings #15355

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

Closed
wants to merge 18 commits into from
Closed
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
48 changes: 48 additions & 0 deletions build_tools/circle/build_doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,44 @@ get_build_type() {
return
fi
changed_examples=$(echo "$filenames" | grep -E "^examples/(.*/)*plot_")

# The following is used to extract the list of filenames of example python
# files that sphinx-gallery needs to run to generate png files used as
# figures or images in the .rst files from the documentation.
# If the contributor changes a .rst file in a PR we need to run all
# the examples mentioned in that file to get sphinx build the
# documentation without generating spurious warnings related to missing
# png files.

if [[ -n "$filenames" ]]
then
# get rst files
rst_files="$(echo "$filenames" | grep -E "rst$")"

# get lines with figure or images
img_fig_lines="$(echo "$rst_files" | xargs grep -shE "(figure|image)::")"

# get only auto_examples
auto_example_files="$(echo "$img_fig_lines" | grep auto_examples | awk -F "/" '{print $NF}')"

# remove "sphx_glr_" from path and accept replace _\d\d\d.png with .py
scripts_names="$(echo "$auto_example_files" | sed 's/sphx_glr_//' | sed -e 's/_[[:digit:]][[:digit:]][[:digit:]].png/.py/')"

# get unique values
examples_in_rst="$(echo "$scripts_names" | uniq )"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

if [[ -n "$examples_in_rst" ]]
then
	changed_examples="$changed_examples|$examples_in_rst"
fi

And leave the rest unchanged. My goal is to reduce the number of if statements after this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then if $changed_examples is empty your regular expression for EXAMPLES_PATTERN will begin with |: this generates an error in every checker of regexp I've tested (maybe you know why?) and always crashes my checks in cmarmo#5

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Is our Makefile tolerant to extra | when either changed_examples or examples_in_rst are empty?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this verbose way work?

if [[ -n "$examples_in_rst" ]]
then
	if [[ -n "$changed_examples" ]]
	then
		changed_examples="$changed_examples|$examples_in_rst"
	else
		changed_examples="$examples_in_rst"
	fi
fi
10000

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I go for it.
Next time you write the code and I'll do the review? I feel like the entire process will be way more efficient... ;)

fi

# executed only if there are examples in the modified rst files
if [[ -n "$examples_in_rst" ]]
then
if [[ -n "$changed_examples" ]]
then
changed_examples="$changed_examples|$examples_in_rst"
else
changed_examples="$examples_in_rst"
fi
fi

if [[ -n "$changed_examples" ]]
then
echo BUILD: detected examples/ filename modified in $git_range: $changed_examples
Expand All @@ -66,6 +104,7 @@ get_build_type() {
echo "$pattern"
return
fi

echo QUICK BUILD: no examples/ filename modified in $git_range:
echo "$filenames"
}
Expand Down Expand Up @@ -190,6 +229,8 @@ then
if [ -z "$warnings" ]
then
warnings="/home/circleci/project/ no warnings"
else
check=1
fi
echo "$warnings"

Expand All @@ -204,5 +245,12 @@ then
echo "$warnings" | sed 's/\/home\/circleci\/project\//<li>/g'
echo '</ul></body></html>'
) > 'doc/_build/html/stable/_changed.html'

if [ $check ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can do this without introducing the check variable:

if [ -n "$warnings" ]
then
    echo "There are Sphinx Warnings in the documentation!"
    echo "Please check doc/_build/html/stable/_changed.html"
    exit 1
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried: but I was using grep in order to do this and grep throws an exit 1 when it could find anything, so the script exited due to the set -e... I can dig deeper if it's reeeally necessary...

then
echo "Sphinx generated warnings when building the documentation related to files modified in this PR."
echo "Please check doc/_build/html/stable/_changed.html"
exit 1
fi
fi

0