[Educational]: Add linting to Python files with `black`
See original GitHub issueFor new contributors only
We’re looking to add linting to torchserve to improve code quality and readability
Once we have a couple of files linted we can start asking contributors to lint their files before committing and I’ll add a github action to do a lint check on CI - @sudomaze already did this #1602
Since there’s a lot of .py
files which would be impossible to merge in a single code review I pulled out the 20 files with most commits and we can use them as a roadmap for what to do
If you’ve never contributed to torchserve before this is a great place to start, pick one of the files here and add linting to it, make a PR and make sure linting passes. Do not submit more than 1 PR or fixes to more than 1 lines this issue is mainly open for educational purposes
pip install black
- Run
black <file_to_lint.py>
- Make your PR and comment on this thread saying which of the below tasks should be closed. Only
git add
a single file at a time otherwise we won’t be able to code review - If all the tasks are done increase
head -n 20
to a bigger integer and pick a file there to contribute
The most important files to add linting to are the ones that change the most often i.e have the most commits
git rev-list --objects --all | awk '$2 ~ /\.py/' | awk '{print $2}' | sort -k2 | uniq -c | sort -rn | head -n 20
Number of commits, file
- 59 ts_scripts/install_dependencies.py - https://github.com/pytorch/serve/pull/1596
- 57 ts/torch_handler/base_handler.py https://github.com/pytorch/serve/pull/1597
- 52 ts/model_service_worker.py #1599
- 47 examples/Huggingface_Transformers/Transformer_handler_generalized.py https://github.com/pytorch/serve/pull/1612
- 42 ts_scripts/sanity_utils.py
- 41 test/pytest/test_handler.py
- 35 ts_scripts/tsutils.py
- 34 ts/model_server.py
- 34 benchmarks/benchmark-ab.py
- 29 ts_scripts/marsgen.py
- 29 ts/model_loader.py #1605
- 28 model-archiver/model_archiver/model_packaging.py
- 28 benchmarks/benchmark.py
- 24 torchserve_sanity.py
- 23 ts/torch_handler/object_detector.py #1603
- 23 model-archiver/model_archiver/model_packaging_utils.py
- 22 setup.py
- 21 ts_scripts/torchserve_grpc_client.py
- 21 model-archiver/model_archiver/manifest_components/model.py
- 21 model-archiver/model_archiver/arg_parser.py
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top GitHub Comments
I submitted PR #1605 , taking care of the linting for ts/model_loader.py
Just submitted PR #1604, taking care of the linting for
ts/model_server.py