Skip to content

Commit

Permalink
add isort to pre-commit (#875)
Browse files Browse the repository at this point in the history
* add isort to pre-commit

* initial isorting imports

* fix imports
  • Loading branch information
pkasprzyk authored Apr 7, 2022
1 parent a91ccd1 commit 8950d17
Show file tree
Hide file tree
Showing 205 changed files with 550 additions and 654 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black", "--filter-files", "--skip", "tests/neptune/test_imports.py"]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion alpha_integration_dev/common_client_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import abc
import os
from contextlib import contextmanager
from datetime import datetime
import abc


class ClientFeatures(abc.ABC):
Expand Down
2 changes: 1 addition & 1 deletion alpha_integration_dev/old_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
from alpha_integration_dev.common_client_code import ClientFeatures
from neptune.exceptions import (
DeleteArtifactUnsupportedInAlphaException,
DownloadArtifactUnsupportedException,
DownloadArtifactsUnsupportedException,
DownloadArtifactUnsupportedException,
DownloadSourcesException,
FileNotFound,
)
Expand Down
3 changes: 2 additions & 1 deletion alpha_integration_dev/old_client_noglobal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import sys
from datetime import datetime

from neptune import Session, envs
from common_client_code import ClientFeatures

from neptune import Session, envs


class OldClientNonglobalFeatures(ClientFeatures):
def __init__(self):
Expand Down
4 changes: 2 additions & 2 deletions dev_tools/prepare_test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
#
import pkgutil
import inspect
import importlib
import inspect
import pkgutil

EXCLUDED_MODULES = [
"neptune.internal",
Expand Down
7 changes: 3 additions & 4 deletions e2e_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
import os
import time

from faker import Faker
import boto3
import pytest
from faker import Faker

from e2e_tests.utils import Environment, a_project_name, initialize_container
from neptune.management import add_project_member, create_project
from neptune.management.internal.utils import normalize_project_name
from neptune.management import create_project, add_project_member

from e2e_tests.utils import initialize_container, a_project_name, Environment

fake = Faker()

Expand Down
6 changes: 2 additions & 4 deletions e2e_tests/integrations/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
# limitations under the License.
#
import pytest

import torch
from torch.utils.data import Dataset, DataLoader

from pytorch_lightning import LightningModule, Trainer
from pytorch_lightning.loggers.neptune import NeptuneLogger
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.loggers.neptune import NeptuneLogger
from torch.utils.data import DataLoader, Dataset

import neptune.new as neptune

Expand Down
10 changes: 5 additions & 5 deletions e2e_tests/management/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
#
import pytest

from e2e_tests.base import BaseE2ETest, fake
from e2e_tests.utils import Environment, a_project_name
from neptune.management import (
get_project_list,
get_project_member_list,
get_workspace_member_list,
add_project_member,
create_project,
delete_project,
get_project_list,
get_project_member_list,
get_workspace_member_list,
remove_project_member,
)
from neptune.management.exceptions import (
UserAlreadyHasAccess,
UserNotExistsOrWithoutAccess,
)
from neptune.management.internal.utils import normalize_project_name
from e2e_tests.base import BaseE2ETest, fake
from e2e_tests.utils import a_project_name, Environment


@pytest.mark.management
Expand Down
7 changes: 3 additions & 4 deletions e2e_tests/standard/test_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
# limitations under the License.
#
import os
import time
import tempfile
import time
from pathlib import Path

import pytest

from neptune.new.metadata_containers import MetadataContainer

from e2e_tests.base import BaseE2ETest, AVAILABLE_CONTAINERS, fake
from e2e_tests.base import AVAILABLE_CONTAINERS, BaseE2ETest, fake
from e2e_tests.utils import tmp_context, with_check_if_file_appears
from neptune.new.metadata_containers import MetadataContainer


class TestArtifacts(BaseE2ETest):
Expand Down
5 changes: 2 additions & 3 deletions e2e_tests/standard/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
import pytest

import neptune.new as neptune
from neptune.new.metadata_containers import Model, MetadataContainer

from e2e_tests.base import BaseE2ETest, AVAILABLE_CONTAINERS, fake
from e2e_tests.base import AVAILABLE_CONTAINERS, BaseE2ETest, fake
from neptune.new.metadata_containers import MetadataContainer, Model


class TestAtoms(BaseE2ETest):
Expand Down
5 changes: 2 additions & 3 deletions e2e_tests/standard/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import random
import itertools
import random

import pytest

from e2e_tests.base import AVAILABLE_CONTAINERS, BaseE2ETest, fake
from neptune.new.metadata_containers import MetadataContainer

from e2e_tests.base import BaseE2ETest, AVAILABLE_CONTAINERS, fake

# List of every possible container type pair for instance: "run-run, run-model, model-model_version, ..."
ALL_CONTAINERS_PAIRS = list(
map("-".join, itertools.product(AVAILABLE_CONTAINERS, AVAILABLE_CONTAINERS))
Expand Down
6 changes: 3 additions & 3 deletions e2e_tests/standard/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

import pytest

from e2e_tests.base import BaseE2ETest, AVAILABLE_CONTAINERS, fake
from e2e_tests.utils import tmp_context, initialize_container
from e2e_tests.base import AVAILABLE_CONTAINERS, BaseE2ETest, fake
from e2e_tests.utils import initialize_container, tmp_context
from neptune.new.internal.backends import hosted_file_operations
from neptune.new.metadata_containers import MetadataContainer
from neptune.new.internal.backends.api_model import MultipartConfig, OptionalFeatures
from neptune.new.internal.backends.hosted_neptune_backend import HostedNeptuneBackend
from neptune.new.metadata_containers import MetadataContainer
from neptune.new.types import FileSet


Expand Down
11 changes: 5 additions & 6 deletions e2e_tests/standard/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
import pytest

import neptune.new as neptune
from neptune.new.project import Project
from neptune.new.metadata_containers import Model
from neptune.new.exceptions import NeptuneModelKeyAlreadyExistsError

from e2e_tests.base import BaseE2ETest, fake, AVAILABLE_CONTAINERS
from e2e_tests.base import AVAILABLE_CONTAINERS, BaseE2ETest, fake
from e2e_tests.utils import (
with_check_if_file_appears,
initialize_container,
reinitialize_container,
with_check_if_file_appears,
)
from neptune.new.exceptions import NeptuneModelKeyAlreadyExistsError
from neptune.new.metadata_containers import Model
from neptune.new.project import Project


class TestInitRun(BaseE2ETest):
Expand Down
4 changes: 2 additions & 2 deletions e2e_tests/standard/test_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import random
import concurrent.futures
import random

import pytest
import neptune.new as neptune

import neptune.new as neptune
from e2e_tests.base import BaseE2ETest, fake
from e2e_tests.utils import reinitialize_container

Expand Down
5 changes: 2 additions & 3 deletions e2e_tests/standard/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
import pytest
from PIL import Image

from neptune.new.metadata_containers import MetadataContainer

from e2e_tests.base import BaseE2ETest, AVAILABLE_CONTAINERS, fake
from e2e_tests.base import AVAILABLE_CONTAINERS, BaseE2ETest, fake
from e2e_tests.utils import generate_image, image_to_png, tmp_context
from neptune.new.metadata_containers import MetadataContainer


class TestSeries(BaseE2ETest):
Expand Down
5 changes: 2 additions & 3 deletions e2e_tests/standard/test_stage_transitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
#
import pytest

from neptune.new.metadata_containers import ModelVersion
from neptune.new.exceptions import NeptuneCannotChangeStageManually

from e2e_tests.base import BaseE2ETest
from neptune.new.exceptions import NeptuneCannotChangeStageManually
from neptune.new.metadata_containers import ModelVersion


class TestStageTransitions(BaseE2ETest):
Expand Down
9 changes: 4 additions & 5 deletions e2e_tests/standard/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import re
import json
import re
from pathlib import Path

import pytest
from click.testing import CliRunner

import neptune.new as neptune
from neptune.new.exceptions import NeptuneException
from neptune.new.sync import sync

from e2e_tests.base import BaseE2ETest, fake, AVAILABLE_CONTAINERS
from e2e_tests.base import AVAILABLE_CONTAINERS, BaseE2ETest, fake
from e2e_tests.utils import (
DISABLE_SYSLOG_KWARGS,
initialize_container,
reinitialize_container,
tmp_context,
)
from neptune.new.exceptions import NeptuneException
from neptune.new.sync import sync

runner = CliRunner()

Expand Down
4 changes: 2 additions & 2 deletions e2e_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

import io
import os
import string
import random
import string
import tempfile
from datetime import datetime
from collections import namedtuple
from contextlib import contextmanager
from datetime import datetime

import numpy
from PIL import Image
Expand Down
2 changes: 1 addition & 1 deletion neptune/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from neptune._version import get_versions
from neptune.exceptions import (
InvalidNeptuneBackend,
NeptuneUninitializedException,
NeptuneIncorrectImportException,
NeptuneUninitializedException,
)
from neptune.internal.api_clients import backend_factory
from neptune.internal.api_clients.offline_backend import OfflineBackend
Expand Down
2 changes: 1 addition & 1 deletion neptune/api_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#
from neptune import envs
from neptune.exceptions import NeptuneException, STYLES
from neptune.exceptions import STYLES, NeptuneException


class NeptuneApiException(NeptuneException):
Expand Down
2 changes: 1 addition & 1 deletion neptune/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from neptune.api_exceptions import ChannelDoesNotExist, ExperimentAlreadyFinished
from neptune.exceptions import (
InvalidChannelValue,
NoChannelValue,
NeptuneIncorrectImportException,
NoChannelValue,
)
from neptune.internal.channels.channels import (
ChannelNamespace,
Expand Down
1 change: 1 addition & 0 deletions neptune/internal/api_clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#

# isort: skip_file
from neptune.internal.api_clients.hosted_api_clients.hosted_backend_api_client import (
HostedNeptuneBackendApiClient,
)
Expand Down
2 changes: 1 addition & 1 deletion neptune/internal/api_clients/backend_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# limitations under the License.
#

from neptune.exceptions import InvalidNeptuneBackend
from neptune.backend import BackendApiClient
from neptune.exceptions import InvalidNeptuneBackend
from neptune.internal.api_clients import (
HostedNeptuneBackendApiClient,
OfflineBackendApiClient,
Expand Down
3 changes: 1 addition & 2 deletions neptune/internal/api_clients/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import logging
import os

from neptune.constants import ANONYMOUS, ANONYMOUS_API_TOKEN

from neptune import envs
from neptune.api_exceptions import InvalidApiKey
from neptune.constants import ANONYMOUS, ANONYMOUS_API_TOKEN
from neptune.exceptions import NeptuneMissingApiTokenException

_logger = logging.getLogger(__name__)
Expand Down
Loading

0 comments on commit 8950d17

Please sign in to comment.