-
Notifications
You must be signed in to change notification settings - Fork 64
[Lint] Add Lint and move metadata from setup.py to pyproject.toml #120
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
Conversation
Move metadata into pyproject.toml [Lint] Add CI
Move metadata into pyproject.toml [Lint] Add CI
A generic question (on the broader topic): Is there any way for a reviewer to turn off the github warning messages in the UI? They seem appropriate for the person who created the PR, but takes up a lot of screen space for the reviewer. |
@@ -0,0 +1,33 @@ | |||
#!/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that this is only for checking? How many of these can be fixed automatically? Can we create a utility for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will see if I can include some useful auto-formatter and put them into a bash script.
Sorry, that's my fault that I used ONNX setting, but didn't include pylint for now (since it warns a lot.). Ususally the warning message wouldn't be this much. The warning message are all about pylint, and I haven't adjusted that (In normal case, you get the warning in local, and address it). But some checks I would suggest we keep it on UI, like misspelling. I will add pylint in the next commit. |
- name: Setup Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: "3.10" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can install all dev dependencies to help pylint find onnx etc.
@@ -59,10 +60,6 @@ steps: | |||
pytest -v onnxscript --cov=onnxscript --cov-report term-missing | |||
displayName: 'pytest' | |||
|
|||
- script: | | |||
python -m flake8 onnxscript --max-line-length 95 --exclude "**test/models/*.py,**onnx_backend_test_code/*.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be irrelevant to this PR: does anyone know why these files are ignored for formatter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the tests are about how you can use onnx_script, and those writings doesn't have to follow formatting as it's "user-side code". but cc @gramalingam
|
||
jobs: | ||
lint-python: | ||
name: Lint Python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider limiting the github token's permission for this job:
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried an easy fix with permission - read only on PR didn't work.
track #127
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SG. Can be another pr imo
cc @gramalingam for final review. |
@@ -0,0 +1,25 @@ | |||
#!/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add something for windows? That would be great, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have .bat version in another PR. #127
.flake8
Outdated
@@ -0,0 +1,16 @@ | |||
# flake8 is currebtly not yet supported by pyproject.toml. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
misspelling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pyproject.toml
Outdated
"License :: OSI Approved :: Apache Software License", | ||
] | ||
# NOTE: replace requirements.txt | ||
dependencies = ["numpy==1.21.5", "protobuf<4", "onnx"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can replace == by >= ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Should be merged after #120 fixes #125 1. add `auto-formatter` **lint.sh** (feel free to add on others) 2. flake8, black, and isort formatting is clean now 3. pylint and mypy is a lot of work to address - need everyone address these step by step (also take them out from style.sh, and make style_optional.sh CI test for them.) 4. relative path addressed (import module instead of class and function) 5. We should enable Lint/Enforce as mandatory 6. Move debuginfo stand alone as it caused circular import. NOTE: I hope this one can be quickly merged, as there are PRs being merged constantly which means endless merge conflict for this one. Co-authored-by: Ubuntu <titaiwang@titaiwanglinuxcpudev.y3zdd0j2xrqelnmezcgpqgmnte.jx.internal.cloudapp.net>
This PR basically migrates the lint and CI from ONNX to here.
Add lint: black, isort, mypy, and flake8
Add pyproject.toml (includes what was in requirements.txt, setup.cfg, and metadata in setup.py)
Add lint CI to align coding style
Lint / Enforce style (pull_request)
CI utilizes style.sh to do the testLint / Enforce style (pull_request)
as required after a reasonable transition time periodContinue work (actually apply lint on files) on [Lint] Apply lint #126
fixes #105