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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pylint #11183

Merged
merged 25 commits into from Feb 20, 2024
Merged

Remove pylint #11183

merged 25 commits into from Feb 20, 2024

Conversation

harupy
Copy link
Member

@harupy harupy commented Feb 19, 2024

馃洜 DevTools 馃洜

Open in GitHub Codespaces

Install mlflow from this PR

pip install git+https://github.com/mlflow/mlflow.git@refs/pull/11183/merge

Checkout with GitHub CLI

gh pr checkout 11183

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

  • Remove pylint because it's very slow and we have ruff.
  • The custom rules (no-rst and lazy-builtin-import) have been migrated to a simple linter using the ast module, which is much faster than pylint.

Follow-up tasks

  • Remove pylint disable comments.

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

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.

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/deployments: MLflow Deployments client APIs, server, and third-party Deployments integrations
  • 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/recipes: Recipes, Recipe APIs, Recipe configs, Recipe Templates
  • 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/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/breaking-change - The PR will be mentioned in the "Breaking Changes" 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 <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
@github-actions github-actions bot added the rn/none List under Small Changes in Changelogs. label Feb 19, 2024
Copy link

github-actions bot commented Feb 19, 2024

Documentation preview for a6dcdba will be available when this CircleCI job
completes successfully.

More info

Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
@harupy harupy changed the title [WIP] Remove pylint Remove pylint Feb 20, 2024
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Copy link
Member Author

@harupy harupy Feb 20, 2024

Choose a reason for hiding this comment

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

Linting all files takes 0.6 ~ 0.7 sec on my machine:

% time clint $(git ls-files '*.py')
clint $(git ls-files '*.py')  4.93s user 0.59s system 815% cpu 0.677 total

% time clint $(git ls-files '*.py')
clint $(git ls-files '*.py')  4.75s user 0.59s system 823% cpu 0.649 total

% time clint $(git ls-files '*.py')
clint $(git ls-files '*.py')  4.70s user 0.58s system 805% cpu 0.655 total

Copy link
Member Author

Choose a reason for hiding this comment

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

pylint

% time pylint $(git ls-files '*.py')

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

pylint $(git ls-files '*.py')  192.85s user 38.47s system 794% cpu 29.106 total

Copy link
Collaborator

Choose a reason for hiding this comment

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

THIS IS LIFE CHANGING!!

Comment on lines 13 to 22
# Integrating with Visual Studio Code

1. Install [the Pylint extension](https://marketplace.visualstudio.com/items?itemName=ms-python.pylint)
2. Add the following setting in your `settings.json` file:

```json
{
"pylint.path": ["${interpreter}", "-m", "clint"]
}
```
Copy link
Member Author

@harupy harupy Feb 20, 2024

Choose a reason for hiding this comment

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

clint behaves like pylint and can be used with the pylint extension.

echo "::add-matcher::.github/workflows/matchers/format.json"
echo "::add-matcher::.github/workflows/matchers/ruff.json"
- uses: ./.github/actions/cache-pip
- name: Install dependencies
run: |
python -m venv .venv
source .venv/bin/activate
source ./dev/install-common-deps.sh --ml
Copy link
Member Author

Choose a reason for hiding this comment

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

Pylint also checks class inheritance, so we needed to install ML packages mlflow depends on.

Copy link
Collaborator

@B-Step62 B-Step62 left a comment

Choose a reason for hiding this comment

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

The result looks truly amazing!! Overall looks good to me, just added a few minor commnets.

- id: disallow-rule-ids
name: disallow-rule-ids
entry: python ./dev/disallow_rule_ids.py
- id: clint
Copy link
Collaborator

@B-Step62 B-Step62 Feb 20, 2024

Choose a reason for hiding this comment

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

Can we name the step a bit verbosely like "custom-python-lint", so that external contributors can easily tell what this step is?

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds good!

@@ -0,0 +1,22 @@
# Installation
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: a quick description of what this linter is for will be helpful

Copy link
Member Author

Choose a reason for hiding this comment

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

sure!

Copy link
Collaborator

Choose a reason for hiding this comment

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

THIS IS LIFE CHANGING!!

def __str__(self):
return f"{self.path}:{self.lineno}:{self.col_offset}: {self.rule.id}: {self.rule.message}"

def json(self) -> dict[str, str | int | None]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this JSON serialization used for? Perhaps VSCode integration? (just curious about the difference from pylint plugins' implementation)

Copy link
Member Author

@harupy harupy Feb 20, 2024

Choose a reason for hiding this comment

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

It's used by the pylint extension :) The pylint extension (written in typescript) runs pylint in a subprocess and parse stdout as JSON to collect lint errors.


def visit_ClassDef(self, node: ast.ClassDef) -> None:
self.stack.append(node)
self._no_rst(node)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is more about future extension, but is it possible to define those rules pluggable like pylint (or perhaps declarative)? Currently when we want to add/remove rules for clint, we need to directly edit the single node traversal class, which might be a bit error-prone. Of course it doesn't need to be in this PR but sth we can think of in long-term.

Copy link
Member Author

@harupy harupy Feb 20, 2024

Choose a reason for hiding this comment

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

It's possible to define a visitor for each rule like pylint but it has a con. That's slow because each visitor needs to traverse the code. I'd consider making this pluggable if we had more (> 5) rules.

Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
@harupy harupy merged commit 8915365 into mlflow:master Feb 20, 2024
41 checks passed
@harupy harupy deleted the remove-pylint branch February 20, 2024 10:55
@harupy harupy mentioned this pull request Feb 20, 2024
37 tasks
sateeshmannar pushed a commit to StateFarmIns/mlflow that referenced this pull request Feb 20, 2024
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
artjen pushed a commit to artjen/mlflow that referenced this pull request Mar 26, 2024
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: Arthur Jenoudet <arthur.jenoudet@databricks.com>
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