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

Clean up pylint command #5014

Merged
merged 1 commit into from Nov 8, 2021
Merged

Conversation

harupy
Copy link
Member

@harupy harupy commented Nov 7, 2021

Signed-off-by: harupy hkawamura0130@gmail.com

What changes are proposed in this pull request?

Clean up pylint command by specifying required options in pylintrc.

How is this patch tested?

NA

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

(Details in 1-2 sentences. You can just refer to another PR with a description if this PR is part of a larger change.)

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/artifacts: Artifact stores and artifact logging
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages
  • area/examples: Example code
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/projects: MLproject format, project running backends
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/server-infra: MLflow Tracking server backend
  • area/tracking: Tracking Service, tracking client APIs, autologging

Interface

  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/docker: Docker use across MLflow's components, such as MLflow Projects and MLflow Models
  • area/sqlalchemy: Use of SQLAlchemy in the Tracking Service or Model Registry
  • area/windows: Windows support

Language

  • language/r: R APIs and clients
  • language/java: Java APIs and clients
  • language/new: Proposals for new client languages

Integrations

  • integrations/azure: Azure and Azure ML integrations
  • integrations/sagemaker: SageMaker integrations
  • integrations/databricks: Databricks integrations

How should the PR be classified in the release notes? Choose one:

  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Signed-off-by: harupy <hkawamura0130@gmail.com>
@github-actions github-actions bot added the rn/none List under Small Changes in Changelogs. label Nov 7, 2021
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$')
Copy link
Member Author

@harupy harupy Nov 7, 2021

Choose a reason for hiding this comment

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

Once this PR has been merged, we can run pylint $(git diff --name-only | grep '\.py$') before making a commit to make sure there is no pylint error.

Copy link
Member Author

@harupy harupy Nov 7, 2021

Choose a reason for hiding this comment

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

You can also run pylint $(git diff --name-only | grep '\.py$') using a pre-commit for Git (this is the biggest motication of this PR for me).

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)
Copy link
Member Author

@harupy harupy Nov 8, 2021

Choose a reason for hiding this comment

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

I made the following changes:

  • Moved --jobs is specified in pylintrc.
  • Removed --msg-template since the default template is good enough.
  • Removed --rcfile because pylint automatically detects pylintrc.

Comment on lines 8 to +10
# 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=
Copy link
Member Author

Choose a reason for hiding this comment

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

Switched to using ignore-paths which is more accurate because it matches against paths, not base names.

else:
return []
return []
Copy link
Member Author

Choose a reason for hiding this comment

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

Required this change because pylint now checks scripts in the dev directory.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So pylint print warning for for ... else usage ?

Copy link
Member Author

@harupy harupy Nov 8, 2021

Choose a reason for hiding this comment

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

@WeichenXu123 No, pylint raises a warning when we use for-else without a break statement in the loop:

https://docs.quantifiedcode.com/python-anti-patterns/correctness/else_clause_on_loop_without_a_break_statement.html

# Example

def contains_magic_number(list, magic_number):
    for i in list:
        if i == magic_number:
            print("This list contains the magic number")
    else:
        print("This list does NOT contain the magic number")

res = subprocess.run(["pip", "list"], stdout=subprocess.PIPE)
res = subprocess.run(["pip", "list"], stdout=subprocess.PIPE, check=True)
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@WeichenXu123 WeichenXu123 left a comment

Choose a reason for hiding this comment

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

LGTM

@harupy harupy merged commit 3cd6ac8 into mlflow:master Nov 8, 2021
@harupy harupy deleted the clean-up-pylint-command branch November 8, 2021 04:16
@harupy harupy mentioned this pull request Nov 19, 2021
29 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rn/none List under Small Changes in Changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants