Skip to content

Commit

Permalink
Standardize imports
Browse files Browse the repository at this point in the history
Standardize imports
  • Loading branch information
BKDDFS authored Sep 12, 2024
2 parents d7dfabd + d0e75f7 commit 8743a48
Show file tree
Hide file tree
Showing 29 changed files with 69 additions and 65 deletions.
2 changes: 1 addition & 1 deletion extractor_service/app/extractor_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""
import logging

from fastapi import HTTPException, BackgroundTasks
from fastapi import BackgroundTasks, HTTPException

from .dependencies import ExtractorDependencies
from .extractors import Extractor, ExtractorFactory
Expand Down
10 changes: 5 additions & 5 deletions extractor_service/app/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import gc
import logging
from abc import ABC, abstractmethod
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from abc import ABC, abstractmethod
import logging
from typing import Type
import gc

import numpy as np

from .dependencies import ExtractorDependencies
from .image_evaluators import ImageEvaluator
from .image_processors import ImageProcessor
from .schemas import ExtractorConfig
from .video_processors import VideoProcessor
from .image_processors import ImageProcessor
from .image_evaluators import ImageEvaluator

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions extractor_service/app/image_evaluators.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
from abc import ABC, abstractmethod
from pathlib import Path

import requests
import numpy as np
import requests
import tensorflow as tf
from tensorflow import convert_to_tensor
from tensorflow.keras import Model
from tensorflow.keras.layers import Dense, Dropout
import tensorflow as tf

from .schemas import ExtractorConfig

Expand Down
2 changes: 1 addition & 1 deletion extractor_service/app/video_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"""
import logging
from abc import ABC, abstractmethod
from typing import Generator
from contextlib import contextmanager
from pathlib import Path
from typing import Generator

import cv2
import numpy as np
Expand Down
12 changes: 7 additions & 5 deletions extractor_service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@
import sys

import uvicorn
from fastapi import FastAPI, BackgroundTasks, Depends
from fastapi import BackgroundTasks, Depends, FastAPI

if os.getenv("DOCKER_ENV"):
from app.schemas import ExtractorConfig, Message, ExtractorStatus
from app.dependencies import (ExtractorDependencies,
get_extractor_dependencies)
from app.extractor_manager import ExtractorManager
from app.dependencies import ExtractorDependencies, get_extractor_dependencies
from app.schemas import ExtractorConfig, ExtractorStatus, Message
else:
from .app.schemas import ExtractorConfig, Message, ExtractorStatus
from .app.dependencies import (ExtractorDependencies,
get_extractor_dependencies)
from .app.extractor_manager import ExtractorManager
from .app.dependencies import ExtractorDependencies, get_extractor_dependencies
from .app.schemas import ExtractorConfig, ExtractorStatus, Message

logging.basicConfig(level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "PerfectFrameAI"
version = "2.3.2"
version = "2.3.3"
description = "AI tool for finding the most aesthetic frames in a video. 🎞️➜🖼️"
authors = ["Bartłomiej Flis <[email protected]>"]
license = "GPL-3.0 license"
Expand Down
2 changes: 1 addition & 1 deletion service_manager/docker_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
import subprocess
import sys
import logging
from typing import Optional

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions service_manager/service_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import json
import logging
import time
from http.client import RemoteDisconnected
from pathlib import Path
from typing import Union
from urllib.request import urlopen, Request
from http.client import RemoteDisconnected
from urllib.request import Request, urlopen

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion start.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
import argparse
import logging

from config import Config
from service_manager.docker_manager import DockerManager
Expand Down
8 changes: 4 additions & 4 deletions tests/extractor_service/common.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Common fixtures for all conftest files."""
import pytest

from extractor_service.app.dependencies import (ExtractorDependencies,
get_evaluator,
get_image_processor,
get_video_processor)
from extractor_service.app.extractors import BestFramesExtractor
from extractor_service.app.schemas import ExtractorConfig
from extractor_service.app.dependencies import (
ExtractorDependencies, get_image_processor,
get_video_processor, get_evaluator
)


@pytest.fixture(scope="package")
Expand Down
11 changes: 5 additions & 6 deletions tests/extractor_service/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from fastapi.testclient import TestClient
import pytest
from fastapi.testclient import TestClient

from tests.extractor_service.common import config
from tests.common import (
files_dir, best_frames_dir, top_images_dir,
setup_top_images_extractor_env, setup_best_frames_extractor_env
)
from extractor_service.main import app, run_extractor
from tests.common import (best_frames_dir, files_dir,
setup_best_frames_extractor_env,
setup_top_images_extractor_env, top_images_dir)
from tests.extractor_service.common import config


@pytest.fixture(scope="package")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from extractor_service.app.extractors import BestFramesExtractor
from extractor_service.app.schemas import ExtractorConfig

Expand Down
9 changes: 4 additions & 5 deletions tests/extractor_service/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import pytest

from tests.extractor_service.common import extractor, config, dependencies
from tests.common import (
files_dir, best_frames_dir, top_images_dir,
setup_top_images_extractor_env, setup_best_frames_extractor_env
)
from extractor_service.app.extractors import BestFramesExtractor
from tests.common import (best_frames_dir, files_dir,
setup_best_frames_extractor_env,
setup_top_images_extractor_env, top_images_dir)
from tests.extractor_service.common import config, dependencies, extractor
4 changes: 2 additions & 2 deletions tests/extractor_service/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

from extractor_service.app.extractors import BestFramesExtractor
from extractor_service.app.schemas import ExtractorConfig
from tests.extractor_service.common import extractor, config, dependencies
from tests.common import files_dir, best_frames_dir
from tests.common import best_frames_dir, files_dir
from tests.extractor_service.common import config, dependencies, extractor
11 changes: 6 additions & 5 deletions tests/extractor_service/unit/dependencies_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from extractor_service.app.dependencies import (ExtractorDependencies,
get_evaluator,
get_extractor_dependencies,
get_image_processor,
get_video_processor)
from extractor_service.app.image_evaluators import InceptionResNetNIMA
from extractor_service.app.image_processors import OpenCVImage
from extractor_service.app.video_processors import OpenCVVideo
from extractor_service.app.image_evaluators import InceptionResNetNIMA
from extractor_service.app.dependencies import (
get_image_processor, get_video_processor,
get_evaluator, get_extractor_dependencies, ExtractorDependencies
)


def test_get_image_processor():
Expand Down
5 changes: 2 additions & 3 deletions tests/extractor_service/unit/extractor_manager_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import pytest
from fastapi import HTTPException, BackgroundTasks

from fastapi import BackgroundTasks, HTTPException

from extractor_service.app.extractor_manager import ExtractorManager
from extractor_service.app.extractors import ExtractorFactory
Expand Down
10 changes: 5 additions & 5 deletions tests/extractor_service/unit/extractor_test.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import logging
from pathlib import Path
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import numpy as np
import pytest

from extractor_service.app.extractors import (BestFramesExtractor,
ExtractorFactory,
TopImagesExtractor)
from extractor_service.app.image_evaluators import InceptionResNetNIMA
from extractor_service.app.image_processors import OpenCVImage
from extractor_service.app.video_processors import OpenCVVideo
from extractor_service.app.image_evaluators import InceptionResNetNIMA
from extractor_service.app.extractors import (ExtractorFactory,
BestFramesExtractor,
TopImagesExtractor)


def test_extractor_initialization(config, dependencies):
Expand Down
5 changes: 3 additions & 2 deletions tests/extractor_service/unit/image_evaluators_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import logging
from unittest.mock import patch, MagicMock, call
from unittest.mock import MagicMock, call, patch

import numpy as np
import pytest

from extractor_service.app.image_evaluators import InceptionResNetNIMA, _ResNetModel
from extractor_service.app.image_evaluators import (InceptionResNetNIMA,
_ResNetModel)


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/extractor_service/unit/image_processors_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import uuid
from pathlib import Path
from unittest.mock import patch, MagicMock, call
from unittest.mock import MagicMock, call, patch

import cv2
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion tests/extractor_service/unit/nima_models_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from pathlib import Path
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import numpy as np
import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/extractor_service/unit/schemas_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import pytest
from pydantic import ValidationError

from extractor_service.app.schemas import ExtractorConfig, Message, ExtractorStatus
from extractor_service.app.schemas import (ExtractorConfig, ExtractorStatus,
Message)


def test_config_default():
Expand Down
2 changes: 1 addition & 1 deletion tests/extractor_service/unit/top_images_extractor_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from unittest.mock import MagicMock, patch, call
from unittest.mock import MagicMock, call, patch

import numpy as np
import pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/extractor_service/unit/video_processors_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from pathlib import Path
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import cv2
import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/service_manager/e2e/best_frames_extractor_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import subprocess
import sys

import pytest
import os


@pytest.mark.skipif("CI" in os.environ, reason="Test skipped in GitHub Actions.")
Expand Down
7 changes: 3 additions & 4 deletions tests/service_manager/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import pytest

from tests.common import (
files_dir, best_frames_dir, top_images_dir,
setup_top_images_extractor_env, setup_best_frames_extractor_env
)
from tests.common import (best_frames_dir, files_dir,
setup_best_frames_extractor_env,
setup_top_images_extractor_env, top_images_dir)


@pytest.fixture(scope="module")
Expand Down
3 changes: 2 additions & 1 deletion tests/service_manager/e2e/top_images_extractor_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import subprocess
import sys

import pytest
import os


@pytest.mark.skipif("CI" in os.environ, reason="Test skipped in GitHub Actions.")
Expand Down
2 changes: 1 addition & 1 deletion tests/service_manager/integration/docker_image_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
import docker
import pytest

from config import Config

Expand Down
2 changes: 1 addition & 1 deletion tests/service_manager/unit/docker_manager_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import subprocess
from unittest.mock import patch, MagicMock, PropertyMock, call
from unittest.mock import MagicMock, PropertyMock, call, patch

import pytest

Expand Down
2 changes: 1 addition & 1 deletion tests/service_manager/unit/service_initializer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from http.client import RemoteDisconnected
from pathlib import Path
from unittest import mock
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import pytest

Expand Down

0 comments on commit 8743a48

Please sign in to comment.