8000 Check default doctest directives in CI by lucyleeow · Pull Request #17269 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Check default doctest directives in CI #17269

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 8 commits into from
May 19, 2020

Conversation

lucyleeow
Copy link
Member

Reference Issues/PRs

closes #17019

What does this implement/fix? Explain your changes.

Any other comments?

@adrinjalali
Copy link
Member

Do we want to keep the circleci and azure linting in sync? @thomasjpfan @rth maybe?

@lucyleeow lucyleeow changed the title [WIP] Check default doctest directives in CI Check default doctest directives in CI May 19, 2020
@lucyleeow
Copy link
Member Author

Uses find and grep to search for the default doctest directives 'NORMALIZE_WHITESPACE' and 'ELLIPSIS' in linting.sh. Happy to alter.

@jnothman
Copy link
Member

Do we want to keep the circleci and azure linting in sync? @thomasjpfan @rth maybe?

circle/linting.sh is used in azure.

Copy link
Member
@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM


if [ ! -z "$doctest_directive" ]
then
echo "Default doctest directives found:"
8000 Copy link
Member

Choose a reason for hiding this comment

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

Let's make it clearer what the issue is:

Suggested change
echo "Default doctest directives found:"
echo "ELLIPSIS and NORMALIZE_WHITESPACE doctest directives are enabled by default, but were found in:"

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I wasn't sure how much information to give.

Copy link
Member

Choose a reason for hiding this comment

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

I expect the message will be rarely seen, which is only more reason to provide detail for when it surprises someone!


# Check for default doctest directives ELLIPSIS and NORMALIZE_WHITESPACE

doctest_directive="$(find . -type f \( -name "*.py" -o -name "*.rst" \) -exec grep -nw -E "# doctest: \+(ELLIPSIS|NORMALIZE_WHITESPACE)" {} \;)"
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't git grep -nw -E "# doctest\: \+(ELLIPSIS|NORMALIZE_WHITESPACE)" be much faster?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't know about git grep. There is no way to search only in .py and .rst files but I don't think that is going to be a problem. Though it means searching through more files than required.
I didn't trust grep to do the file selection as I've had problems, which is why I used find. Plus this way find and grep are working in parallel.
Not a bash expert, I can test locally and see which is faster?

Copy link
Member

Choose a reason for hiding this comment

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

I tested and git grep seems to be much faster, even though it's going through more files. We also don't have any occurrence of # doctest +(ELLIPSIS|NORMALIZE_WHITESPACE) anywhere anyway, so grep going though more files shouldn't be an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Your way is way faster!

@adrinjalali adrinjalali merged commit 2d12bb5 into scikit-learn:master May 19, 2020
@lucyleeow lucyleeow deleted the IS/17019 branch May 20, 2020 13:34
viclafargue pushed a commit to viclafargue/scikit-learn that referenced this pull request Jun 26, 2020
* add grep

* directs to test CI

* attempt2

* better output format

* use find

* revert test rst file

* better message

* faster grep
jayzed82 pushed a commit to jayzed82/scikit-learn that referenced this pull request Oct 22, 2020
* add grep

* directs to test CI

* attempt2

* better output format

* use find

* revert test rst file

* better message

* faster grep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use CI to make sure # doctest: +ELLIPSIS is not in docs
3 participants
0