Skip to content

Commit

Permalink
Format with tox -e fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
theoctober19th committed Dec 15, 2023
1 parent a0dd1a6 commit 9f0ea55
Show file tree
Hide file tree
Showing 20 changed files with 78 additions and 118 deletions.
8 changes: 2 additions & 6 deletions spark8t/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from .interface import AbstractKubeInterface
from .lightkube import LightKube
from .kubectl import KubeInterface
from .lightkube import LightKube

__all__ = [
"AbstractKubeInterface",
"LightKube",
"KubeInterface"
]
__all__ = ["AbstractKubeInterface", "LightKube", "KubeInterface"]
8 changes: 2 additions & 6 deletions spark8t/backend/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

import yaml

from spark8t.domain import (
KubernetesResourceType
)
from spark8t.domain import KubernetesResourceType
from spark8t.exceptions import AccountNotFound
from spark8t.utils import (
WithLogging,
)
from spark8t.utils import WithLogging


class AbstractKubeInterface(WithLogging, metaclass=ABCMeta):
Expand Down
13 changes: 3 additions & 10 deletions spark8t/backend/kubectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@
import subprocess
from typing import Any, Dict, List, Optional, Union

from spark8t.domain import (
KubernetesResourceType,
)
from spark8t.domain import KubernetesResourceType
from spark8t.exceptions import AccountNotFound, K8sResourceNotFound
from spark8t.literals import MANAGED_BY_LABELNAME, PRIMARY_LABELNAME, SPARK8S_LABEL
from spark8t.utils import (
execute_command_output,
listify,
parse_yaml_shell_output,
)
from spark8t.utils import execute_command_output, listify, parse_yaml_shell_output

from .interface import AbstractKubeInterface


Expand Down Expand Up @@ -338,4 +332,3 @@ def select_by_master(self, master: str):
if self.context_name in contexts_for_api_server
else self.with_context(contexts_for_api_server[0])
)

12 changes: 3 additions & 9 deletions spark8t/backend/lightkube.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@
from lightkube.resources.rbac_authorization_v1 import Role, RoleBinding
from lightkube.types import PatchType

from spark8t.domain import (
Defaults,
KubernetesResourceType,
)
from spark8t.domain import Defaults, KubernetesResourceType
from spark8t.exceptions import K8sResourceNotFound
from spark8t.utils import (
filter_none,
PropertyFile
)
from spark8t.utils import PropertyFile, filter_none

from .interface import AbstractKubeInterface


Expand Down Expand Up @@ -403,4 +398,3 @@ def exists(
if "not found" in e.status.message:
return False
raise e

2 changes: 1 addition & 1 deletion spark8t/cli/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from argparse import ArgumentParser, Namespace
from typing import Callable, List, Optional

from spark8t.cli import defaults
from spark8t.backend import AbstractKubeInterface, KubeInterface, LightKube
from spark8t.cli import defaults
from spark8t.utils import DEFAULT_LOGGING_FILE, config_from_file, environ


Expand Down
3 changes: 1 addition & 2 deletions spark8t/cli/service_account_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
from spark8t.domain import ServiceAccount
from spark8t.exceptions import AccountNotFound, PrimaryAccountNotFound
from spark8t.registry import K8sServiceAccountRegistry
from spark8t.utils import setup_logging, parse_conf_overrides
from spark8t.utils import PropertyFile
from spark8t.utils import PropertyFile, parse_conf_overrides, setup_logging


def build_service_account_from_args(args, registry) -> ServiceAccount:
Expand Down
2 changes: 1 addition & 1 deletion spark8t/cli/spark_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
)
from spark8t.domain import ServiceAccount
from spark8t.exceptions import AccountNotFound, PrimaryAccountNotFound
from spark8t.spark_interface import SparkInterface
from spark8t.registry import K8sServiceAccountRegistry
from spark8t.spark_interface import SparkInterface
from spark8t.utils import setup_logging


Expand Down
1 change: 1 addition & 0 deletions spark8t/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from spark8t.utils import PropertyFile


class Defaults:
"""Class containing all relevant defaults for the application."""

Expand Down
6 changes: 3 additions & 3 deletions spark8t/registry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .in_memory_registry import InMemoryAccountRegistry
from .interface import AbstractServiceAccountRegistry
from .k8s_registry import K8sServiceAccountRegistry
from .in_memory_registry import InMemoryAccountRegistry

__allo__ = [
"AbstractServiceAccountRegistry",
"K8sServiceAccountRegistry",
"InMemoryAccountRegistry"
]
"InMemoryAccountRegistry",
]
6 changes: 2 additions & 4 deletions spark8t/registry/in_memory_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

from typing import Dict, List, Optional

from spark8t.domain import (
ServiceAccount,
)
from spark8t.domain import ServiceAccount
from spark8t.exceptions import AccountNotFound
from spark8t.registry import AbstractServiceAccountRegistry
from spark8t.utils import PropertyFile


class InMemoryAccountRegistry(AbstractServiceAccountRegistry):
def __init__(self, cache: Dict[str, ServiceAccount]):
self.cache = cache
Expand Down Expand Up @@ -99,4 +98,3 @@ def set_configurations(self, account_id: str, configurations: PropertyFile) -> s

def get(self, account_id: str) -> Optional[ServiceAccount]:
return self.cache.get(account_id)

9 changes: 2 additions & 7 deletions spark8t/registry/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
from abc import ABC, abstractmethod
from typing import List, Optional

from spark8t.domain import (
ServiceAccount,
)
from spark8t.utils import (
WithLogging, PropertyFile
)
from spark8t.domain import ServiceAccount
from spark8t.utils import PropertyFile, WithLogging


class AbstractServiceAccountRegistry(WithLogging, ABC):
Expand Down Expand Up @@ -88,4 +84,3 @@ def get(self, account_id: str) -> Optional[ServiceAccount]:
account_id: account id to be used for retrieving the service account.
"""
pass

9 changes: 3 additions & 6 deletions spark8t/registry/k8s_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

from typing import Any, Dict, List, Optional

from spark8t.domain import (
KubernetesResourceType,
ServiceAccount,
)
from spark8t.backend import AbstractKubeInterface
from spark8t.domain import KubernetesResourceType, ServiceAccount
from spark8t.exceptions import AccountNotFound, K8sResourceNotFound
from spark8t.literals import MANAGED_BY_LABELNAME, PRIMARY_LABELNAME, SPARK8S_LABEL
from spark8t.utils import (
Expand All @@ -15,7 +13,7 @@
)

from .interface import AbstractServiceAccountRegistry
from spark8t.backend import AbstractKubeInterface


class K8sServiceAccountRegistry(AbstractServiceAccountRegistry):
"""Class implementing a ServiceAccountRegistry, based on K8s."""
Expand Down Expand Up @@ -289,4 +287,3 @@ def get(self, account_id: str) -> Optional[ServiceAccount]:
except K8sResourceNotFound:
return None
return self._build_service_account_from_raw(service_account_raw["metadata"])

17 changes: 4 additions & 13 deletions spark8t/spark_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@
import os
import socket
from enum import Enum
from typing import Any, Dict, List, Optional


from spark8t.domain import (
Defaults,
ServiceAccount,
)
from spark8t.utils import (
WithLogging,
PropertyFile,
environ,
umask_named_temporary_file,
)
from typing import Any, List, Optional

from spark8t.backend import AbstractKubeInterface
from spark8t.domain import Defaults, ServiceAccount
from spark8t.utils import PropertyFile, WithLogging, environ, umask_named_temporary_file


class SparkDeployMode(str, Enum):
Expand Down
2 changes: 0 additions & 2 deletions spark8t/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class LevelsDict(TypedDict):
)



def config_from_json(path_to_file: str = DEFAULT_LOGGING_FILE) -> None:
"""
Configure logger from json
Expand Down Expand Up @@ -568,4 +567,3 @@ def parse_conf_overrides(
"Please check input arguments and try again."
)
return PropertyFile(conf_overrides)

2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest
from lightkube.resources.core_v1 import Namespace

from spark8t.domain import Defaults
from spark8t.backend import KubeInterface, LightKube
from spark8t.domain import Defaults
from spark8t.registry import K8sServiceAccountRegistry

integration_test_flag = bool(int(os.environ.get("IE_TEST", "0")))
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/test_kube_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import pytest

from spark8t.domain import KubernetesResourceType
from spark8t.utils import PropertyFile
from spark8t.utils import umask_named_temporary_file
from spark8t.utils import PropertyFile, umask_named_temporary_file


@pytest.mark.parametrize(
Expand Down
Loading

0 comments on commit 9f0ea55

Please sign in to comment.