Skip to content

Commit

Permalink
Try namespace package
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted committed Jun 26, 2024
1 parent af6997b commit d6d6749
Show file tree
Hide file tree
Showing 27 changed files with 86 additions and 152 deletions.
5 changes: 4 additions & 1 deletion hooks/gen_docs/gen_docs_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

from hooks import ROOT
from kpops.api.registry import Registry
from kpops.components import KafkaConnector, PipelineComponent
from kpops.components.base_components.kafka_connector import KafkaConnector
from kpops.components.base_components.pipeline_component import (
PipelineComponent,
)
from kpops.utils.colorify import redify, yellowify
from kpops.utils.pydantic import issubclass_patched
from kpops.utils.yaml import load_yaml_file
Expand Down
14 changes: 0 additions & 14 deletions kpops/__init__.py

This file was deleted.

13 changes: 6 additions & 7 deletions kpops/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pathlib import Path
from typing import TYPE_CHECKING

import kpops
from kpops.api.logs import log, log_action
from kpops.api.options import FilterType
from kpops.api.registry import Registry
Expand All @@ -23,8 +22,8 @@
from kpops.utils.cli_commands import init_project

if TYPE_CHECKING:
from kpops.components import PipelineComponent
from kpops.components.base_components.models.resource import Resource
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.config import KpopsConfig


Expand Down Expand Up @@ -68,7 +67,7 @@ def manifest(
environment: str | None = None,
verbose: bool = False,
) -> list[Resource]:
pipeline = kpops.generate(
pipeline = generate(
pipeline_path=pipeline_path,
dotenv=dotenv,
config=config,
Expand All @@ -95,7 +94,7 @@ def deploy(
verbose: bool = True,
parallel: bool = False,
):
pipeline = kpops.generate(
pipeline = generate(
pipeline_path=pipeline_path,
dotenv=dotenv,
config=config,
Expand Down Expand Up @@ -131,7 +130,7 @@ def destroy(
verbose: bool = True,
parallel: bool = False,
):
pipeline = kpops.generate(
pipeline = generate(
pipeline_path=pipeline_path,
dotenv=dotenv,
config=config,
Expand Down Expand Up @@ -169,7 +168,7 @@ def reset(
verbose: bool = True,
parallel: bool = False,
):
pipeline = kpops.generate(
pipeline = generate(
pipeline_path=pipeline_path,
dotenv=dotenv,
config=config,
Expand Down Expand Up @@ -206,7 +205,7 @@ def clean(
verbose: bool = True,
parallel: bool = False,
):
pipeline = kpops.generate(
pipeline = generate(
pipeline_path=pipeline_path,
dotenv=dotenv,
config=config,
Expand Down
2 changes: 1 addition & 1 deletion kpops/api/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import typer

if TYPE_CHECKING:
from kpops.components import PipelineComponent
from kpops.components.base_components.pipeline_component import PipelineComponent


class CustomFormatter(logging.Formatter):
Expand Down
2 changes: 1 addition & 1 deletion kpops/api/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from kpops.components import PipelineComponent
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.pipeline import ComponentFilterPredicate


Expand Down
3 changes: 1 addition & 2 deletions kpops/api/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
from types import ModuleType
from typing import TYPE_CHECKING, TypeVar

from kpops import __name__
from kpops.api.exception import ClassNotFoundError
from kpops.components.base_components.pipeline_component import PipelineComponent

if TYPE_CHECKING:
from collections.abc import Iterator

KPOPS_MODULE = __name__ + "."
KPOPS_MODULE = "kpops."

T = TypeVar("T")
ClassDict = dict[str, type[T]] # type -> class
Expand Down
5 changes: 2 additions & 3 deletions kpops/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import typer

import kpops
from kpops import __version__
import kpops.api as kpops
from kpops.api.file_type import KpopsFileType
from kpops.api.options import FilterType
from kpops.cli.utils import collect_pipeline_paths
Expand Down Expand Up @@ -306,7 +305,7 @@ def clean(

def version_callback(show_version: bool) -> None:
if show_version:
typer.echo(f"KPOps {__version__}")
# typer.echo(f"KPOps {__version__}") # FIXME: read version from package
raise typer.Exit


Expand Down
27 changes: 0 additions & 27 deletions kpops/components/__init__.py

This file was deleted.

19 changes: 19 additions & 0 deletions kpops/components/base_components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from kpops.components.base_components.helm_app import HelmApp
from kpops.components.base_components.kafka_app import KafkaApp
from kpops.components.base_components.kafka_connector import (
KafkaConnector,
KafkaSinkConnector,
KafkaSourceConnector,
)
from kpops.components.base_components.kubernetes_app import KubernetesApp
from kpops.components.base_components.pipeline_component import PipelineComponent

__all__ = (
"HelmApp",
"KafkaApp",
"KafkaConnector",
"KafkaSinkConnector",
"KafkaSourceConnector",
"KubernetesApp",
"PipelineComponent",
)
2 changes: 1 addition & 1 deletion kpops/components/base_components/kafka_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from kpops.components.base_components.helm_app import HelmAppValues
from kpops.components.base_components.models.topic import KafkaTopic, KafkaTopicStr
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.components.streams_bootstrap import StreamsBootstrap
from kpops.components.common.streams_bootstrap import StreamsBootstrap
from kpops.utils.docstring import describe_attr
from kpops.utils.pydantic import (
CamelCaseConfigModel,
Expand Down
38 changes: 8 additions & 30 deletions kpops/components/streams_bootstrap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
from abc import ABC

from pydantic import Field

from kpops.component_handlers.helm_wrapper.model import HelmRepoConfig
from kpops.components.base_components.helm_app import HelmApp
from kpops.utils.docstring import describe_attr

STREAMS_BOOTSTRAP_HELM_REPO = HelmRepoConfig(
repository_name="bakdata-streams-bootstrap",
url="https://bakdata.github.io/streams-bootstrap/",
from kpops.components.common.streams_bootstrap import StreamsBootstrap
from kpops.components.streams_bootstrap.producer.producer_app import ProducerApp
from kpops.components.streams_bootstrap.streams.streams_app import StreamsApp

__all__ = (
"StreamsBootstrap",
"StreamsApp",
"ProducerApp",
)
STREAMS_BOOTSTRAP_VERSION = "2.9.0"


class StreamsBootstrap(HelmApp, ABC):
"""Base for components with a streams-bootstrap Helm chart.
:param repo_config: Configuration of the Helm chart repo to be used for
deploying the component, defaults to streams-bootstrap Helm repo
:param version: Helm chart version, defaults to "2.9.0"
"""

repo_config: HelmRepoConfig = Field(
default=STREAMS_BOOTSTRAP_HELM_REPO,
description=describe_attr("repo_config", __doc__),
)
version: str | None = Field(
default=STREAMS_BOOTSTRAP_VERSION,
description=describe_attr("version", __doc__),
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
OutputTopicTypes,
TopicConfig,
)
from kpops.components.streams_bootstrap import StreamsBootstrap
from kpops.components.common.streams_bootstrap import StreamsBootstrap
from kpops.components.streams_bootstrap.app_type import AppType
from kpops.components.streams_bootstrap.producer.model import ProducerAppValues
from kpops.utils.docstring import describe_attr
Expand Down
9 changes: 3 additions & 6 deletions kpops/components/streams_bootstrap/streams/streams_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
from typing_extensions import override

from kpops.component_handlers.kubernetes.pvc_handler import PVCHandler
from kpops.components import HelmApp
from kpops.components.base_components.kafka_app import (
KafkaApp,
KafkaAppCleaner,
)
from kpops.components.base_components.helm_app import HelmApp
from kpops.components.base_components.kafka_app import KafkaApp, KafkaAppCleaner
from kpops.components.base_components.models.topic import KafkaTopic
from kpops.components.streams_bootstrap import StreamsBootstrap
from kpops.components.common.streams_bootstrap import StreamsBootstrap
from kpops.components.streams_bootstrap.app_type import AppType
from kpops.components.streams_bootstrap.streams.model import (
StreamsAppValues,
Expand Down
2 changes: 1 addition & 1 deletion kpops/utils/gen_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)

from kpops.api.registry import Registry
from kpops.components import (
from kpops.components.base_components.pipeline_component import (
PipelineComponent,
)
from kpops.config import KpopsConfig
Expand Down
16 changes: 8 additions & 8 deletions tests/api/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
from kpops.api.exception import ClassNotFoundError
from kpops.api.registry import Registry, _find_classes, _iter_namespace, find_class
from kpops.component_handlers.schema_handler.schema_provider import SchemaProvider
from kpops.components import (
HelmApp,
KafkaApp,
from kpops.components.base_components.helm_app import HelmApp
from kpops.components.base_components.kafka_app import KafkaApp
from kpops.components.base_components.kafka_connector import (
KafkaConnector,
KafkaSinkConnector,
KafkaSourceConnector,
KubernetesApp,
PipelineComponent,
ProducerApp,
StreamsApp,
StreamsBootstrap,
)
from kpops.components.base_components.kubernetes_app import KubernetesApp
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.components.common.streams_bootstrap import StreamsBootstrap
from kpops.components.streams_bootstrap.producer.producer_app import ProducerApp
from kpops.components.streams_bootstrap.streams.streams_app import StreamsApp
from tests.cli.resources.custom_module import CustomSchemaProvider


Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pytest_snapshot.plugin import Snapshot
from typer.testing import CliRunner

import kpops
import kpops.api as kpops
from kpops.cli.main import app
from kpops.utils.cli_commands import create_config

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_schema_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from kpops.api.registry import Registry
from kpops.cli.main import app
from kpops.components import PipelineComponent
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.utils.docstring import describe_attr

RESOURCE_PATH = Path(__file__).parent / "resources"
Expand Down
6 changes: 4 additions & 2 deletions tests/components/test_kafka_sink_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
KafkaConnectorConfig,
KafkaConnectorType,
)
from kpops.components import KafkaSinkConnector
from kpops.components.base_components.kafka_connector import KafkaConnectorResetter
from kpops.components.base_components.kafka_connector import (
KafkaConnectorResetter,
KafkaSinkConnector,
)
from kpops.components.base_components.models.from_section import (
FromSection,
FromTopic,
Expand Down
6 changes: 4 additions & 2 deletions tests/components/test_producer_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
from kpops.component_handlers import ComponentHandlers
from kpops.component_handlers.helm_wrapper.model import HelmUpgradeInstallFlags
from kpops.component_handlers.helm_wrapper.utils import create_helm_release_name
from kpops.components import ProducerApp
from kpops.components.base_components.models.topic import (
KafkaTopic,
OutputTopicTypes,
TopicConfig,
)
from kpops.components.streams_bootstrap.producer.producer_app import ProducerAppCleaner
from kpops.components.streams_bootstrap.producer.producer_app import (
ProducerApp,
ProducerAppCleaner,
)
from kpops.config import KpopsConfig, TopicNameConfig
from tests.components import PIPELINE_BASE_DIR

Expand Down
2 changes: 1 addition & 1 deletion tests/components/test_streams_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
HelmUpgradeInstallFlags,
)
from kpops.component_handlers.helm_wrapper.utils import create_helm_release_name
from kpops.components import StreamsApp
from kpops.components.base_components.models import TopicName
from kpops.components.base_components.models.to_section import (
ToSection,
Expand All @@ -27,6 +26,7 @@
StreamsAppAutoScaling,
)
from kpops.components.streams_bootstrap.streams.streams_app import (
StreamsApp,
StreamsAppCleaner,
)
from kpops.config import KpopsConfig, TopicNameConfig
Expand Down
2 changes: 1 addition & 1 deletion tests/components/test_streams_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
HelmUpgradeInstallFlags,
)
from kpops.component_handlers.helm_wrapper.utils import create_helm_release_name
from kpops.components.streams_bootstrap import StreamsBootstrap
from kpops.components.common.streams_bootstrap import StreamsBootstrap
from kpops.config import KpopsConfig
from tests.components import PIPELINE_BASE_DIR

Expand Down
10 changes: 4 additions & 6 deletions tests/pipeline/test_components/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
Schema,
SchemaProvider,
)
from kpops.components import (
KafkaSinkConnector,
PipelineComponent,
ProducerApp,
StreamsApp,
)
from kpops.components.base_components.kafka_connector import KafkaSinkConnector
from kpops.components.base_components.models import ModelName, ModelVersion, TopicName
from kpops.components.base_components.models.to_section import (
ToSection,
)
from kpops.components.base_components.models.topic import OutputTopicTypes, TopicConfig
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.components.streams_bootstrap.producer.producer_app import ProducerApp
from kpops.components.streams_bootstrap.streams.streams_app import StreamsApp


class ScheduledProducer(ProducerApp): ...
Expand Down
Loading

0 comments on commit d6d6749

Please sign in to comment.