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

ci: Check import formatting with isort #324

Merged
merged 12 commits into from
Nov 9, 2020

Conversation

akihironitta
Copy link
Contributor

@akihironitta akihironitta commented Oct 31, 2020

What does this PR do?

Replicates Lightning-AI/pytorch-lightning#4241. WIP in PL as well in Lightning-AI/pytorch-lightning#4242.

Description of the changes

  • Add isort config to pyproject.toml which is recommended in docs
  • Add CI check to .github/workflows/code-format.yml
  • Disable import check by other checkers if one exists
  • Apply isort to the codebase
  • Add isort pre-commit hook
  • ...?

Let me know if I should split this PR!

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

  • Is this pull request ready for review? (if not, please submit in draft mode)

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@codecov
Copy link

codecov bot commented Oct 31, 2020

Codecov Report

Merging #324 (8dd1416) into master (4d254fd) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #324      +/-   ##
==========================================
- Coverage   82.42%   82.39%   -0.03%     
==========================================
  Files         100      100              
  Lines        5621     5613       -8     
==========================================
- Hits         4633     4625       -8     
  Misses        988      988              
Flag Coverage Δ
cpu 24.66% <67.50%> (-0.09%) ⬇️
pytest 24.66% <67.50%> (-0.09%) ⬇️
unittests 81.64% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pl_bolts/datasets/__init__.py 100.00% <ø> (ø)
pl_bolts/models/self_supervised/amdim/__init__.py 80.00% <ø> (ø)
pl_bolts/models/self_supervised/amdim/datasets.py 61.11% <ø> (ø)
..._bolts/models/self_supervised/cpc/cpc_finetuner.py 100.00% <ø> (ø)
pl_bolts/models/self_supervised/cpc/cpc_module.py 20.31% <ø> (ø)
pl_bolts/models/self_supervised/moco/__init__.py 100.00% <ø> (ø)
pl_bolts/models/self_supervised/moco/transforms.py 100.00% <ø> (ø)
.../models/self_supervised/simclr/simclr_finetuner.py 100.00% <ø> (ø)
pl_bolts/models/self_supervised/swav/__init__.py 100.00% <ø> (ø)
pl_bolts/__init__.py 100.00% <100.00%> (ø)
... and 30 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d254fd...8dd1416. Read the comment docs.

@Borda Borda added enhancement New feature or request ci/cd Continues Integration and delivery labels Nov 6, 2020
@Borda
Copy link
Member

Borda commented Nov 6, 2020

@akihironitta how is it going here? seems to be empty...

@akihironitta
Copy link
Contributor Author

Not a strong opinion, but I prefer to use force_single_line = 'True' option as I think it looks neat. Any thoughts?

-from pl_bolts.datasets import DummyDataset, RandomDataset, RandomDictDataset, RandomDictStringDataset
+from pl_bolts.datasets import DummyDataset
+from pl_bolts.datasets import RandomDataset
+from pl_bolts.datasets import RandomDictDataset
+from pl_bolts.datasets import RandomDictStringDatase

@akihironitta akihironitta changed the title [WIP] ci: Check import formatting with isort ci: Check import formatting with isort Nov 7, 2020
@akihironitta akihironitta marked this pull request as ready for review November 7, 2020 19:13
@Borda
Copy link
Member

Borda commented Nov 9, 2020

from pl_bolts.datasets import DummyDataset, RandomDataset, RandomDictDataset, RandomDictStringDataset

if it loading from a single file, I would prefer a single line...

.github/workflows/code-format.yml Outdated Show resolved Hide resolved
@Borda Borda added the ready label Nov 9, 2020
@Borda
Copy link
Member

Borda commented Nov 9, 2020

@akihironitta I would welcome adding something similar also for PL, just in smaller steps, meaning one PR per PL/sub-package and then in the config enable one-by-one...

@Borda Borda merged commit 27855d0 into Lightning-Universe:master Nov 9, 2020
ananyahjha93 added a commit that referenced this pull request Nov 9, 2020
* add core members

* ci: Check import formatting with `isort` (#324)

* Create branch ci/add-import-checker

* Add isort to ci

* Add pyproject.toml

* Apply isort

* Update pyproject.toml

* Add isort to requirements/test.txt

* Add pre-commit to requirements/test.txt

* Add isort hook from the official repo

* Update isort pre-commit config

* Split flake8 and isort checks

* suggestion-name

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>

* fix missing

* added core maintainers

* added core

Co-authored-by: Akihiro Nitta <nitta@akihironitta.com>
Co-authored-by: ananyahjha93 <ananya@pytorchlightning.ai>
@akihironitta akihironitta deleted the ci/add-import-checker branch November 10, 2020 05:06
@akihironitta
Copy link
Contributor Author

@akihironitta I would welcome adding something similar also for PL, just in smaller steps, meaning one PR per PL/sub-package and then in the config enable one-by-one...

@Borda Sure!

@Borda Borda added this to the v0.3 milestone Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/cd Continues Integration and delivery enhancement New feature or request ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants