From 820f63d340baf557e42286a27716d47ed4490e15 Mon Sep 17 00:00:00 2001 From: Maria Khrustaleva Date: Tue, 7 Jan 2025 13:52:52 +0100 Subject: [PATCH] Sort imports --- cvat/apps/dataset_manager/project.py | 7 ++++--- cvat/apps/dataset_manager/task.py | 9 ++++----- cvat/apps/dataset_manager/tests/test_rest_api_formats.py | 2 +- cvat/apps/dataset_manager/util.py | 4 ++-- cvat/apps/dataset_manager/views.py | 6 ++---- cvat/apps/engine/backup.py | 7 +++---- cvat/apps/engine/models.py | 2 +- cvat/apps/engine/tests/test_rest_api.py | 4 ++-- cvat/apps/engine/tests/utils.py | 5 +++-- 9 files changed, 22 insertions(+), 24 deletions(-) diff --git a/cvat/apps/dataset_manager/project.py b/cvat/apps/dataset_manager/project.py index 3c1821af8ee..afdcd930249 100644 --- a/cvat/apps/dataset_manager/project.py +++ b/cvat/apps/dataset_manager/project.py @@ -3,15 +3,16 @@ # # SPDX-License-Identifier: MIT -from contextlib import nullcontext +import io from collections.abc import Mapping +from contextlib import nullcontext from typing import Any, Callable -import io + import rq from datumaro.components.errors import DatasetError, DatasetImportError, DatasetNotFoundError from django.conf import settings -from django.utils import timezone from django.db import transaction +from django.utils import timezone from cvat.apps.dataset_manager.task import TaskAnnotation from cvat.apps.dataset_manager.util import TmpDirManager diff --git a/cvat/apps/dataset_manager/task.py b/cvat/apps/dataset_manager/task.py index b9aa4adfb4c..b11c85f771c 100644 --- a/cvat/apps/dataset_manager/task.py +++ b/cvat/apps/dataset_manager/task.py @@ -6,17 +6,16 @@ import io import itertools from collections import OrderedDict +from contextlib import nullcontext from copy import deepcopy from enum import Enum -from typing import Optional, Union, Callable - -from contextlib import nullcontext -from django.utils import timezone +from typing import Callable, Optional, Union from datumaro.components.errors import DatasetError, DatasetImportError, DatasetNotFoundError from django.conf import settings from django.db import transaction from django.db.models.query import Prefetch, QuerySet +from django.utils import timezone from rest_framework.exceptions import ValidationError from cvat.apps.dataset_manager.annotation import AnnotationIR, AnnotationManager @@ -28,11 +27,11 @@ ) from cvat.apps.dataset_manager.formats.registry import make_exporter, make_importer from cvat.apps.dataset_manager.util import ( + TmpDirManager, add_prefetch_fields, bulk_create, faster_deepcopy, get_cached, - TmpDirManager, ) from cvat.apps.engine import models, serializers from cvat.apps.engine.log import DatasetLogManager diff --git a/cvat/apps/dataset_manager/tests/test_rest_api_formats.py b/cvat/apps/dataset_manager/tests/test_rest_api_formats.py index 639f6147147..5eec5ed9bda 100644 --- a/cvat/apps/dataset_manager/tests/test_rest_api_formats.py +++ b/cvat/apps/dataset_manager/tests/test_rest_api_formats.py @@ -32,8 +32,8 @@ from rest_framework import status import cvat.apps.dataset_manager as dm -from cvat.apps.dataset_manager.cron import clear_export_cache from cvat.apps.dataset_manager.bindings import CvatTaskOrJobDataExtractor, TaskData +from cvat.apps.dataset_manager.cron import clear_export_cache from cvat.apps.dataset_manager.task import TaskAnnotation from cvat.apps.dataset_manager.tests.utils import TestDir from cvat.apps.dataset_manager.util import get_export_cache_lock diff --git a/cvat/apps/dataset_manager/util.py b/cvat/apps/dataset_manager/util.py index b6aecf74749..d53f3ff2c5c 100644 --- a/cvat/apps/dataset_manager/util.py +++ b/cvat/apps/dataset_manager/util.py @@ -7,16 +7,16 @@ import os import os.path as osp import re -import zipfile import tempfile +import zipfile from collections.abc import Generator, Sequence from contextlib import contextmanager from copy import deepcopy from datetime import timedelta from enum import Enum +from pathlib import Path from threading import Lock from typing import Any -from pathlib import Path import attrs import django_rq diff --git a/cvat/apps/dataset_manager/views.py b/cvat/apps/dataset_manager/views.py index 553e161a54f..23249b517d9 100644 --- a/cvat/apps/dataset_manager/views.py +++ b/cvat/apps/dataset_manager/views.py @@ -24,17 +24,15 @@ from cvat.apps.engine.utils import get_rq_lock_by_user from .formats.registry import EXPORT_FORMATS, IMPORT_FORMATS -from .util import EXPORT_CACHE_DIR_NAME # pylint: disable=unused-import from .util import ( + ExportCacheManager, LockNotAvailableError, + TmpDirManager, current_function_name, extend_export_file_lifetime, get_export_cache_lock, - ExportCacheManager, - TmpDirManager, ) - slogger = ServerLogManager(__name__) _MODULE_NAME = __package__ + '.' + osp.splitext(osp.basename(__file__))[0] diff --git a/cvat/apps/engine/backup.py b/cvat/apps/engine/backup.py index 36b90c76dc5..fef27f2a165 100644 --- a/cvat/apps/engine/backup.py +++ b/cvat/apps/engine/backup.py @@ -8,16 +8,15 @@ import os import re import shutil -import tempfile import uuid from abc import ABCMeta, abstractmethod from collections.abc import Collection, Iterable +from datetime import timedelta from enum import Enum from logging import Logger from tempfile import NamedTemporaryFile -from typing import Any, Optional, Union, Type +from typing import Any, Optional, Type, Union from zipfile import ZipFile -from datetime import timedelta import django_rq from django.conf import settings @@ -31,8 +30,8 @@ import cvat.apps.dataset_manager as dm from cvat.apps.dataset_manager.bindings import CvatImportError -from cvat.apps.dataset_manager.views import log_exception from cvat.apps.dataset_manager.util import ExportCacheManager, TmpDirManager +from cvat.apps.dataset_manager.views import log_exception from cvat.apps.engine import models from cvat.apps.engine.cloud_provider import import_resource_from_cloud_storage from cvat.apps.engine.location import StorageType, get_location_configuration diff --git a/cvat/apps/engine/models.py b/cvat/apps/engine/models.py index 6a8c573ce34..5099670cf73 100644 --- a/cvat/apps/engine/models.py +++ b/cvat/apps/engine/models.py @@ -22,8 +22,8 @@ from django.core.files.storage import FileSystemStorage from django.db import IntegrityError, models, transaction from django.db.models import Q, TextChoices -from django.db.models.fields import FloatField from django.db.models.base import ModelBase +from django.db.models.fields import FloatField from django.utils.translation import gettext_lazy as _ from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import extend_schema_field diff --git a/cvat/apps/engine/tests/test_rest_api.py b/cvat/apps/engine/tests/test_rest_api.py index c74959f22dd..cb613c60d04 100644 --- a/cvat/apps/engine/tests/test_rest_api.py +++ b/cvat/apps/engine/tests/test_rest_api.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: MIT -import django_rq import copy import io import json @@ -27,6 +26,7 @@ from unittest import mock import av +import django_rq import numpy as np from django.conf import settings from django.contrib.auth.models import Group, User @@ -3108,7 +3108,7 @@ def test_api_v2_tasks_id_export_no_auth(self): self._run_api_v2_tasks_id_export_import(None) def test_can_remove_export_cache_automatically_after_successful_export(self): - from cvat.apps.dataset_manager.cron import cron_export_cache_cleanup, clear_export_cache + from cvat.apps.dataset_manager.cron import clear_export_cache, cron_export_cache_cleanup self._create_tasks() task_id = self.tasks[0]["id"] user = self.admin diff --git a/cvat/apps/engine/tests/utils.py b/cvat/apps/engine/tests/utils.py index d0189d96592..15d2adb6545 100644 --- a/cvat/apps/engine/tests/utils.py +++ b/cvat/apps/engine/tests/utils.py @@ -5,11 +5,13 @@ import itertools import logging import os +import shutil from collections.abc import Iterator, Sequence from contextlib import contextmanager from io import BytesIO +from pathlib import Path from typing import Any, Callable, TypeVar -import shutil + import av import django_rq import numpy as np @@ -17,7 +19,6 @@ from django.core.cache import caches from django.http.response import HttpResponse from PIL import Image -from pathlib import Path from rest_framework.test import APITestCase T = TypeVar('T')