Skip to content

Commit

Permalink
ci: add isort to the ruff lint rules (#4032)
Browse files Browse the repository at this point in the history
Co-authored-by: aarnphm-ec2-dev <[email protected]>
  • Loading branch information
frostming and aarnphm authored Jul 11, 2023
1 parent 7fb4578 commit 79b10e9
Show file tree
Hide file tree
Showing 283 changed files with 1,328 additions and 1,324 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ ci:
autoupdate_schedule: monthly
exclude: '.*\.(css|js|svg)$'
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.274'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.277'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
Expand Down
2 changes: 1 addition & 1 deletion docs/source/frameworks/diffusers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can import a pretrained diffusion model from huggingface hub or local direct
"sd2.1", # model tag in BentoML model store
"stabilityai/stable-diffusion-2-1", # huggingface model name
)
If you plan to use the model with a custom pipeline that has method other than :code:`__call__` (e.g. a :code:`StableDiffusionMegaPipeline`), you need to explicitly list them like this:

Expand Down
4 changes: 2 additions & 2 deletions examples/custom_model_runner/locustfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from locust import task
from locust import between
from locust import HttpUser
from locust import between
from locust import task


class MnistTestUser(HttpUser):
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 @@ -4,12 +4,12 @@

import net
import torch
import torch.optim as optim
import torch.nn.functional as F
import torch.optim as optim
from torch.optim.lr_scheduler import StepLR
from torch.utils.data import DataLoader
from torchvision import datasets
from torchvision import transforms
from torch.utils.data import DataLoader
from torch.optim.lr_scheduler import StepLR


def train(args, model, device, train_loader, optimizer, epoch):
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_runner/nltk_pretrained_model/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import time
import typing as t
from typing import TYPE_CHECKING
from statistics import mean
from typing import TYPE_CHECKING

import nltk
from nltk.sentiment import SentimentIntensityAnalyzer
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_web_serving/fastapi_example/train.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging

import pandas as pd
from sklearn import svm
from sklearn import datasets
from sklearn import svm

import bentoml

Expand Down
2 changes: 1 addition & 1 deletion examples/custom_web_serving/flask_example/train.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from sklearn import svm
from sklearn import datasets
from sklearn import svm

import bentoml

Expand Down
10 changes: 5 additions & 5 deletions examples/flax/MNIST/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
from __future__ import annotations

import contextlib
import os
import subprocess
import sys
import typing as t
import contextlib
import subprocess
from typing import TYPE_CHECKING

import psutil
import pytest

import bentoml
from bentoml.testing.server import host_bento
from bentoml._internal.configuration.containers import BentoMLContainer
from bentoml.testing.server import host_bento

if TYPE_CHECKING:
from contextlib import ExitStack

from _pytest.main import Session
from _pytest.nodes import Item
from _pytest.config import Config
from _pytest.fixtures import FixtureRequest as _PytestFixtureRequest
from _pytest.main import Session
from _pytest.nodes import Item

class FixtureRequest(_PytestFixtureRequest):
param: str
Expand Down
2 changes: 1 addition & 1 deletion examples/flax/MNIST/tests/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import pytest

import bentoml
from bentoml.testing.grpc import create_channel
from bentoml.testing.grpc import async_client_call
from bentoml.testing.grpc import create_channel

if t.TYPE_CHECKING:
import jax.numpy as jnp
Expand Down
8 changes: 4 additions & 4 deletions examples/flax/MNIST/train.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# modified from https://github.com/google/flax/blob/main/examples/mnist/README.md
from __future__ import annotations

import argparse
import os
import typing as t
import argparse
from typing import TYPE_CHECKING

import jax
import attrs
import numpy as np
import optax
import cattrs
import jax
import jax.numpy as jnp
import numpy as np
import optax
import tensorflow_datasets as tfds
from flax import linen as nn
from flax import serialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import numpy as np
import pandas as pd
from sample import sample_input
from fastapi import FastAPI
from fastapi import Request
from sample import sample_input

import bentoml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import numpy as np
import pandas as pd
from sample import sample_input
from fastapi import FastAPI
from fastapi import Request
from sample import sample_input

import bentoml

Expand Down
4 changes: 2 additions & 2 deletions examples/fraud_detection/benchmark/locustfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np
import pandas as pd
from locust import task
from locust import between
from locust import HttpUser
from locust import between
from locust import task

NUM_OF_ROWS = 500
test_transactions = pd.read_csv("../data/test_transaction.csv")[0:NUM_OF_ROWS]
Expand Down
2 changes: 1 addition & 1 deletion examples/kfserving/train.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from sklearn import svm
from sklearn import datasets
from sklearn import svm

import bentoml

Expand Down
7 changes: 3 additions & 4 deletions examples/mlflow/keras/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
on the Reuters newswire topic classification task.
"""
# pylint: disable=no-name-in-module
import numpy as np

# The following import and function call are the only additions to code required
# to automatically log metrics and parameters to MLflow.
import mlflow.keras
import numpy as np
from tensorflow import keras
from tensorflow.keras.datasets import reuters
from tensorflow.keras.layers import Activation
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
from tensorflow.keras.layers import Activation
from tensorflow.keras.models import Sequential
from tensorflow.keras.datasets import reuters
from tensorflow.keras.preprocessing.text import Tokenizer

import bentoml
Expand Down
4 changes: 2 additions & 2 deletions examples/mlflow/lightgbm/train.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import argparse

import mlflow
import lightgbm as lgb
import matplotlib as mpl
import mlflow
import mlflow.lightgbm
from sklearn import datasets
from sklearn.metrics import log_loss
from sklearn.metrics import accuracy_score
from sklearn.metrics import log_loss
from sklearn.model_selection import train_test_split

import bentoml
Expand Down
8 changes: 4 additions & 4 deletions examples/mlflow/pytorch/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
#
# BentoML example is based on https://github.com/mlflow/mlflow/blob/master/examples/pytorch/mnist_tensorboard_artifact.py
#
import os
import argparse
import os

import torch
import mlflow
import torch.nn as nn
import torch.optim as optim
import mlflow.pytorch
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets
from torchvision import transforms

Expand Down
4 changes: 2 additions & 2 deletions examples/mlflow/sklearn_autolog/grid_search_cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import mlflow
import pandas as pd
from utils import fetch_logged_data
from sklearn import svm
from sklearn import datasets
from sklearn import svm
from sklearn.model_selection import GridSearchCV
from utils import fetch_logged_data

import bentoml

Expand Down
4 changes: 2 additions & 2 deletions examples/mlflow/sklearn_autolog/linear_regression.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pprint import pprint

import numpy as np
import mlflow
from utils import fetch_logged_data
import numpy as np
from sklearn.linear_model import LinearRegression
from utils import fetch_logged_data

import bentoml

Expand Down
6 changes: 3 additions & 3 deletions examples/mlflow/sklearn_autolog/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pprint import pprint

import numpy as np
import mlflow
from utils import fetch_logged_data
from sklearn.pipeline import Pipeline
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from utils import fetch_logged_data

import bentoml

Expand Down
2 changes: 1 addition & 1 deletion examples/mlflow/sklearn_logistic_regression/train.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import mlflow
import mlflow.sklearn
import numpy as np
from sklearn.linear_model import LogisticRegression

import bentoml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# pylint: disable=abstract-method,redefined-outer-name
import argparse

import mlflow.pytorch
import numpy as np
import torch
import torch.nn as nn
import mlflow.pytorch
import torch.nn.functional as F
from sklearn.metrics import accuracy_score
from sklearn.datasets import load_iris
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split

import bentoml
Expand Down
8 changes: 4 additions & 4 deletions examples/mlflow/torchscript/MNIST/mnist_torchscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import argparse

import mlflow
import mlflow.pytorch
import numpy as np
import torch
import mlflow
import torch.nn as nn
import torch.optim as optim
import mlflow.pytorch
import torch.nn.functional as F
import torch.optim as optim
from torch.optim.lr_scheduler import StepLR
from torchvision import datasets
from torchvision import transforms
from torch.optim.lr_scheduler import StepLR

import bentoml

Expand Down
4 changes: 2 additions & 2 deletions examples/monitoring/task_classification/locustfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from locust import task
from locust import between
from locust import HttpUser
from locust import between
from locust import task
from sklearn import datasets

test_data = datasets.load_iris().data
Expand Down
2 changes: 1 addition & 1 deletion examples/monitoring/task_classification/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import numpy as np

import bentoml
from bentoml.io import Text
from bentoml.io import NumpyNdarray
from bentoml.io import Text

CLASS_NAMES = ["setosa", "versicolor", "virginica"]

Expand Down
8 changes: 4 additions & 4 deletions examples/monitoring/task_classification/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import annotations

import contextlib
import os
import subprocess
import sys
import typing as t
import contextlib
import subprocess
from pathlib import Path

import numpy as np
Expand All @@ -14,11 +14,11 @@
from bentoml._internal.configuration.containers import BentoMLContainer

if t.TYPE_CHECKING:
from _pytest.config import Config
from _pytest.fixtures import FixtureRequest
from _pytest.main import Session
from _pytest.nodes import Item
from _pytest.config import Config
from _pytest.tmpdir import TempPathFactory
from _pytest.fixtures import FixtureRequest

PROJECT_DIR = Path(__file__).parent.parent

Expand Down
2 changes: 1 addition & 1 deletion examples/monitoring/task_classification/train.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from sklearn import svm
from sklearn import datasets
from sklearn import svm

import bentoml

Expand Down
2 changes: 1 addition & 1 deletion examples/pydantic_validation/train.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging

import pandas as pd
from sklearn import svm
from sklearn import datasets
from sklearn import svm

import bentoml

Expand Down
4 changes: 2 additions & 2 deletions examples/pytorch_mnist/locustfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from locust import task
from locust import between
from locust import HttpUser
from locust import between
from locust import task

with open("samples/1.png", "rb") as f:
test_image_bytes = f.read()
Expand Down
Loading

0 comments on commit 79b10e9

Please sign in to comment.