Skip to content

Commit

Permalink
Resolve circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted committed Jul 10, 2024
1 parent ad4e6f3 commit 28d6e53
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 166 deletions.
18 changes: 2 additions & 16 deletions kpops/component_handlers/kafka_connect/model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from typing import Any, Literal
from typing import Any

import pydantic
from pydantic import (
Expand All @@ -12,10 +12,8 @@
from pydantic.json_schema import SkipJsonSchema
from typing_extensions import override

from kpops.components.base_components.helm_app import HelmAppValues
from kpops.components.base_components.models.topic import KafkaTopic, KafkaTopicStr
from kpops.components.common.topic import KafkaTopic, KafkaTopicStr
from kpops.utils.pydantic import (
CamelCaseConfigModel,
DescConfigModel,
by_alias,
exclude_by_value,
Expand Down Expand Up @@ -111,15 +109,3 @@ class KafkaConnectConfigErrorResponse(BaseModel):
name: str
error_count: int
configs: list[KafkaConnectConfigDescription]


class KafkaConnectorResetterConfig(CamelCaseConfigModel):
brokers: str
connector: str
delete_consumer_group: bool | None = None
offset_topic: str | None = None


class KafkaConnectorResetterValues(HelmAppValues):
connector_type: Literal["source", "sink"]
config: KafkaConnectorResetterConfig
2 changes: 1 addition & 1 deletion kpops/component_handlers/topic/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
parse_and_compare_topic_configs,
parse_rest_proxy_topic_config,
)
from kpops.components.base_components.models.topic import KafkaTopic
from kpops.components.common.topic import KafkaTopic
from kpops.utils.colorify import greenify, magentaify
from kpops.utils.dict_differ import Diff, DiffType, render_diff

Expand Down
10 changes: 5 additions & 5 deletions kpops/components/base_components/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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 (
from .helm_app import HelmApp
from .kafka_app import KafkaApp
from .kafka_connector import (
KafkaConnector,
KafkaSinkConnector,
KafkaSourceConnector,
)
from kpops.components.base_components.kubernetes_app import KubernetesApp
from kpops.components.base_components.pipeline_component import PipelineComponent
from .kubernetes_app import KubernetesApp
from .pipeline_component import PipelineComponent

__all__ = (
"HelmApp",
Expand Down
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 @@ -12,9 +12,9 @@
from kpops.component_handlers import get_handlers
from kpops.components.base_components.cleaner import Cleaner
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.common.streams_bootstrap import StreamsBootstrap
from kpops.components.common.topic import KafkaTopic, KafkaTopicStr
from kpops.config import get_config
from kpops.utils.docstring import describe_attr
from kpops.utils.pydantic import (
Expand Down
19 changes: 15 additions & 4 deletions kpops/components/base_components/kafka_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from abc import ABC
from functools import cached_property
from typing import Any, NoReturn
from typing import Any, Literal, NoReturn

import pydantic
from pydantic import Field, PrivateAttr, ValidationInfo, computed_field, field_validator
Expand All @@ -15,18 +15,17 @@
)
from kpops.component_handlers.kafka_connect.model import (
KafkaConnectorConfig,
KafkaConnectorResetterConfig,
KafkaConnectorResetterValues,
KafkaConnectorType,
)
from kpops.components.base_components.cleaner import Cleaner
from kpops.components.base_components.helm_app import HelmAppValues
from kpops.components.base_components.models.from_section import FromTopic
from kpops.components.base_components.models.topic import KafkaTopic
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.components.common.topic import KafkaTopic
from kpops.config import get_config
from kpops.utils.colorify import magentaify
from kpops.utils.docstring import describe_attr
from kpops.utils.pydantic import CamelCaseConfigModel

try:
from typing import Self # pyright: ignore[reportAttributeAccessIssue]
Expand All @@ -36,6 +35,18 @@
log = logging.getLogger("KafkaConnector")


class KafkaConnectorResetterConfig(CamelCaseConfigModel):
brokers: str
connector: str
delete_consumer_group: bool | None = None
offset_topic: str | None = None


class KafkaConnectorResetterValues(HelmAppValues):
connector_type: Literal["source", "sink"]
config: KafkaConnectorResetterConfig


class KafkaConnectorResetter(Cleaner, ABC):
"""Helm app for resetting and cleaning a Kafka Connector.
Expand Down
2 changes: 1 addition & 1 deletion kpops/components/base_components/models/to_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pydantic import ConfigDict, Field

from kpops.components.base_components.models import ModelName, ModelVersion, TopicName
from kpops.components.base_components.models.topic import KafkaTopic, TopicConfig
from kpops.components.common.topic import KafkaTopic, TopicConfig
from kpops.utils.docstring import describe_attr
from kpops.utils.pydantic import DescConfigModel

Expand Down
122 changes: 0 additions & 122 deletions kpops/components/base_components/models/topic.py

This file was deleted.

2 changes: 1 addition & 1 deletion kpops/components/base_components/pipeline_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from kpops.components.base_components.models.to_section import (
ToSection,
)
from kpops.components.base_components.models.topic import (
from kpops.components.common.topic import (
KafkaTopic,
OutputTopicTypes,
TopicConfig,
Expand Down
5 changes: 3 additions & 2 deletions kpops/components/streams_bootstrap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 .producer.producer_app import ProducerApp
from .streams.streams_app import StreamsApp

__all__ = (
"StreamsBootstrap",
Expand Down
4 changes: 2 additions & 2 deletions kpops/components/streams_bootstrap/producer/producer_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
KafkaApp,
KafkaAppCleaner,
)
from kpops.components.base_components.models.topic import (
from kpops.components.common.streams_bootstrap import StreamsBootstrap
from kpops.components.common.topic import (
KafkaTopic,
OutputTopicTypes,
TopicConfig,
)
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
2 changes: 1 addition & 1 deletion kpops/components/streams_bootstrap/streams/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
KafkaAppValues,
KafkaStreamsConfig,
)
from kpops.components.base_components.models.topic import KafkaTopic, KafkaTopicStr
from kpops.components.common.streams_bootstrap import StreamsBootstrapValues
from kpops.components.common.topic import KafkaTopic, KafkaTopicStr
from kpops.utils.docstring import describe_attr
from kpops.utils.pydantic import (
CamelCaseConfigModel,
Expand Down
2 changes: 1 addition & 1 deletion kpops/components/streams_bootstrap/streams/streams_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from kpops.component_handlers.kubernetes.pvc_handler import PVCHandler
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.common.streams_bootstrap import StreamsBootstrap
from kpops.components.common.topic import KafkaTopic
from kpops.components.streams_bootstrap.app_type import AppType
from kpops.components.streams_bootstrap.streams.model import (
StreamsAppValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from kpops.components.base_components.models.to_section import (
ToSection,
)
from kpops.components.base_components.models.topic import OutputTopicTypes, TopicConfig
from kpops.components.common.topic import OutputTopicTypes, TopicConfig
from kpops.config import KpopsConfig, SchemaRegistryConfig
from kpops.utils.colorify import greenify, magentaify, yellowify
from tests.pipeline.test_components import TestSchemaProvider
Expand Down
2 changes: 1 addition & 1 deletion tests/component_handlers/topic/test_topic_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
TopicResponse,
TopicSpec,
)
from kpops.components.base_components.models.topic import (
from kpops.components.common.topic import (
KafkaTopic,
OutputTopicTypes,
TopicConfig,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/test_kafka_sink_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from kpops.components.base_components.models.to_section import (
ToSection,
)
from kpops.components.base_components.models.topic import (
from kpops.components.common.topic import (
KafkaTopic,
OutputTopicTypes,
TopicConfig,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/test_kafka_source_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from kpops.components.base_components.models.to_section import (
ToSection,
)
from kpops.components.base_components.models.topic import OutputTopicTypes, TopicConfig
from kpops.components.common.topic import OutputTopicTypes, TopicConfig
from kpops.utils.environment import ENV
from tests.components.test_kafka_connector import (
CONNECTOR_CLEAN_HELM_NAMEOVERRIDE,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/test_producer_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from kpops.component_handlers import ComponentHandlers, get_handlers
from kpops.component_handlers.helm_wrapper.model import HelmUpgradeInstallFlags
from kpops.component_handlers.helm_wrapper.utils import create_helm_release_name
from kpops.components.base_components.models.topic import (
from kpops.components.common.topic import (
KafkaTopic,
OutputTopicTypes,
TopicConfig,
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 @@ -16,7 +16,7 @@
from kpops.components.base_components.models.to_section import (
ToSection,
)
from kpops.components.base_components.models.topic import (
from kpops.components.common.topic import (
KafkaTopic,
OutputTopicTypes,
TopicConfig,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/test_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pydantic
import pytest

from kpops.components.base_components.models.topic import (
from kpops.components.common.topic import (
KafkaTopic,
KafkaTopicStr,
OutputTopicTypes,
Expand Down
2 changes: 1 addition & 1 deletion tests/pipeline/test_components/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
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.common.topic import OutputTopicTypes, TopicConfig

Check failure on line 14 in tests/pipeline/test_components/components.py

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, 3.10)

Import "kpops.components.common.topic" could not be resolved (reportMissingImports)

Check failure on line 14 in tests/pipeline/test_components/components.py

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, 3.10)

Type of "OutputTopicTypes" is unknown (reportUnknownVariableType)

Check failure on line 14 in tests/pipeline/test_components/components.py

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, 3.10)

Type of "TopicConfig" is unknown (reportUnknownVariableType)

Check failure on line 14 in tests/pipeline/test_components/components.py

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, 3.10)

Import "kpops.components.common.topic" could not be resolved (reportMissingImports)

Check failure on line 14 in tests/pipeline/test_components/components.py

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, 3.10)

Type of "OutputTopicTypes" is unknown (reportUnknownVariableType)

Check failure on line 14 in tests/pipeline/test_components/components.py

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, 3.10)

Type of "TopicConfig" is unknown (reportUnknownVariableType)
from kpops.components.streams_bootstrap.producer.producer_app import ProducerApp
from kpops.components.streams_bootstrap.streams.streams_app import StreamsApp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from kpops.component_handlers.kafka_connect.model import KafkaConnectorConfig
from kpops.components.base_components.kafka_connector import KafkaSinkConnector
from kpops.components.base_components.models.topic import OutputTopicTypes
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.components.common.topic import OutputTopicTypes
from kpops.components.streams_bootstrap.producer.producer_app import ProducerApp
from kpops.components.streams_bootstrap.streams.streams_app import StreamsApp

Expand Down

0 comments on commit 28d6e53

Please sign in to comment.