Skip to content

Commit

Permalink
Merge branch 'mlflow:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
NieuweNils committed Nov 8, 2021
2 parents e4d4e71 + 6af26f8 commit a8d1690
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 48 deletions.
5 changes: 3 additions & 2 deletions CONTRIBUTING.rst
Expand Up @@ -125,8 +125,9 @@ you can `sign your work`_ when committing code changes and opening pull requests
git config --global user.name "Your Name"
git config --global user.email yourname@example.com
For convenience, we provide a pre-commit git hook that validates that commits are signed-off.
Enable it by running:
For convenience, we provide a pre-commit git hook that validates that commits are signed-off and
runs `black --check` and `pylint` to ensure the code will pass the lint check for python.
You can enable it by running:

.. code-block:: bash
Expand Down
3 changes: 1 addition & 2 deletions dev/set_matrix.py
Expand Up @@ -316,8 +316,7 @@ def process_requirements(requirements, version=None):
)
if match_all:
return packages
else:
return []
return []

raise TypeError("Invalid object type for `requirements`: '{}'".format(type(requirements)))

Expand Down
2 changes: 1 addition & 1 deletion dev/show_package_release_dates.py
Expand Up @@ -6,7 +6,7 @@


def get_distributions():
res = subprocess.run(["pip", "list"], stdout=subprocess.PIPE)
res = subprocess.run(["pip", "list"], stdout=subprocess.PIPE, check=True)
pip_list_stdout = res.stdout.decode("utf-8")
# `pip_list_stdout` looks like this:
# ``````````````````````````````````````````````````````````
Expand Down
8 changes: 8 additions & 0 deletions hooks/pre-commit
@@ -0,0 +1,8 @@
set -ex

diff=$(git diff --cached --name-only | grep '\.py$' || true)

if [ ! -z "$diff" ]; then
black --check $diff
pylint $diff
fi
41 changes: 1 addition & 40 deletions lint.sh
Expand Up @@ -5,30 +5,6 @@
err=0
trap 'err=1' ERR

FWDIR="$(cd "`dirname $0`"; pwd)"
cd "$FWDIR"

# https://stackoverflow.com/a/17841619
function join {
local d=$1
shift
echo -n "$1"
shift
printf "%s" "${@/#/$d}"
}

include_dirs=(
"mlflow"
"tests"
)

exclude_dirs=(
"mlflow/protos"
"mlflow/server/js"
"mlflow/store/db_migrations"
"mlflow/temporary_db_migrations_for_pre_1_users"
)

echo -e "\n========== black ==========\n"
# Exclude proto files because they are auto-generated
black --check .
Expand All @@ -38,23 +14,8 @@ if [ $? -ne 0 ]; then
echo '$ pip install $(cat dev/lint-requirements.txt | grep "black==") && black .'
fi

echo -e "\n========== pycodestyle ==========\n"
exclude=$(join "," "${exclude_dirs[@]}")
include=$(join " " "${include_dirs[@]}")
pycodestyle --max-line-length=100 --ignore=E203,W503 --exclude=$exclude -- $include

echo -e "\n========== pylint ==========\n"
# pylint's `--ignore` option filters files based on their base names, not paths.
# see: http://pylint.pycqa.org/en/latest/user_guide/run.html#command-line-options
# This behavior might cause us to unintentionally ignore some files.
# To avoid this issue, select files to lint using `git ls-files` and `grep`.
# Another advantage of this approach is we can apply pylint to all python scripts
# without creating `__init__.py` in all directories.
exclude="^\($(join "\|" "${exclude_dirs[@]}")\)/.\+\.py$"
include="^\($(join "\|" "${include_dirs[@]}")\)/.\+\.py$"
msg_template="{path} ({line},{column}): [{msg_id} {symbol}] {msg}"

pylint --jobs=0 --msg-template="$msg_template" --rcfile="$FWDIR/pylintrc" $(git ls-files | grep $include | grep -v $exclude)
pylint $(git ls-files | grep '\.py$')

echo -e "\n========== rstcheck ==========\n"
rstcheck README.rst
Expand Down
15 changes: 12 additions & 3 deletions pylintrc
Expand Up @@ -7,19 +7,28 @@ extension-pkg-whitelist=

# Add files or directories to the denylist. They should be base names, not
# paths.
ignore=build,protos,sdk,db_migrations,temporary_db_migrations_for_pre_1_users

ignore=

# Add files or directories matching the regex patterns to the denylist. The
# regex matches against base names, not paths.
ignore-patterns=

# Add files or directories matching the regex patterns to the ignore-list.
# The regex matches against paths.
ignore-paths=setup.py,
docs,
examples,
mlflow/protos,
mlflow/server/js,
mlflow/store/db_migrations,
mlflow/temporary_db_migrations_for_pre_1_users

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=

# Use multiple processes to speed up Pylint.
jobs=1
jobs=0

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
Expand Down

0 comments on commit a8d1690

Please sign in to comment.