Skip to content

Conversation

@rekhajoshm
Copy link
Contributor

@rekhajoshm rekhajoshm commented Feb 9, 2018

What changes were proposed in this pull request?

Includes python document style checking.

  • Use sphinx like check, run only if pydocstyle installed on machine/jenkins
  • use pydocstyle rather than single file version pep257.py, which is much older and had some known issues
  • verify pydocstyle latest 2.1.1 is in use, to ensure latest doc checks are getting executed
  • ignore (inclusion/exclusion error codes) features and support via tox.ini
  • Be non-breaking change and allow updating docstyle to standards at easy pace

How was this patch tested?

./dev/run-tests

rekhajoshm added 12 commits May 5, 2015 16:10
Pulling functionality from apache spark
pull latest from apache spark
Pulling functionality from apache spark
Pulling functionality from apache spark
pull request from apache/master
pull latest from apache spark
pull latest from apache spark
pull latest apache spark
Apache spark pull latest
Apache spark latest pull
@SparkQA
Copy link

SparkQA commented Feb 9, 2018

Test build #87248 has finished for PR 20556 at commit 85ca69d.

  • This patch fails RAT tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Feb 9, 2018

Test build #87249 has finished for PR 20556 at commit ee14cf7.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rekhajoshm
Copy link
Contributor Author

build error unrelated to this PR. retest this please.

dev/lint-python Outdated
SPARK_ROOT_DIR="$(dirname "$SCRIPT_DIR")"
# Exclude auto-generated configuration file.
PATHS_TO_CHECK="$( cd "$SPARK_ROOT_DIR" && find . -name "*.py" )"
DOC_PATHS_TO_CHECK="$( cd "$SPARK_ROOT_DIR" && find . -name "*.py" | grep -vF 'functions.py')"
Copy link
Member

Choose a reason for hiding this comment

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

nit: add an extra space between 'functions.py' and ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

dev/lint-python Outdated
PYLINT_REPORT_PATH="$SPARK_ROOT_DIR/dev/pylint-report.txt"
PYLINT_INSTALL_INFO="$SPARK_ROOT_DIR/dev/pylint-info.txt"
PYDOCSTYLEBUILD="pydocstyle"
PYDOCSTYLEVERSION=$(python -c 'import pkg_resources; print pkg_resources.get_distribution("pydocstyle").version')
Copy link
Member

Choose a reason for hiding this comment

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

..; print(pkg_resources.get_distribution("pydocstyle").version)' 2> /dev/null)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

dev/tox.ini Outdated
max-line-length=100
exclude=cloudpickle.py,heapq3.py,shared.py,python/docs/conf.py,work/*/*.py,python/.eggs/*
[pydocstyle]
ignore=D100,D101,D102,D103,D104,D105,D106,D107,D200,D201,D202,D203,D204,D205,D206,D207,D208,D209,D210,D211,D212,D213,D214,D215,D300,D301,D302,D400,D401,D402,D403,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414
Copy link
Member

Choose a reason for hiding this comment

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

We need a line break at the end of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@SparkQA
Copy link

SparkQA commented Feb 14, 2018

Test build #87439 has finished for PR 20556 at commit ee14cf7.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

dev/lint-python Outdated

# Check python document style, skip check if pydocstyle is not installed.
if hash "$PYDOCSTYLEBUILD" 2> /dev/null; then
if [ $PYDOCSTYLEVERSION == "2.1.1" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

What happens when a new version of pydocstyle is released? Would the same rules below still work so that this check could be >= 2.1.1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

dev/lint-python Outdated
lint_status=1
fi

if [ "$lint_status" -ne 0 ]; then
Copy link
Member

Choose a reason for hiding this comment

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

could you just move this block above and get rid of lint_status?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure i understand

Copy link
Contributor

Choose a reason for hiding this comment

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

So if I understand @BryanCutler's request correctly, instead of setting linte_status in the if check above and then lint_status to determine if we should run the pydocstyle checker, just directly check the compile status and then run the pydocstyle checker on that.

That being said I think we could also drop the compile_status check since we would have already exited the script if it was non-zero at this point (I think).

@holdenk
Copy link
Contributor

holdenk commented Feb 26, 2018

Thanks for working on this! I like the idea of automated document style checking for Python :)

@holdenk
Copy link
Contributor

holdenk commented Feb 26, 2018

Jenkins retest this please.

@SparkQA
Copy link

SparkQA commented Feb 27, 2018

Test build #87683 has finished for PR 20556 at commit ee14cf7.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Feb 27, 2018

Test build #87688 has finished for PR 20556 at commit 11ad2c1.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

@holdenk holdenk left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. Is this a thing you still have bandwidth to work on?

dev/lint-python Outdated
lint_status=1
fi

if [ "$lint_status" -ne 0 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

So if I understand @BryanCutler's request correctly, instead of setting linte_status in the if check above and then lint_status to determine if we should run the pydocstyle checker, just directly check the compile status and then run the pydocstyle checker on that.

That being said I think we could also drop the compile_status check since we would have already exited the script if it was non-zero at this point (I think).

dev/lint-python Outdated
rm "$PYDOCSTYLE_REPORT_PATH"
fi
else
echo "The pydocstyle version needs to be latest 2.1.1.Skipping pydoc checks for now"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add a space between "2.1.1.Skipping" the final dot and skipping.

@holdenk
Copy link
Contributor

holdenk commented Jul 27, 2018

If your still working on this would be good to merge in the latest master branch.

@holdenk
Copy link
Contributor

holdenk commented Sep 14, 2018

Are you still interested in this PR?

@rekhajoshm
Copy link
Contributor Author

Yes @holdenk , seems like I missed the last notification on it. Please let me look into it this weekend. Thanks.

@rekhajoshm
Copy link
Contributor Author

PR #22425 Closing this.Thanks

@rekhajoshm rekhajoshm closed this Sep 15, 2018
@SparkQA
Copy link

SparkQA commented Sep 15, 2018

Test build #96085 has finished for PR 20556 at commit 5f6b409.

  • This patch fails Spark unit tests.
  • This patch does not merge cleanly.
  • This patch adds no public classes.

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.

5 participants