forked from qubvel-org/segmentation_models.pytorch
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Ruff #23
Merged
Merged
Ruff #23
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f9d91a8
add ruff, remove black/flake8/isort/pyupgrade
isaaccorley e3d05dc
update ruff commands and settings
isaaccorley 1118d17
fix import sorting
isaaccorley 658eeaa
update to auto fix when running ruff check
isaaccorley 874468a
test that CI throws an error
isaaccorley 2d29c9b
try again
isaaccorley 85a702e
try without output format
isaaccorley 27827e4
fix
isaaccorley 1dcaa36
update min version of ruff
isaaccorley 75eb401
update
isaaccorley 6930106
add output-format=github
isaaccorley 07caa22
fixes per suggestions
isaaccorley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,18 +9,18 @@ on: | |
- main | ||
- release** | ||
jobs: | ||
black: | ||
name: black | ||
ruff: | ||
name: ruff | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repo | ||
uses: actions/[email protected].1 | ||
uses: actions/[email protected].2 | ||
- name: Set up python | ||
uses: actions/setup-python@v5.0.0 | ||
uses: actions/setup-python@v5.1.0 | ||
with: | ||
python-version: '3.11' | ||
python-version: '3.12' | ||
- name: Cache dependencies | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].2 | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
|
@@ -32,83 +32,10 @@ jobs: | |
pip cache purge | ||
- name: List pip dependencies | ||
run: pip list | ||
- name: Run black checks | ||
run: black . --check --diff | ||
flake8: | ||
name: flake8 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repo | ||
uses: actions/[email protected] | ||
- name: Set up python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: '3.11' | ||
- name: Cache dependencies | ||
uses: actions/[email protected] | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} | ||
- name: Install pip dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
pip install -r requirements/style.txt | ||
pip cache purge | ||
- name: List pip dependencies | ||
run: pip list | ||
- name: Run flake8 checks | ||
run: flake8 | ||
isort: | ||
name: isort | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repo | ||
uses: actions/[email protected] | ||
- name: Set up python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: '3.11' | ||
- name: Cache dependencies | ||
uses: actions/[email protected] | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} | ||
- name: Install pip dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
- name: Run ruff checks | ||
run: | | ||
pip install -r requirements/style.txt | ||
pip cache purge | ||
- name: List pip dependencies | ||
run: pip list | ||
- name: Run isort checks | ||
run: isort . --check --diff | ||
pyupgrade: | ||
name: pyupgrade | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repo | ||
uses: actions/[email protected] | ||
- name: Set up python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: '3.11' | ||
- name: Cache dependencies | ||
uses: actions/[email protected] | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} | ||
- name: Install pip dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
pip install -r requirements/style.txt | ||
pip cache purge | ||
- name: List pip dependencies | ||
run: pip list | ||
- name: Run pyupgrade checks | ||
run: pyupgrade --py39-plus | ||
ruff check --output-format=github --no-fix . | ||
ruff format --diff | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }} | ||
cancel-in-progress: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
data/ | ||
images/ | ||
logo/ | ||
logs/ | ||
output/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ The goal of this fork is to 1) provide maintenance support for the original libr | |
Additionally we have performed the following for improved software standards: | ||
|
||
- More thorough testing and CI | ||
- Formatting using `black`, `isort`, `flake8`, `mypy` | ||
- Formatting using `ruff` and `mypy` | ||
- Reduction of dependence on unmaintained libraries (now depends only on `torch`, `timm`, and `einops`) | ||
- Reduce lines of code to maintain (removed custom utils, metrics, encoders) in favor of newer libraries such as `torchmetrics` and `timm` | ||
|
||
|
@@ -227,3 +227,19 @@ Note that some models like `ConvNext` and `Swin` only have 4 intermediate featur | |
```python | ||
model = torchseg.Unet('resnet50', encoder_depth=4) | ||
``` | ||
|
||
## Contribute | ||
|
||
We welcome new contributions for modern semantic segmentation models, losses, and methods! | ||
|
||
#### Install dev dependencies | ||
|
||
For development you can install the required dependencies using `pip install '.[all]'. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should really be in a separate PR too |
||
|
||
#### Code Formatting/Linting | ||
|
||
To format files run `ruff format`. To check for linting errors run `ruff check`. | ||
|
||
#### Tests | ||
|
||
To run tests use `pytest -ra` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,10 +40,8 @@ dynamic = ["version"] | |
|
||
[project.optional-dependencies] | ||
style = [ | ||
"black[jupyter]>=21.8", | ||
"flake8>=3.8", | ||
"isort[colors]>=5.8", | ||
"pyupgrade>=2.8", | ||
# ruff 0.2+ required for [ruff.lint] | ||
"ruff>=0.2.0" | ||
] | ||
tests = [ | ||
"pytest>=7.3", | ||
|
@@ -56,11 +54,6 @@ all = [ | |
[project.urls] | ||
Homepage = "https://github.com/isaaccorley/torchseg" | ||
|
||
[tool.black] | ||
target-version = ["py39", "py310"] | ||
color = true | ||
skip_magic_trailing_comma = true | ||
|
||
[tool.coverage.report] | ||
# Ignore warnings for overloads | ||
# https://github.com/nedbat/coveragepy/issues/970#issuecomment-612602180 | ||
|
@@ -69,12 +62,6 @@ exclude_lines = [ | |
"@overload", | ||
] | ||
|
||
[tool.isort] | ||
profile = "black" | ||
known_first_party = ["tests", "torchseg", "train"] | ||
skip_gitignore = true | ||
color_output = true | ||
|
||
[tool.pytest.ini_options] | ||
norecursedirs = [ | ||
".ipynb_checkpoints", | ||
|
@@ -95,3 +82,19 @@ torchseg = ["py.typed"] | |
|
||
[tool.setuptools.packages.find] | ||
include = ["torchseg*"] | ||
|
||
[tool.ruff] | ||
fix = true | ||
show-fixes = true | ||
|
||
[tool.ruff.format] | ||
skip-magic-trailing-comma = true | ||
|
||
[tool.ruff.lint] | ||
extend-select = ["I", "UP"] | ||
|
||
[tool.ruff.lint.isort] | ||
split-on-trailing-comma = false | ||
|
||
[tool.ruff.lint.pydocstyle] | ||
convention = "google" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't being used yet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
# style | ||
black[jupyter]==24.3.0 | ||
flake8==7.0.0 | ||
isort[colors]==5.13.2 | ||
pyupgrade==3.15.2 | ||
ruff==0.3.7 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Most of these version bumps should be saved for another PR, probably by dependabot