diff --git a/kpops/components/base_components/base_defaults_component.py b/kpops/components/base_components/base_defaults_component.py index b015c134c..5c74244b5 100644 --- a/kpops/components/base_components/base_defaults_component.py +++ b/kpops/components/base_components/base_defaults_component.py @@ -20,7 +20,7 @@ from pydantic.json_schema import SkipJsonSchema from kpops.component_handlers import ComponentHandlers -from kpops.config import KpopsConfig +from kpops.config import KpopsConfig, get_config from kpops.const.file_type import KpopsFileType from kpops.utils import cached_classproperty from kpops.utils.dict_ops import ( @@ -50,7 +50,6 @@ class BaseDefaultsComponent(DescConfigModel, ABC): correctly to the component. :param enrich: Whether to enrich component with defaults, defaults to False - :param config_: KPOps configuration to be accessed by this component :param handlers_: Component handlers to be accessed by this component :param validate: Whether to run custom validation on the component, defaults to True """ @@ -64,11 +63,6 @@ class BaseDefaultsComponent(DescConfigModel, ABC): description=describe_attr("enrich", __doc__), exclude=True, ) - config_: SkipJsonSchema[KpopsConfig] = Field( - default=..., - description=describe_attr("config_", __doc__), - exclude=True, - ) handlers_: SkipJsonSchema[ComponentHandlers] = Field( default=..., description=describe_attr("handlers_", __doc__), @@ -87,11 +81,10 @@ def __init__(self, **values: Any) -> None: values = cls.extend_with_defaults(**values) tmp_self = cls(**values, enrich=False) values = tmp_self.model_dump(mode="json", by_alias=True) - values = cls.substitute_in_component(tmp_self.config_, **values) + values = cls.substitute_in_component(**values) self.__init__( enrich=False, validate=True, - config_=tmp_self.config_, handlers_=tmp_self.handlers_, **values, ) @@ -130,20 +123,19 @@ def gen_parents(): return tuple(gen_parents()) @classmethod - def substitute_in_component( - cls, config_: KpopsConfig, **component_data: Any - ) -> dict[str, Any]: + def substitute_in_component(cls, **component_data: Any) -> dict[str, Any]: """Substitute all $-placeholders in a component in dict representation. :param component_as_dict: Component represented as dict :return: Updated component """ + config = get_config() # Leftover variables that were previously introduced in the component by the substitution # functions, still hardcoded, because of their names. # TODO(Ivan Yordanov): Get rid of them substitution_hardcoded: dict[str, JsonType] = { - "error_topic_name": config_.topic_name_config.default_error_topic_name, - "output_topic_name": config_.topic_name_config.default_output_topic_name, + "error_topic_name": config.topic_name_config.default_error_topic_name, + "output_topic_name": config.topic_name_config.default_output_topic_name, } component_substitution = generate_substitution( component_data, @@ -152,7 +144,7 @@ def substitute_in_component( separator=".", ) substitution = generate_substitution( - config_.model_dump(mode="json"), + config.model_dump(mode="json"), "config", existing_substitution=component_substitution, separator=".", @@ -166,16 +158,14 @@ def substitute_in_component( ) @classmethod - def extend_with_defaults( - cls, config_: KpopsConfig, **kwargs: Any - ) -> dict[str, Any]: + def extend_with_defaults(cls, **kwargs: Any) -> dict[str, Any]: """Merge parent components' defaults with own. :param config: KPOps configuration :param kwargs: The init kwargs for pydantic :returns: Enriched kwargs with inherited defaults """ - kwargs["config_"] = config_ + config = get_config() pipeline_path_str = ENV.get(PIPELINE_PATH) if not pipeline_path_str: return kwargs @@ -187,7 +177,7 @@ def extend_with_defaults( kwargs[k] = asdict(v) defaults_file_paths_ = get_defaults_file_paths( - pipeline_path, config_, ENV.get("environment") + pipeline_path, config, ENV.get("environment") ) defaults = cls.load_defaults(*defaults_file_paths_) log.debug( diff --git a/kpops/components/base_components/cleaner.py b/kpops/components/base_components/cleaner.py index c1a7da003..76a75247f 100644 --- a/kpops/components/base_components/cleaner.py +++ b/kpops/components/base_components/cleaner.py @@ -8,6 +8,7 @@ create_helm_release_name, ) from kpops.components.base_components.helm_app import HelmApp +from kpops.config import get_config class Cleaner(HelmApp, ABC): @@ -34,7 +35,7 @@ def helm_name_override(self) -> str: @override def helm_flags(self) -> HelmFlags: return HelmFlags( - create_namespace=self.config_.create_namespace, + create_namespace=get_config().create_namespace, version=self.version, wait=True, wait_for_jobs=True, diff --git a/kpops/components/base_components/helm_app.py b/kpops/components/base_components/helm_app.py index 8aaf7a566..6959c578c 100644 --- a/kpops/components/base_components/helm_app.py +++ b/kpops/components/base_components/helm_app.py @@ -27,6 +27,7 @@ KubernetesAppValues, ) from kpops.components.base_components.models.resource import Resource +from kpops.config import get_config from kpops.utils.colorify import magentaify from kpops.utils.docstring import describe_attr from kpops.utils.pydantic import exclude_by_name @@ -84,7 +85,7 @@ class HelmApp(KubernetesApp): @cached_property def helm(self) -> Helm: """Helm object that contains component-specific config such as repo.""" - helm = Helm(self.config_.helm_config) + helm = Helm(get_config().helm_config) if self.repo_config is not None: helm.add_repo( self.repo_config.repository_name, @@ -96,11 +97,11 @@ def helm(self) -> Helm: @cached_property def helm_diff(self) -> HelmDiff: """Helm diff object of last and current release of this component.""" - return HelmDiff(self.config_.helm_diff_config) + return HelmDiff(get_config().helm_diff_config) @cached_property def dry_run_handler(self) -> DryRunHandler: - helm_diff = HelmDiff(self.config_.helm_diff_config) + helm_diff = HelmDiff(get_config().helm_diff_config) return DryRunHandler(self.helm, helm_diff, self.namespace) @property @@ -130,7 +131,7 @@ def helm_flags(self) -> HelmFlags: return HelmFlags( **auth_flags, version=self.version, - create_namespace=self.config_.create_namespace, + create_namespace=get_config().create_namespace, ) @property @@ -138,7 +139,7 @@ def template_flags(self) -> HelmTemplateFlags: """Return flags for Helm template command.""" return HelmTemplateFlags( **self.helm_flags.model_dump(), - api_version=self.config_.helm_config.api_version, + api_version=get_config().helm_config.api_version, ) @override diff --git a/kpops/components/base_components/kafka_app.py b/kpops/components/base_components/kafka_app.py index 2c24f2525..a3521b79e 100644 --- a/kpops/components/base_components/kafka_app.py +++ b/kpops/components/base_components/kafka_app.py @@ -14,6 +14,7 @@ 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.config import get_config from kpops.utils.docstring import describe_attr from kpops.utils.pydantic import ( CamelCaseConfigModel, @@ -113,7 +114,7 @@ async def clean(self, dry_run: bool) -> None: log.info(f"Init cleanup job for {self.helm_release_name}") await self.deploy(dry_run) - if not self.config_.retain_clean_jobs: + if not get_config().retain_clean_jobs: log.info(f"Uninstall cleanup job for {self.helm_release_name}") await self.destroy(dry_run) diff --git a/kpops/components/base_components/kafka_connector.py b/kpops/components/base_components/kafka_connector.py index 3e3884f85..1e75ac056 100644 --- a/kpops/components/base_components/kafka_connector.py +++ b/kpops/components/base_components/kafka_connector.py @@ -23,6 +23,7 @@ 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.config import get_config from kpops.utils.colorify import magentaify from kpops.utils.docstring import describe_attr @@ -84,7 +85,7 @@ async def reset(self, dry_run: bool) -> None: ) await self.deploy(dry_run) - if not self.config_.retain_clean_jobs: + if not get_config().retain_clean_jobs: log.info(magentaify("Connector Cleanup: uninstall Kafka Resetter.")) await self.destroy(dry_run) @@ -140,7 +141,6 @@ def _resetter(self) -> KafkaConnectorResetter: if self.resetter_namespace: kwargs["namespace"] = self.resetter_namespace return KafkaConnectorResetter( - config_=self.config_, handlers_=self.handlers_, **kwargs, **self.model_dump( @@ -158,7 +158,7 @@ def _resetter(self) -> KafkaConnectorResetter: connector_type=self._connector_type.value, config=KafkaConnectorResetterConfig( connector=self.full_name, - brokers=self.config_.kafka_brokers, + brokers=get_config().kafka_brokers, ), **self.resetter_values.model_dump(), ), diff --git a/kpops/components/streams_bootstrap/producer/producer_app.py b/kpops/components/streams_bootstrap/producer/producer_app.py index 4ff6ca562..4371e1713 100644 --- a/kpops/components/streams_bootstrap/producer/producer_app.py +++ b/kpops/components/streams_bootstrap/producer/producer_app.py @@ -56,7 +56,6 @@ class ProducerApp(KafkaApp, StreamsBootstrap): @cached_property def _cleaner(self) -> ProducerAppCleaner: return ProducerAppCleaner( - config_=self.config_, handlers_=self.handlers_, **self.model_dump(by_alias=True, exclude={"_cleaner", "from_", "to"}), ) diff --git a/kpops/components/streams_bootstrap/streams/streams_app.py b/kpops/components/streams_bootstrap/streams/streams_app.py index eb62a0945..846dea509 100644 --- a/kpops/components/streams_bootstrap/streams/streams_app.py +++ b/kpops/components/streams_bootstrap/streams/streams_app.py @@ -60,7 +60,6 @@ class StreamsApp(KafkaApp, StreamsBootstrap): @cached_property def _cleaner(self) -> StreamsAppCleaner: return StreamsAppCleaner( - config_=self.config_, handlers_=self.handlers_, **self.model_dump(by_alias=True, exclude={"_cleaner", "from_", "to"}), ) diff --git a/kpops/config/__init__.py b/kpops/config/__init__.py index 5a9f25a3e..5e0915183 100644 --- a/kpops/config/__init__.py +++ b/kpops/config/__init__.py @@ -2,8 +2,9 @@ import logging from pathlib import Path +from typing import ClassVar -from pydantic import AnyHttpUrl, Field, TypeAdapter +from pydantic import AnyHttpUrl, Field, PrivateAttr, TypeAdapter from pydantic_settings import ( BaseSettings, PydanticBaseSettingsSource, @@ -74,6 +75,8 @@ class KafkaConnectConfig(BaseSettings): class KpopsConfig(BaseSettings): """Global configuration for KPOps project.""" + _config: ClassVar[KpopsConfig] = PrivateAttr() + pipeline_base_dir: Path = Field( default=Path(), description="Base directory to the pipelines (default is current working directory)", @@ -131,9 +134,10 @@ def create( cls.setup_logging_level(verbose) YamlConfigSettingsSource.config_dir = config YamlConfigSettingsSource.environment = environment - return KpopsConfig( + cls._config = KpopsConfig( _env_file=dotenv # pyright: ignore[reportCallIssue] ) + return cls._config @staticmethod def setup_logging_level(verbose: bool): @@ -162,3 +166,14 @@ def settings_customise_sources( dotenv_settings, file_secret_settings, ) + + +def get_config() -> KpopsConfig: + if KpopsConfig._config is None: + msg = f"{KpopsConfig.__name__} has not been initialized, call {KpopsConfig.__name__}.{KpopsConfig.create.__name__}" + raise RuntimeError(msg) + return KpopsConfig._config + + +def set_config(config: KpopsConfig) -> None: + KpopsConfig._config = config diff --git a/kpops/pipeline/__init__.py b/kpops/pipeline/__init__.py index e09e78af6..2754f9db1 100644 --- a/kpops/pipeline/__init__.py +++ b/kpops/pipeline/__init__.py @@ -306,7 +306,6 @@ def apply_component( :param component_data: Arguments for instantiation of pipeline component """ component = component_class( - config_=self.config, handlers_=self.handlers, **component_data, ) @@ -350,7 +349,6 @@ def enrich_component_with_env( ) return component.__class__( - config_=self.config, handlers_=self.handlers, **env_component_as_dict, ) diff --git a/tests/components/test_base_defaults_component.py b/tests/components/test_base_defaults_component.py index b727beea6..d4d711e5f 100644 --- a/tests/components/test_base_defaults_component.py +++ b/tests/components/test_base_defaults_component.py @@ -11,7 +11,7 @@ BaseDefaultsComponent, get_defaults_file_paths, ) -from kpops.config import KpopsConfig +from kpops.config import KpopsConfig, set_config from kpops.const.file_type import DEFAULTS_YAML, PIPELINE_YAML, KpopsFileType from kpops.pipeline import PIPELINE_PATH from kpops.utils.environment import ENV @@ -46,10 +46,11 @@ class EnvVarTest(BaseDefaultsComponent): name: str | None = None -@pytest.fixture() -def config() -> KpopsConfig: +@pytest.fixture(autouse=True) +def config() -> None: ENV[PIPELINE_PATH] = str(RESOURCES_PATH / "pipeline.yaml") - return KpopsConfig(pipeline_base_dir=PIPELINE_BASE_DIR) + config = KpopsConfig(pipeline_base_dir=PIPELINE_BASE_DIR) + set_config(config) @pytest.fixture() @@ -123,9 +124,9 @@ def test_load_defaults_with_environment( == defaults ) - def test_inherit_defaults(self, config: KpopsConfig, handlers: ComponentHandlers): + def test_inherit_defaults(self, handlers: ComponentHandlers): ENV["environment"] = "development" - component = Child(config_=config, handlers_=handlers) + component = Child(handlers_=handlers) assert ( component.name == "fake-child-name" @@ -143,9 +144,8 @@ def test_inherit_defaults(self, config: KpopsConfig, handlers: ComponentHandlers component.hard_coded == "hard_coded_value" ), "Defaults in code should be kept for parents" - def test_inherit(self, config: KpopsConfig, handlers: ComponentHandlers): + def test_inherit(self, handlers: ComponentHandlers): component = Child( - config_=config, handlers_=handlers, name="name-defined-in-pipeline_parser", ) @@ -166,10 +166,8 @@ def test_inherit(self, config: KpopsConfig, handlers: ComponentHandlers): component.hard_coded == "hard_coded_value" ), "Defaults in code should be kept for parents" - def test_multiple_generations( - self, config: KpopsConfig, handlers: ComponentHandlers - ): - component = GrandChild(config_=config, handlers_=handlers) + def test_multiple_generations(self, handlers: ComponentHandlers): + component = GrandChild(handlers_=handlers) assert ( component.name == "fake-child-name" @@ -188,11 +186,9 @@ def test_multiple_generations( ), "Defaults in code should be kept for parents" assert component.grand_child == "grand-child-value" - def test_env_var_substitution( - self, config: KpopsConfig, handlers: ComponentHandlers - ): + def test_env_var_substitution(self, handlers: ComponentHandlers): ENV["pipeline_name"] = RESOURCES_PATH.as_posix() - component = EnvVarTest(config_=config, handlers_=handlers) + component = EnvVarTest(handlers_=handlers) assert component.name @@ -200,10 +196,8 @@ def test_env_var_substitution( Path(component.name) == RESOURCES_PATH ), "Environment variables should be substituted" - def test_merge_defaults(self, config: KpopsConfig, handlers: ComponentHandlers): - component = GrandChild( - config_=config, handlers_=handlers, nested=Nested(**{"bar": False}) - ) + def test_merge_defaults(self, handlers: ComponentHandlers): + component = GrandChild(handlers_=handlers, nested=Nested(**{"bar": False})) assert isinstance(component.nested, Nested) assert component.nested == Nested(**{"foo": "foo", "bar": False}) diff --git a/tests/components/test_helm_app.py b/tests/components/test_helm_app.py index da49ad65f..8e83f1e70 100644 --- a/tests/components/test_helm_app.py +++ b/tests/components/test_helm_app.py @@ -64,7 +64,6 @@ def helm_app( repo_config: HelmRepoConfig, ) -> HelmApp: return HelmApp( - config_=config, handlers_=handlers, name="test-helm-app", values=app_values, @@ -115,7 +114,6 @@ async def test_should_lazy_load_helm_wrapper_and_call_repo_add_when_implemented( repository_name="test-repo", url="https://test.com/charts/" ) helm_app = HelmApp( - config_=config, handlers_=handlers, name="test-helm-app", values=app_values, @@ -169,7 +167,6 @@ def helm_chart(self) -> str: return "path/to/helm/charts/" app_with_local_chart = AppWithLocalChart( - config_=config, handlers_=handlers, name="test-app-with-local-chart", values=app_values, @@ -231,7 +228,6 @@ def test_helm_name_override( repo_config: HelmRepoConfig, ): helm_app = HelmApp( - config_=config, handlers_=handlers, prefix="test-pipeline-prefix-with-a-long-name-", name="helm-app-name-is-very-long-as-well", diff --git a/tests/components/test_kafka_connector.py b/tests/components/test_kafka_connector.py index 572c57083..1ab97898b 100644 --- a/tests/components/test_kafka_connector.py +++ b/tests/components/test_kafka_connector.py @@ -10,7 +10,7 @@ from kpops.components.base_components.kafka_connector import ( KafkaConnector, ) -from kpops.config import KpopsConfig, TopicNameConfig +from kpops.config import KpopsConfig, TopicNameConfig, set_config from tests.components import PIPELINE_BASE_DIR CONNECTOR_NAME = "test-connector-with-long-name-0123456789abcdefghijklmnop" @@ -28,9 +28,9 @@ @pytest.mark.usefixtures("mock_env") class TestKafkaConnector: - @pytest.fixture() - def config(self) -> KpopsConfig: - return KpopsConfig( + @pytest.fixture(autouse=True) + def config(self) -> None: + config = KpopsConfig( topic_name_config=TopicNameConfig( default_error_topic_name="${component.type}-error-topic", default_output_topic_name="${component.type}-output-topic", @@ -39,6 +39,7 @@ def config(self) -> KpopsConfig: helm_diff_config=HelmDiffConfig(), pipeline_base_dir=PIPELINE_BASE_DIR, ) + set_config(config) @pytest.fixture() def handlers(self) -> ComponentHandlers: @@ -72,12 +73,10 @@ def connector_config(self) -> KafkaConnectorConfig: @pytest.fixture() def connector( self, - config: KpopsConfig, handlers: ComponentHandlers, connector_config: KafkaConnectorConfig, ) -> KafkaConnector: return KafkaConnector( # HACK: not supposed to be instantiated, because ABC - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=connector_config, @@ -87,13 +86,11 @@ def connector( def test_connector_config_name_override( self, connector: KafkaConnector, - config: KpopsConfig, handlers: ComponentHandlers, ): assert connector.config.name == CONNECTOR_FULL_NAME connector = KafkaConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config={"connector.class": CONNECTOR_CLASS}, # type: ignore[reportGeneralTypeIssues], gets enriched @@ -108,7 +105,6 @@ def test_connector_config_name_override( ), ): KafkaConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config={"connector.class": CONNECTOR_CLASS, "name": "different-name"}, # type: ignore[reportGeneralTypeIssues], gets enriched @@ -121,7 +117,6 @@ def test_connector_config_name_override( ), ): KafkaConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config={"connector.class": CONNECTOR_CLASS, "name": ""}, # type: ignore[reportGeneralTypeIssues], gets enriched diff --git a/tests/components/test_kafka_sink_connector.py b/tests/components/test_kafka_sink_connector.py index 1a8705611..a75122858 100644 --- a/tests/components/test_kafka_sink_connector.py +++ b/tests/components/test_kafka_sink_connector.py @@ -30,7 +30,6 @@ OutputTopicTypes, TopicConfig, ) -from kpops.config import KpopsConfig from kpops.utils.colorify import magentaify from tests.components.test_kafka_connector import ( CONNECTOR_CLEAN_FULL_NAME, @@ -53,12 +52,10 @@ def log_info_mock(self, mocker: MockerFixture) -> MagicMock: @pytest.fixture() def connector( self, - config: KpopsConfig, handlers: ComponentHandlers, connector_config: KafkaConnectorConfig, ) -> KafkaSinkConnector: return KafkaSinkConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=connector_config, @@ -105,13 +102,11 @@ def test_resetter_inheritance(self, connector: KafkaSinkConnector): def test_connector_config_parsing( self, - config: KpopsConfig, handlers: ComponentHandlers, connector_config: KafkaConnectorConfig, ): topic_pattern = ".*" connector = KafkaSinkConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=KafkaConnectorConfig( @@ -124,14 +119,12 @@ def test_connector_config_parsing( def test_from_section_parsing_input_topic( self, - config: KpopsConfig, handlers: ComponentHandlers, connector_config: KafkaConnectorConfig, ): topic1 = TopicName("connector-topic1") topic2 = TopicName("connector-topic2") connector = KafkaSinkConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=connector_config, @@ -165,13 +158,11 @@ def test_from_section_parsing_input_topic( def test_from_section_parsing_input_pattern( self, - config: KpopsConfig, handlers: ComponentHandlers, connector_config: KafkaConnectorConfig, ): topic_pattern = TopicName(".*") connector = KafkaSinkConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=connector_config, @@ -409,13 +400,11 @@ async def test_clean_when_dry_run_is_false( @pytest.mark.asyncio() async def test_clean_without_to_when_dry_run_is_true( self, - config: KpopsConfig, handlers: ComponentHandlers, dry_run_handler_mock: MagicMock, connector_config: KafkaConnectorConfig, ): connector = KafkaSinkConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=connector_config, @@ -430,7 +419,6 @@ async def test_clean_without_to_when_dry_run_is_true( @pytest.mark.asyncio() async def test_clean_without_to_when_dry_run_is_false( self, - config: KpopsConfig, handlers: ComponentHandlers, helm_mock: MagicMock, dry_run_handler_mock: MagicMock, @@ -438,7 +426,6 @@ async def test_clean_without_to_when_dry_run_is_false( connector_config: KafkaConnectorConfig, ): connector = KafkaSinkConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=connector_config, diff --git a/tests/components/test_kafka_source_connector.py b/tests/components/test_kafka_source_connector.py index b7d78f3b2..b3bfc6223 100644 --- a/tests/components/test_kafka_source_connector.py +++ b/tests/components/test_kafka_source_connector.py @@ -26,7 +26,6 @@ ToSection, ) from kpops.components.base_components.models.topic import OutputTopicTypes, TopicConfig -from kpops.config import KpopsConfig from kpops.utils.environment import ENV from tests.components.test_kafka_connector import ( CONNECTOR_CLEAN_HELM_NAMEOVERRIDE, @@ -46,12 +45,10 @@ class TestKafkaSourceConnector(TestKafkaConnector): @pytest.fixture() def connector( self, - config: KpopsConfig, handlers: ComponentHandlers, connector_config: KafkaConnectorConfig, ) -> KafkaSourceConnector: return KafkaSourceConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=connector_config, @@ -77,13 +74,11 @@ def test_resetter_offset_topic(self, connector: KafkaSourceConnector): def test_from_section_raises_exception( self, - config: KpopsConfig, handlers: ComponentHandlers, connector_config: KafkaConnectorConfig, ): with pytest.raises(NotImplementedError): KafkaSourceConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=connector_config, @@ -312,7 +307,6 @@ async def test_clean_when_dry_run_is_false( @pytest.mark.asyncio() async def test_clean_without_to_when_dry_run_is_false( self, - config: KpopsConfig, handlers: ComponentHandlers, helm_mock: MagicMock, dry_run_handler_mock: MagicMock, @@ -320,7 +314,6 @@ async def test_clean_without_to_when_dry_run_is_false( connector_config: KafkaConnectorConfig, ): connector = KafkaSourceConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=connector_config, @@ -394,13 +387,11 @@ async def test_clean_without_to_when_dry_run_is_false( @pytest.mark.asyncio() async def test_clean_without_to_when_dry_run_is_true( self, - config: KpopsConfig, handlers: ComponentHandlers, dry_run_handler_mock: MagicMock, connector_config: KafkaConnectorConfig, ): connector = KafkaSourceConnector( - config_=config, handlers_=handlers, name=CONNECTOR_NAME, config=connector_config, diff --git a/tests/components/test_kubernetes_app.py b/tests/components/test_kubernetes_app.py index 15dfaffe8..a4c3e84e8 100644 --- a/tests/components/test_kubernetes_app.py +++ b/tests/components/test_kubernetes_app.py @@ -58,7 +58,6 @@ def kubernetes_app( app_values: KubernetesTestValues, ) -> KubernetesApp: return KubernetesApp( - config_=config, handlers_=handlers, name="test-kubernetes-app", values=app_values, @@ -75,7 +74,6 @@ def test_should_raise_value_error_when_name_is_not_valid( ValueError, match=r"The component name .* is invalid for Kubernetes." ): KubernetesApp( - config_=config, handlers_=handlers, name="Not-Compatible*", values=app_values, @@ -86,7 +84,6 @@ def test_should_raise_value_error_when_name_is_not_valid( ValueError, match=r"The component name .* is invalid for Kubernetes." ): KubernetesApp( - config_=config, handlers_=handlers, name="snake_case*", values=app_values, @@ -94,7 +91,6 @@ def test_should_raise_value_error_when_name_is_not_valid( ) assert KubernetesApp( - config_=config, handlers_=handlers, name="valid-name", values=app_values, diff --git a/tests/components/test_producer_app.py b/tests/components/test_producer_app.py index 29fbc3cd8..da8d70df9 100644 --- a/tests/components/test_producer_app.py +++ b/tests/components/test_producer_app.py @@ -62,7 +62,6 @@ def producer_app( self, config: KpopsConfig, handlers: ComponentHandlers ) -> ProducerApp: return ProducerApp( - config_=config, handlers_=handlers, name=PRODUCER_APP_NAME, **{ @@ -104,7 +103,6 @@ def test_cleaner_helm_name_override(self, producer_app: ProducerApp): def test_output_topics(self, config: KpopsConfig, handlers: ComponentHandlers): producer_app = ProducerApp( - config_=config, handlers_=handlers, name=PRODUCER_APP_NAME, **{ @@ -320,7 +318,6 @@ def test_get_output_topics( handlers: ComponentHandlers, ): producer_app = ProducerApp( - config_=config, handlers_=handlers, name="my-producer", **{ diff --git a/tests/components/test_streams_app.py b/tests/components/test_streams_app.py index 3a9251f59..e23ec43bb 100644 --- a/tests/components/test_streams_app.py +++ b/tests/components/test_streams_app.py @@ -80,7 +80,6 @@ def streams_app( self, config: KpopsConfig, handlers: ComponentHandlers ) -> StreamsApp: return StreamsApp( - config_=config, handlers_=handlers, name=STREAMS_APP_NAME, **{ @@ -103,7 +102,6 @@ def stateful_streams_app( self, config: KpopsConfig, handlers: ComponentHandlers ) -> StreamsApp: return StreamsApp( - config_=config, handlers_=handlers, name=STREAMS_APP_NAME, **{ @@ -198,7 +196,6 @@ def test_cleaner_helm_name_override(self, streams_app: StreamsApp): def test_set_topics(self, config: KpopsConfig, handlers: ComponentHandlers): streams_app = StreamsApp( - config_=config, handlers_=handlers, name=STREAMS_APP_NAME, **{ @@ -248,7 +245,6 @@ def test_no_empty_input_topic( self, config: KpopsConfig, handlers: ComponentHandlers ): streams_app = StreamsApp( - config_=config, handlers_=handlers, name=STREAMS_APP_NAME, **{ @@ -281,7 +277,6 @@ def test_should_validate(self, config: KpopsConfig, handlers: ComponentHandlers) ValueError, match="Define role only if `type` is `pattern` or `None`" ): StreamsApp( - config_=config, handlers_=handlers, name=STREAMS_APP_NAME, **{ @@ -305,7 +300,6 @@ def test_should_validate(self, config: KpopsConfig, handlers: ComponentHandlers) ValueError, match="Define `role` only if `type` is undefined" ): StreamsApp( - config_=config, handlers_=handlers, name=STREAMS_APP_NAME, **{ @@ -328,7 +322,6 @@ def test_set_streams_output_from_to( self, config: KpopsConfig, handlers: ComponentHandlers ): streams_app = StreamsApp( - config_=config, handlers_=handlers, name=STREAMS_APP_NAME, **{ @@ -371,7 +364,6 @@ def test_weave_inputs_from_prev_component( self, config: KpopsConfig, handlers: ComponentHandlers ): streams_app = StreamsApp( - config_=config, handlers_=handlers, name=STREAMS_APP_NAME, **{ @@ -415,7 +407,6 @@ async def test_deploy_order_when_dry_run_is_false( mocker: MockerFixture, ): streams_app = StreamsApp( - config_=config, handlers_=handlers, name=STREAMS_APP_NAME, **{ @@ -645,7 +636,6 @@ async def test_get_input_output_topics( self, config: KpopsConfig, handlers: ComponentHandlers ): streams_app = StreamsApp( - config_=config, handlers_=handlers, name="my-app", **{ diff --git a/tests/components/test_streams_bootstrap.py b/tests/components/test_streams_bootstrap.py index ebdcb819c..b72b8aca9 100644 --- a/tests/components/test_streams_bootstrap.py +++ b/tests/components/test_streams_bootstrap.py @@ -39,7 +39,6 @@ def handlers(self) -> ComponentHandlers: def test_default_configs(self, config: KpopsConfig, handlers: ComponentHandlers): streams_bootstrap = StreamsBootstrap( - config_=config, handlers_=handlers, name="example-name", **{ @@ -63,7 +62,6 @@ async def test_should_deploy_streams_bootstrap_app( mocker: MockerFixture, ): streams_bootstrap = StreamsBootstrap( - config_=config, handlers_=handlers, name="example-name", **{ diff --git a/tests/pipeline/test_components/components.py b/tests/pipeline/test_components/components.py index 150164d9a..9d7c26001 100644 --- a/tests/pipeline/test_components/components.py +++ b/tests/pipeline/test_components/components.py @@ -38,7 +38,6 @@ def inflate(self) -> list[PipelineComponent]: for topic_name, topic_config in self.to.topics.items(): if topic_config.type == OutputTopicTypes.OUTPUT: kafka_connector = KafkaSinkConnector( - config_=self.config_, handlers_=self.handlers_, name=f"{self.name}-inflated-sink-connector", config={ # type: ignore[reportGeneralTypeIssues], required `connector.class` comes from defaults during enrichment @@ -58,7 +57,6 @@ def inflate(self) -> list[PipelineComponent]: ) inflate_steps.append(kafka_connector) streams_app = StreamsApp( - config_=self.config_, handlers_=self.handlers_, name=f"{self.name}-inflated-streams-app", to=ToSection( # type: ignore[reportGeneralTypeIssues] @@ -93,7 +91,6 @@ def provide_schema( class SimpleInflateConnectors(StreamsApp): def inflate(self) -> list[PipelineComponent]: connector = KafkaSinkConnector( - config_=self.config_, handlers_=self.handlers_, name="inflated-connector-name", config={}, # type: ignore[reportArgumentType] diff --git a/tests/pipeline/test_components_without_schema_handler/components.py b/tests/pipeline/test_components_without_schema_handler/components.py index 887e5f0a7..8af3e2bea 100644 --- a/tests/pipeline/test_components_without_schema_handler/components.py +++ b/tests/pipeline/test_components_without_schema_handler/components.py @@ -22,7 +22,6 @@ def inflate(self) -> list[PipelineComponent]: for topic_name, topic_config in self.to.topics.items(): if topic_config.type == OutputTopicTypes.OUTPUT: kafka_connector = KafkaSinkConnector( - config_=self.config_, handlers_=self.handlers_, name="sink-connector", config=KafkaConnectorConfig(