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

Fix linting in examples folder #180

Merged
merged 7 commits into from Jul 7, 2022

Conversation

thinkcache
Copy link
Contributor

Issue #136

@thinkcache thinkcache marked this pull request as ready for review July 3, 2022 09:02
@thinkcache
Copy link
Contributor Author

Current issues:

pylint -j 8 --recursive=y mosec examples
************* Module distil_bert_server_pytorch
examples/distil_bert_server_pytorch.py:66:12: E1101: Module 'torch' has no 'device' member (no-member)
examples/distil_bert_server_pytorch.py:66:67: E1101: Module 'torch' has no 'device' member (no-member)
examples/distil_bert_server_pytorch.py:81:19: E1101: Module 'torch' has no 'tensor' member; maybe 'Tensor'? (no-member)
************* Module resnet50_server_pytorch
examples/resnet50_server_pytorch.py:50:18: E1101: Module 'cv2' has no 'imdecode' member (no-member)
examples/resnet50_server_pytorch.py:50:36: E1101: Module 'cv2' has no 'IMREAD_COLOR' member (no-member)
examples/resnet50_server_pytorch.py:56:14: E1101: Module 'cv2' has no 'resize' member (no-member)
examples/resnet50_server_pytorch.py:72:12: E1101: Module 'torch' has no 'device' member (no-member)
examples/resnet50_server_pytorch.py:72:67: E1101: Module 'torch' has no 'device' member (no-member)
examples/resnet50_server_pytorch.py:87:20: E1101: Module 'torch' has no 'stack' member (no-member)
examples/resnet50_server_pytorch.py:87:33: E1101: Module 'torch' has no 'tensor' member; maybe 'Tensor'? (no-member)
examples/resnet50_server_pytorch.py:89:19: E1101: Module 'torch' has no 'argmax' member (no-member)

------------------------------------------------------------------
Your code has been rated at 9.24/10 (previous run: 9.27/10, -0.03)

make: *** [lint] Error 2

A possible solution as per pytorch/pytorch#701
This creates another error.

pylint -j 8 --recursive=y mosec examples
************* Module mosec.worker
mosec/worker.py:64:0: R0022: Useless option value for 'disable', 'no-self-use' was moved to an optional extension, see https://pylint.pycqa.org/en/latest/whatsnew/2/2.14/summary.html#removed-checkers. (useless-option-value)
************* Module mosec.server
mosec/server.py:306:4: R0913: Too many arguments (6/5) (too-many-arguments)

------------------------------------------------------------------
Your code has been rated at 9.97/10 (previous run: 9.24/10, +0.73)

make: *** [lint] Error 8

any help is appreciated.

@kemingy
Copy link
Member

kemingy commented Jul 3, 2022

Should we use pylint --disable=import-error examples? Or maybe we should place these examples in another repo?

  • there may be lots of other 3rd libraries required in the examples, it will cost lots of time to prepare the environment to run the lint
  • those import errors are not very helpful

@lkevinzc What do you think?

@lkevinzc
Copy link
Member

lkevinzc commented Jul 4, 2022

Should we use pylint --disable=import-error examples? Or maybe we should place these examples in another repo?

  • there may be lots of other 3rd libraries required in the examples, it will cost lots of time to prepare the environment to run the lint
  • those import errors are not very helpful

@lkevinzc What do you think?

How about locally we do lint for all codes including those under examples, but we do not do that in CI? Local dev environment should have those third parties installed. Doing full lint for examples benefits code styles.

@kemingy
Copy link
Member

kemingy commented Jul 4, 2022

How about locally we do lint for all codes including those under examples, but we do not do that in CI? Local dev environment should have those third parties installed. Doing full lint for examples benefits code styles.

I think we can ignore the import errors in this PR. It's better to have a CI to make sure all the examples can run with the latest code. We can track this in another issue.

@lkevinzc
Copy link
Member

lkevinzc commented Jul 4, 2022

I think we can ignore the import errors in this PR. It's better to have a CI to make sure all the examples can run with the latest code. We can track this in another issue.

LGTM.

Copy link
Member

@kemingy kemingy left a comment

Choose a reason for hiding this comment

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

Hi @thinkcache, can try this Makefile to ignore the import errors.

Makefile Outdated Show resolved Hide resolved
@kemingy
Copy link
Member

kemingy commented Jul 4, 2022

@thinkcache For the lint error in mosec/, I cannot reproduce this one. Which pylint version are you using now? I'm using 2.14.4. It should be able to read the config from pyproject.toml file.

thinkcache and others added 2 commits July 6, 2022 21:52
Co-authored-by: Keming <kemingy94@gmail.com>
@thinkcache
Copy link
Contributor Author

thinkcache commented Jul 6, 2022

Latest run:

pylint -j 8 --recursive=y --disable=import-error examples --generated-members=numpy.*,torch.*,cv2.*,cv.*

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

ref: pytorch/pytorch#701

@kemingy please review.

@thinkcache thinkcache requested a review from kemingy July 6, 2022 16:46
@kemingy
Copy link
Member

kemingy commented Jul 7, 2022

That's weird. I can pass all the lint locally. How come it doesn't have consistent results?

From the CI results, it seems reasonable. But I guess it's also okay to ignore R,C for the examples.

What do you think? @lkevinzc

pylint -j 8 --recursive=y --disable=R,C,import-error examples --generated-members=numpy.*,torch.*,cv2.*,cv.*

@lkevinzc
Copy link
Member

lkevinzc commented Jul 7, 2022

That's weird. I can pass all the lint locally. How come it doesn't have consistent results?

From the CI results, it seems reasonable. But I guess it's also okay to ignore R,C for the examples.

What do you think? @lkevinzc

pylint -j 8 --recursive=y --disable=R,C,import-error examples --generated-members=numpy.*,torch.*,cv2.*,cv.*

Figured out that CI got error messages because the py environment does not install mosec dev package. I tested locally and found if I pip uninstall mosec I can reproduce the error; but the error disappears after I pip install -e .

@lkevinzc
Copy link
Member

lkevinzc commented Jul 7, 2022

Figured out that CI got error messages because the py environment does not install mosec dev package. I tested locally and found if I pip uninstall mosec I can reproduce the error; but the error disappears after I pip install -e .

@thinkcache Could you help to add one line pip install -e . in the Makefile's lint (just put it at the first line) to fix the CI errors pls? Thanks!

@thinkcache
Copy link
Contributor Author

@lkevinzc
changes added. Can you trigger the CI build to test if this worked?

@kemingy kemingy merged commit 8440ebc into mosecorg:main Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants