Skip to content

Commit

Permalink
chore(pre-commit): pass pre-commit checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Sep 26, 2023
1 parent e73f9ab commit 794c60d
Show file tree
Hide file tree
Showing 55 changed files with 3,051 additions and 2,726 deletions.
2 changes: 1 addition & 1 deletion docs/docs/schema/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$ref": "#/definitions/PipelineConfig",
"definitions": {
"HelmConfig": {
"description": "Global Helm configuration",
"description": "Global Helm configuration.",
"properties": {
"api_version": {
"description": "Kubernetes API version used for Capabilities.APIVersions",
Expand Down
44 changes: 22 additions & 22 deletions docs/docs/schema/pipeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"definitions": {
"FromSection": {
"additionalProperties": false,
"description": "Holds multiple input topics",
"description": "Holds multiple input topics.",
"properties": {
"components": {
"additionalProperties": {
Expand All @@ -28,7 +28,7 @@
},
"FromTopic": {
"additionalProperties": false,
"description": "Input topic",
"description": "Input topic.",
"properties": {
"role": {
"description": "Custom identifier belonging to a topic; define only if `type` is `pattern` or `None`",
Expand All @@ -48,7 +48,7 @@
"type": "object"
},
"HelmRepoConfig": {
"description": "Helm repository configuration",
"description": "Helm repository configuration.",
"properties": {
"repo_auth_flags": {
"allOf": [
Expand Down Expand Up @@ -85,7 +85,7 @@
"type": "object"
},
"InputTopicTypes": {
"description": "Input topic types\n\nINPUT (input topic), PATTERN (extra-topic-pattern or input-topic-pattern)",
"description": "Input topic types.\n\nINPUT (input topic), PATTERN (extra-topic-pattern or input-topic-pattern)",
"enum": [
"input",
"pattern"
Expand All @@ -97,7 +97,7 @@
"additionalProperties": {
"type": "string"
},
"description": "Settings specific to Kafka Connectors",
"description": "Settings specific to Kafka Connectors.",
"properties": {
"connector.class": {
"title": "Connector.Class",
Expand All @@ -111,7 +111,7 @@
"type": "object"
},
"KafkaSinkConnector": {
"description": "Kafka sink connector model",
"description": "Kafka sink connector model.",
"properties": {
"app": {
"allOf": [
Expand Down Expand Up @@ -183,7 +183,7 @@
},
"type": {
"default": "kafka-sink-connector",
"description": "Kafka sink connector model",
"description": "Kafka sink connector model.",
"enum": [
"kafka-sink-connector"
],
Expand All @@ -206,7 +206,7 @@
"type": "object"
},
"KafkaSourceConnector": {
"description": "Kafka source connector model",
"description": "Kafka source connector model.",
"properties": {
"app": {
"allOf": [
Expand Down Expand Up @@ -283,7 +283,7 @@
},
"type": {
"default": "kafka-source-connector",
"description": "Kafka source connector model",
"description": "Kafka source connector model.",
"enum": [
"kafka-source-connector"
],
Expand Down Expand Up @@ -384,13 +384,13 @@
"type": "object"
},
"KubernetesAppConfig": {
"description": "Settings specific to Kubernetes Apps",
"description": "Settings specific to Kubernetes Apps.",
"properties": {},
"title": "KubernetesAppConfig",
"type": "object"
},
"OutputTopicTypes": {
"description": "Types of output topic\n\nOUTPUT (output topic), ERROR (error topic)",
"description": "Types of output topic.\n\nOUTPUT (output topic), ERROR (error topic)",
"enum": [
"output",
"error"
Expand All @@ -399,7 +399,7 @@
"type": "string"
},
"ProducerApp": {
"description": "Producer component\nThis producer holds configuration to use as values for the streams bootstrap producer helm chart. Note that the producer does not support error topics.",
"description": "Producer component.\nThis producer holds configuration to use as values for the streams bootstrap producer helm chart. Note that the producer does not support error topics.",
"properties": {
"app": {
"allOf": [
Expand Down Expand Up @@ -462,7 +462,7 @@
},
"type": {
"default": "producer-app",
"description": "Producer component\nThis producer holds configuration to use as values for the streams bootstrap producer helm chart. Note that the producer does not support error topics.",
"description": "Producer component.\nThis producer holds configuration to use as values for the streams bootstrap producer helm chart. Note that the producer does not support error topics.",
"enum": [
"producer-app"
],
Expand All @@ -485,7 +485,7 @@
"type": "object"
},
"ProducerStreamsConfig": {
"description": "Kafka Streams settings specific to Producer",
"description": "Kafka Streams settings specific to Producer.",
"properties": {
"brokers": {
"description": "Brokers",
Expand Down Expand Up @@ -519,7 +519,7 @@
"type": "object"
},
"ProducerValues": {
"description": "Settings specific to producers",
"description": "Settings specific to producers.",
"properties": {
"nameOverride": {
"description": "Override name with this value",
Expand All @@ -543,7 +543,7 @@
"type": "object"
},
"RepoAuthFlags": {
"description": "Authorisation-related flags for `helm repo`",
"description": "Authorisation-related flags for `helm repo`.",
"properties": {
"ca_file": {
"description": "Path to CA bundle file to verify certificates of HTTPS-enabled servers",
Expand Down Expand Up @@ -578,7 +578,7 @@
"type": "object"
},
"StreamsApp": {
"description": "StreamsApp component that configures a streams bootstrap app",
"description": "StreamsApp component that configures a streams bootstrap app.",
"properties": {
"app": {
"allOf": [
Expand Down Expand Up @@ -645,7 +645,7 @@
},
"type": {
"default": "streams-app",
"description": "StreamsApp component that configures a streams bootstrap app",
"description": "StreamsApp component that configures a streams bootstrap app.",
"enum": [
"streams-app"
],
Expand All @@ -668,7 +668,7 @@
"type": "object"
},
"StreamsAppAutoScaling": {
"description": "Kubernetes Event-driven Autoscaling config",
"description": "Kubernetes Event-driven Autoscaling config.",
"properties": {
"consumerGroup": {
"description": "Name of the consumer group used for checking the offset on the topic and processing the related lag.",
Expand Down Expand Up @@ -771,7 +771,7 @@
"type": "object"
},
"StreamsConfig": {
"description": "Streams Bootstrap streams section",
"description": "Streams Bootstrap streams section.",
"properties": {
"brokers": {
"description": "Brokers",
Expand Down Expand Up @@ -854,7 +854,7 @@
"type": "object"
},
"ToSection": {
"description": "Holds multiple output topics",
"description": "Holds multiple output topics.",
"properties": {
"models": {
"additionalProperties": {
Expand All @@ -880,7 +880,7 @@
},
"TopicConfig": {
"additionalProperties": false,
"description": "Configure an output topic",
"description": "Configure an output topic.",
"properties": {
"configs": {
"additionalProperties": {
Expand Down
4 changes: 3 additions & 1 deletion kpops/cli/custom_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def format(self, record):
logging.WARNING: typer.style(message_format, fg=typer.colors.YELLOW),
logging.ERROR: typer.style(message_format, fg=typer.colors.RED),
logging.CRITICAL: typer.style(
message_format, fg=typer.colors.RED, bold=True,
message_format,
fg=typer.colors.RED,
bold=True,
),
}

Expand Down
55 changes: 42 additions & 13 deletions kpops/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import annotations

import logging
from collections.abc import Iterator
from enum import Enum
from pathlib import Path
from typing import TYPE_CHECKING, Optional
from collections.abc import Iterator

import dtyper
import typer
Expand Down Expand Up @@ -121,12 +121,17 @@ def setup_pipeline(

handlers = setup_handlers(components_module, pipeline_config)
return Pipeline.load_from_yaml(
pipeline_base_dir, pipeline_path, registry, pipeline_config, handlers,
pipeline_base_dir,
pipeline_path,
registry,
pipeline_config,
handlers,
)


def setup_handlers(
components_module: str | None, config: PipelineConfig,
components_module: str | None,
config: PipelineConfig,
) -> ComponentHandlers:
schema_handler = SchemaHandler.load_schema_handler(components_module, config)
connector_handler = KafkaConnectHandler.from_pipeline_config(config)
Expand All @@ -149,7 +154,9 @@ def get_step_names(steps_to_apply: list[PipelineComponent]) -> list[str]:


def filter_steps_to_apply(
pipeline: Pipeline, steps: set[str], filter_type: FilterType,
pipeline: Pipeline,
steps: set[str],
filter_type: FilterType,
) -> list[PipelineComponent]:
def is_in_steps(component: PipelineComponent) -> bool:
return component.name in steps
Expand All @@ -171,15 +178,19 @@ def is_in_steps(component: PipelineComponent) -> bool:


def get_steps_to_apply(
pipeline: Pipeline, steps: str | None, filter_type: FilterType,
pipeline: Pipeline,
steps: str | None,
filter_type: FilterType,
) -> list[PipelineComponent]:
if steps:
return filter_steps_to_apply(pipeline, parse_steps(steps), filter_type)
return list(pipeline)


def reverse_pipeline_steps(
pipeline: Pipeline, steps: str | None, filter_type: FilterType,
pipeline: Pipeline,
steps: str | None,
filter_type: FilterType,
) -> Iterator[PipelineComponent]:
return reversed(get_steps_to_apply(pipeline, steps, filter_type))

Expand All @@ -193,7 +204,9 @@ def log_action(action: str, pipeline_component: PipelineComponent):


def create_pipeline_config(
config: Path, defaults: Optional[Path], verbose: bool,
config: Path,
defaults: Optional[Path],
verbose: bool,
) -> PipelineConfig:
setup_logging_level(verbose)
PipelineConfig.Config.config_path = config
Expand Down Expand Up @@ -225,7 +238,8 @@ def schema(
),
components_module: Optional[str] = COMPONENTS_MODULES,
include_stock_components: bool = typer.Option(
default=True, help="Include the built-in KPOps components.",
default=True,
help="Include the built-in KPOps components.",
),
) -> None:
match scope:
Expand All @@ -251,7 +265,10 @@ def generate(
) -> Pipeline:
pipeline_config = create_pipeline_config(config, defaults, verbose)
pipeline = setup_pipeline(
pipeline_base_dir, pipeline_path, components_module, pipeline_config,
pipeline_base_dir,
pipeline_path,
components_module,
pipeline_config,
)

if not template:
Expand Down Expand Up @@ -286,7 +303,10 @@ def deploy(
):
pipeline_config = create_pipeline_config(config, defaults, verbose)
pipeline = setup_pipeline(
pipeline_base_dir, pipeline_path, components_module, pipeline_config,
pipeline_base_dir,
pipeline_path,
components_module,
pipeline_config,
)

steps_to_apply = get_steps_to_apply(pipeline, steps, filter_type)
Expand All @@ -311,7 +331,10 @@ def destroy(
):
pipeline_config = create_pipeline_config(config, defaults, verbose)
pipeline = setup_pipeline(
pipeline_base_dir, pipeline_path, components_module, pipeline_config,
pipeline_base_dir,
pipeline_path,
components_module,
pipeline_config,
)
pipeline_steps = reverse_pipeline_steps(pipeline, steps, filter_type)
for component in pipeline_steps:
Expand All @@ -335,7 +358,10 @@ def reset(
):
pipeline_config = create_pipeline_config(config, defaults, verbose)
pipeline = setup_pipeline(
pipeline_base_dir, pipeline_path, components_module, pipeline_config,
pipeline_base_dir,
pipeline_path,
components_module,
pipeline_config,
)
pipeline_steps = reverse_pipeline_steps(pipeline, steps, filter_type)
for component in pipeline_steps:
Expand All @@ -360,7 +386,10 @@ def clean(
):
pipeline_config = create_pipeline_config(config, defaults, verbose)
pipeline = setup_pipeline(
pipeline_base_dir, pipeline_path, components_module, pipeline_config,
pipeline_base_dir,
pipeline_path,
components_module,
pipeline_config,
)
pipeline_steps = reverse_pipeline_steps(pipeline, steps, filter_type)
for component in pipeline_steps:
Expand Down
3 changes: 2 additions & 1 deletion kpops/cli/pipeline_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def customise_sources(
env_settings: SettingsSourceCallable,
file_secret_settings: SettingsSourceCallable,
) -> tuple[
SettingsSourceCallable | Callable[[PipelineConfig], dict[str, Any]], ...,
SettingsSourceCallable | Callable[[PipelineConfig], dict[str, Any]],
...,
]:
return (
env_settings,
Expand Down
3 changes: 1 addition & 2 deletions kpops/cli/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import importlib
import inspect
import os
from pathlib import Path
import sys
from collections.abc import Iterator
from dataclasses import dataclass, field
from pathlib import Path
from typing import TypeVar

from kpops import __name__
Expand Down
3 changes: 1 addition & 2 deletions kpops/component_handlers/helm_wrapper/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import re
import subprocess
import tempfile
from collections.abc import Iterator
from collections.abc import Iterable
from collections.abc import Iterable, Iterator

import yaml

Expand Down
Loading

0 comments on commit 794c60d

Please sign in to comment.