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

tools(linter): Ruff #3539

Merged
merged 10 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ jobs:
black --check --pyi typings
isort --check .
- name: Lint check
if: ${{ github.event_name == 'pull_request' }}
run: git diff --name-only --diff-filter=d "origin/$GITHUB_BASE_REF" -z -- '*.py' | xargs -0 --no-run-if-empty pylint --rcfile pyproject.toml --fail-under 9.0 --exit-zero
run: ruff check src tests examples --fix
sauyon marked this conversation as resolved.
Show resolved Hide resolved
- name: Type check
if: ${{ github.event_name == 'pull_request' }}
run: git diff --name-only --diff-filter=d "origin/$GITHUB_BASE_REF" -z -- '*.py[i]' | xargs -0 --no-run-if-empty pyright
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ bentoml get IrisClassifier --verbose

formatter: [black](https://github.com/psf/black), [isort](https://github.com/PyCQA/isort), [buf](https://github.com/bufbuild/buf)

linter: [pylint](https://pylint.org/), [buf](https://github.com/bufbuild/buf)
linter: [ruff](https://github.com/charliermarsh/ruff), [buf](https://github.com/bufbuild/buf)

type checker: [pyright](https://github.com/microsoft/pyright)

Expand Down
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ format: ## Running code formatter: black and isort
format-proto: ## Running proto formatter: buf
@echo "Formatting proto files..."
docker run --init --rm --volume $(GIT_ROOT)/src:/workspace --workdir /workspace bufbuild/buf format --config "/workspace/bentoml/grpc/buf.yaml" -w bentoml/grpc
lint: ## Running lint checker: pylint
@echo "(pylint) Linting bentoml..."
@pylint --rcfile=pyproject.toml --fail-under 9.5 src
@echo "(pylint) Linting examples..."
@pylint --rcfile=pyproject.toml --fail-under 9.5 examples
@echo "(pylint) Linting tests..."
@pylint --rcfile=pyproject.toml --fail-under 9.5 tests
lint: ## Running lint checker: ruff
@echo "(ruff) Linting development project..."
@ruff check src examples tests --fix
aarnphm marked this conversation as resolved.
Show resolved Hide resolved
lint-proto: ## Running proto lint checker: buf
@echo "Linting proto files..."
docker run --init --rm --volume $(GIT_ROOT)/src:/workspace --workdir /workspace bufbuild/buf lint --config "/workspace/bentoml/grpc/buf.yaml" --error-format msvs bentoml/grpc
Expand Down
6 changes: 3 additions & 3 deletions examples/custom_model_runner/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import net
import torch
import torch.optim as optim
import torch.utils.data as data
import torch.nn.functional as F
from torchvision import datasets
from torchvision import transforms
from torch.utils.data import DataLoader
from torch.optim.lr_scheduler import StepLR


Expand Down Expand Up @@ -139,8 +139,8 @@ def main():
)
train_ds = datasets.MNIST("data", train=True, download=True, transform=transform)
test_ds = datasets.MNIST("data", train=False, transform=transform)
train_loader = data.DataLoader(train_ds, **train_kwargs)
test_loader = data.DataLoader(test_ds, **test_kwargs)
train_loader = DataLoader(train_ds, **train_kwargs)
test_loader = DataLoader(test_ds, **test_kwargs)

model = net.CNN().to(device)
optimizer = optim.Adadelta(model.parameters(), lr=args.lr)
Expand Down
1 change: 0 additions & 1 deletion examples/custom_runner/nltk_pretrained_model/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from statistics import mean

import nltk
from utils import exponential_buckets
from nltk.sentiment import SentimentIntensityAnalyzer

import bentoml
Expand Down
Loading