Skip to content

Commit

Permalink
Remove isort and black. Replace with ruff for all linting / formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanJDick committed Dec 7, 2023
1 parent 2cefdd1 commit 292e0c7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 38 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Check formatting with black
- name: Ruff lint
run: |
black --check .
- name: Check imports with isort
ruff check --output-format=github .
- name: Ruff format
run: |
isort --check-only .
- name: Lint with ruff
run: |
ruff --format=github .
ruff format --check .
- name: Test with pytest
run: |
pytest tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml -m "not cuda and not loads_model"
Expand Down
25 changes: 7 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
# See https://pre-commit.com/ for usage and config.
repos:
- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.7
hooks:
- id: black
name: black
language: system
entry: black
types: [python]

- id: isort
name: isort
language: system
entry: isort
types: [python]

- id: ruff
name: ruff
language: system
entry: ruff
types: [python]
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ python -m pip install --upgrade pip
# Editable install:
pip install -e ".[test]" --extra-index-url https://download.pytorch.org/whl/cu118
```
3. (Optional) Install the pre-commit hooks: `pre-commit install`. This will run static analysis tools (black, ruff, isort) on `git commit`.
4. (Optional) Set up `black`, `isort`, and `ruff` in your IDE of choice.
3. (Optional) Install the pre-commit hooks: `pre-commit install`. This will run static analysis tools (ruff) on `git commit`.
4. (Optional) Set `ruff` in your IDE of choice.

### Unit Tests
Run all unit tests with:
Expand Down
14 changes: 4 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ dependencies = [

[project.optional-dependencies]
"test" = [
"black~=23.7.0",
"isort~=5.12.0",
"pre-commit~=3.3.3",
"pytest~=7.4.0",
"ruff~=0.0.281",
# When bumping ruff, consider also bumping the ruff-pre-commit version in .pre-commit-config.yaml.
"ruff~=0.1.7",
]

[project.scripts]
Expand All @@ -56,14 +55,9 @@ dependencies = [
"Homepage" = "https://github.com/invoke-ai/invoke-training"
"Discord" = "https://discord.gg/ZmtBAhwWhy"

[tool.black]
line-length = 120

[tool.isort]
profile = "black"

[tool.ruff]
select = ["E", "F", "W", "C9", "N8"]
src = ["src"]
select = ["E", "F", "W", "C9", "N8", "I"]
target-version = "py39"
line-length = 120

Expand Down
2 changes: 1 addition & 1 deletion src/invoke_training/lora/injection/stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def inject_lora_into_clip_text_encoder(text_encoder: CLIPTextModel, prefix: str


def convert_lora_state_dict_to_kohya_format(
state_dict: typing.Dict[str, torch.Tensor]
state_dict: typing.Dict[str, torch.Tensor],
) -> typing.Dict[str, torch.Tensor]:
"""Convert a Stable Diffusion LoRA state_dict from internal invoke-training format to kohya_ss format.
Expand Down

0 comments on commit 292e0c7

Please sign in to comment.