From e48ec2e1037e6174356cd6e17191a580d5cd7cb0 Mon Sep 17 00:00:00 2001 From: Hayk Martiros Date: Mon, 26 Dec 2022 18:12:02 -0800 Subject: [PATCH] Enable ruff import sorting Topic: import_sorting --- integrations/baseten.py | 5 ++--- pyproject.toml | 2 +- riffusion/cli.py | 2 +- riffusion/datatypes.py | 2 +- riffusion/riffusion_pipeline.py | 3 +-- riffusion/server.py | 10 ++++------ riffusion/spectrogram_converter.py | 6 +++--- riffusion/spectrogram_image_converter.py | 2 +- riffusion/spectrogram_params.py | 2 +- test/image_util_test.py | 2 +- test/linter_test.py | 2 +- test/spectrogram_image_converter_test.py | 2 +- test/test_case.py | 4 ++-- 13 files changed, 20 insertions(+), 24 deletions(-) diff --git a/integrations/baseten.py b/integrations/baseten.py index 18af805..9fd863b 100644 --- a/integrations/baseten.py +++ b/integrations/baseten.py @@ -8,14 +8,13 @@ For more on the Truss file format, see https://truss.baseten.co/ import typing as T -import torch import dacite - +import torch from huggingface_hub import snapshot_download +from riffusion.datatypes import InferenceInput from riffusion.riffusion_pipeline import RiffusionPipeline from riffusion.server import compute_request -from riffusion.datatypes import InferenceInput class Model: diff --git a/pyproject.toml b/pyproject.toml index c6fb776..18e177d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ select = [ "E", "W", # isort - # "I001" + "I001" ] ignore = [] diff --git a/riffusion/cli.py b/riffusion/cli.py index 2022c05..221848d 100644 --- a/riffusion/cli.py +++ b/riffusion/cli.py @@ -6,8 +6,8 @@ from pathlib import Path import argh import numpy as np -from PIL import Image import pydub +from PIL import Image from riffusion.spectrogram_image_converter import SpectrogramImageConverter from riffusion.spectrogram_params import SpectrogramParams diff --git a/riffusion/datatypes.py b/riffusion/datatypes.py index 4f10557..70c77e0 100644 --- a/riffusion/datatypes.py +++ b/riffusion/datatypes.py @@ -3,8 +3,8 @@ Data model for the riffusion API. """ from __future__ import annotations -from dataclasses import dataclass import typing as T +from dataclasses import dataclass @dataclass(frozen=True) diff --git a/riffusion/riffusion_pipeline.py b/riffusion/riffusion_pipeline.py index 997cd85..dd0c5f1 100644 --- a/riffusion/riffusion_pipeline.py +++ b/riffusion/riffusion_pipeline.py @@ -9,15 +9,14 @@ import inspect import typing as T import numpy as np -from PIL import Image import torch - from diffusers.models import AutoencoderKL, UNet2DConditionModel from diffusers.pipeline_utils import DiffusionPipeline from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker from diffusers.schedulers import DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler from diffusers.utils import logging from huggingface_hub import hf_hub_download +from PIL import Image from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer from riffusion.datatypes import InferenceInput diff --git a/riffusion/server.py b/riffusion/server.py index 88d0d3d..42ad7b7 100644 --- a/riffusion/server.py +++ b/riffusion/server.py @@ -3,21 +3,19 @@ Flask server that serves the riffusion model as an API. """ import dataclasses -import logging import io import json -from pathlib import Path +import logging import time import typing as T +from pathlib import Path import dacite import flask - -from flask_cors import CORS import PIL +from flask_cors import CORS -from riffusion.datatypes import InferenceInput -from riffusion.datatypes import InferenceOutput +from riffusion.datatypes import InferenceInput, InferenceOutput from riffusion.riffusion_pipeline import RiffusionPipeline from riffusion.spectrogram_image_converter import SpectrogramImageConverter from riffusion.spectrogram_params import SpectrogramParams diff --git a/riffusion/spectrogram_converter.py b/riffusion/spectrogram_converter.py index 9283e31..a1c5e00 100644 --- a/riffusion/spectrogram_converter.py +++ b/riffusion/spectrogram_converter.py @@ -1,12 +1,12 @@ +import warnings + import numpy as np import pydub import torch import torchaudio -import warnings from riffusion.spectrogram_params import SpectrogramParams -from riffusion.util import audio_util -from riffusion.util import torch_util +from riffusion.util import audio_util, torch_util class SpectrogramConverter: diff --git a/riffusion/spectrogram_image_converter.py b/riffusion/spectrogram_image_converter.py index 198a76f..fea7729 100644 --- a/riffusion/spectrogram_image_converter.py +++ b/riffusion/spectrogram_image_converter.py @@ -1,6 +1,6 @@ import numpy as np -from PIL import Image import pydub +from PIL import Image from riffusion.spectrogram_converter import SpectrogramConverter from riffusion.spectrogram_params import SpectrogramParams diff --git a/riffusion/spectrogram_params.py b/riffusion/spectrogram_params.py index bced763..848bc89 100644 --- a/riffusion/spectrogram_params.py +++ b/riffusion/spectrogram_params.py @@ -1,8 +1,8 @@ from __future__ import annotations +import typing as T from dataclasses import dataclass from enum import Enum -import typing as T @dataclass(frozen=True) diff --git a/test/image_util_test.py b/test/image_util_test.py index 6dedcd9..00f5a9f 100644 --- a/test/image_util_test.py +++ b/test/image_util_test.py @@ -1,9 +1,9 @@ import numpy as np import pydub -from riffusion.util import image_util from riffusion.spectrogram_converter import SpectrogramConverter from riffusion.spectrogram_params import SpectrogramParams +from riffusion.util import image_util from .test_case import TestCase diff --git a/test/linter_test.py b/test/linter_test.py index c59d8a9..65456b9 100644 --- a/test/linter_test.py +++ b/test/linter_test.py @@ -1,5 +1,5 @@ -from pathlib import Path import subprocess +from pathlib import Path from .test_case import TestCase diff --git a/test/spectrogram_image_converter_test.py b/test/spectrogram_image_converter_test.py index 78223be..48e4d0c 100644 --- a/test/spectrogram_image_converter_test.py +++ b/test/spectrogram_image_converter_test.py @@ -1,8 +1,8 @@ import dataclasses import typing as T -from PIL import Image import pydub +from PIL import Image from riffusion.spectrogram_image_converter import SpectrogramImageConverter from riffusion.spectrogram_params import SpectrogramParams diff --git a/test/test_case.py b/test/test_case.py index efbf7ef..92bff45 100644 --- a/test/test_case.py +++ b/test/test_case.py @@ -1,10 +1,10 @@ import os -from pathlib import Path import shutil import tempfile import typing as T -import warnings import unittest +import warnings +from pathlib import Path class TestCase(unittest.TestCase):