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

Introduce autoformatting bot #5065

Merged
merged 1 commit into from Dec 2, 2021
Merged

Introduce autoformatting bot #5065

merged 1 commit into from Dec 2, 2021

Conversation

harupy
Copy link
Member

@harupy harupy commented Nov 14, 2021

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

What changes are proposed in this pull request?

As the PR title describes, introduce an autoformatting bot. Note this bot only fixes auto-fixable errors (e.g. black errors).

How is this patch tested?

Tested using a PR on my fork: harupy/test-auto-format#8

Does this PR change the documentation?

  • No. You can skip the rest of this section.
  • Yes. Make sure the changed pages / sections render correctly by following the steps below.
  1. Check the status of the ci/circleci: build_doc check. If it's successful, proceed to the
    next step, otherwise fix it.
  2. Click Details on the right to open the job page of CircleCI.
  3. Click the Artifacts tab.
  4. Click docs/build/html/index.html.
  5. Find the changed pages / sections and make sure they render correctly.

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

@github-actions github-actions bot added the rn/none List under Small Changes in Changelogs. label Nov 14, 2021
lint.sh Outdated
Comment on lines 14 to 16
How to apply black formatting:
1. Run `pip install $(cat dev/lint-requirements.txt | grep "black==") && black .`
2. Comment `/autoformat` on the PR'
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
How to apply black formatting:
1. Run `pip install $(cat dev/lint-requirements.txt | grep "black==") && black .`
2. Comment `/autoformat` on the PR'
To apply black formatting, do one of the following:
1. Run `pip install $(cat dev/lint-requirements.txt | grep "black==") && black .`
2. Comment `/autoformat` on the PR'

Copy link
Member Author

Choose a reason for hiding this comment

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

^ Liang's suggestion

# As mentioned in the doc below, if we use `secrets.GITHUB_TOKEN`, a commit cerated by
# this workflow will not trigger other GitHub Actions workflows:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
# To make it work, register a personal access token for the mlflow-automation bot as
Copy link
Member

Choose a reason for hiding this comment

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

Should we add these steps to the CONTRIBUTING guidelines?

Copy link
Member Author

Choose a reason for hiding this comment

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

For someone who wants to run this workflow on their fork?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if there are any regular contributors who do this? I suppose if they are they're going to be reading over the Actions yaml configs when they set it up though.

id: check-diff
run: |
has_diff=$([[ -z "$(git diff)" ]] && echo "false" || echo "true")
echo "::set-output name=has_diff::$has_diff"
Copy link
Member

Choose a reason for hiding this comment

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

Did you want to include pylint checks from the repo's pylintrc for only the diff files as well to fast-fail since full linting checks take quite a bit of time to run?

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 for the comment! The role of this bot is to fix something auto-fixable, pylint errors are (usually) not auto-fixable.

Copy link
Member

Choose a reason for hiding this comment

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

With the local commit hook, I guess that would be redundant (you have to fix lint issues on diffs before a commit occurs anyway). This makes perfect sense to leave it solely up to black for automated adjustments.

@harupy harupy changed the title Introduce an autoformatting bot Introduce autoformatting bot Nov 18, 2021
Copy link
Member

@BenWilson2 BenWilson2 left a comment

Choose a reason for hiding this comment

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

The auto-commit formatting looks great on your fork!

Signed-off-by: harupy <hkawamura0130@gmail.com>
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

run: |
npm i
- run: |
npm run lint:fix
Copy link
Member

Choose a reason for hiding this comment

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

this is calling .eslintrc.js settings as defined in package.json operating solely on mlflow.server.js.src, right? So we're only looking at .js, .jsx, .ts, .tsx modules in src?
I'm likely completely wrong about this, but does jest's "collectCoverageFrom" apply to the lint:fix script execution to restrict auto-formatting lint corrections based on jest, or does it need to be explicitly defined in the lint:fix script config e.g., "lint:fix": "eslint src --fix --ext .js,.jsx,.ts,.tsx"?

Copy link
Member Author

Choose a reason for hiding this comment

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

@BenWilson2

we're only looking at .js, .jsx, .ts, .tsx modules in src?

Yes.

does jest's "collectCoverageFrom" apply to the lint:fix script execution

No, it doesn't.

@BenWilson2
Copy link
Member

LGTM

@harupy harupy merged commit cb873ab into mlflow:master Dec 2, 2021
@harupy harupy deleted the autoformatting branch December 2, 2021 00:32
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

3 participants