Skip to content

Commit

Permalink
Revert "ci(ruff-commas): autofix"
Browse files Browse the repository at this point in the history
This reverts commit 301284e.
  • Loading branch information
sujuka99 committed Sep 27, 2023
1 parent 847d4e9 commit 5a6c3d1
Show file tree
Hide file tree
Showing 59 changed files with 449 additions and 802 deletions.
4 changes: 1 addition & 3 deletions kpops/cli/custom_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ 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
69 changes: 20 additions & 49 deletions kpops/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,12 @@ 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 @@ -155,15 +150,13 @@ 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

log.debug(
f"KPOPS_PIPELINE_STEPS is defined with values: {steps} and filter type of {filter_type.value}",
f"KPOPS_PIPELINE_STEPS is defined with values: {steps} and filter type of {filter_type.value}"
)
filtered_steps = [
component
Expand All @@ -179,19 +172,15 @@ 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 @@ -205,9 +194,7 @@ 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 All @@ -224,7 +211,7 @@ def create_pipeline_config(
Generate json schema.
The schemas can be used to enable support for kpops files in a text editor.
""",
"""
)
def schema(
scope: SchemaScope = typer.Argument(
Expand All @@ -239,8 +226,7 @@ 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 +237,7 @@ def schema(


@app.command( # pyright: ignore[reportGeneralTypeIssues] https://github.com/rec/dtyper/issues/8
help="Enriches pipelines steps with defaults. The output is used as input for the deploy/destroy/... commands.",
help="Enriches pipelines steps with defaults. The output is used as input for the deploy/destroy/... commands."
)
def generate(
pipeline_path: Path = PIPELINE_PATH_ARG,
Expand All @@ -266,10 +252,7 @@ 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 All @@ -282,14 +265,14 @@ def generate(
elif steps:
log.warning(
"The following flags are considered only when `--template` is set: \n \
'--steps'",
'--steps'"
)

return pipeline


@app.command(
help="Deploy pipeline steps",
help="Deploy pipeline steps"
) # pyright: ignore[reportGeneralTypeIssues] https://github.com/rec/dtyper/issues/8
def deploy(
pipeline_path: Path = PIPELINE_PATH_ARG,
Expand All @@ -304,10 +287,7 @@ 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 @@ -317,7 +297,7 @@ def deploy(


@app.command(
help="Destroy pipeline steps",
help="Destroy pipeline steps"
) # pyright: ignore[reportGeneralTypeIssues] https://github.com/rec/dtyper/issues/8
def destroy(
pipeline_path: Path = PIPELINE_PATH_ARG,
Expand All @@ -332,10 +312,7 @@ 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 @@ -344,7 +321,7 @@ def destroy(


@app.command(
help="Reset pipeline steps",
help="Reset pipeline steps"
) # pyright: ignore[reportGeneralTypeIssues] https://github.com/rec/dtyper/issues/8
def reset(
pipeline_path: Path = PIPELINE_PATH_ARG,
Expand All @@ -359,10 +336,7 @@ 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 @@ -372,7 +346,7 @@ def reset(


@app.command(
help="Clean pipeline steps",
help="Clean pipeline steps"
) # pyright: ignore[reportGeneralTypeIssues] https://github.com/rec/dtyper/issues/8
def clean(
pipeline_path: Path = PIPELINE_PATH_ARG,
Expand All @@ -387,10 +361,7 @@ 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: 1 addition & 2 deletions kpops/cli/pipeline_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ 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
6 changes: 2 additions & 4 deletions kpops/cli/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ def __getitem__(self, component_type: str) -> type[PipelineComponent]:
return self._classes[component_type]
except KeyError as ke:
msg = f"Could not find a component of type {component_type}"
raise ClassNotFoundError(
msg,
) from ke
raise ClassNotFoundError(msg) from ke


def find_class(module_name: str, baseclass: type[T]) -> type[T]:
Expand All @@ -59,7 +57,7 @@ def _find_classes(module_name: str, baseclass: type[T]) -> Iterator[type[T]]:
if issubclass(_class, baseclass):
# filter out internal kpops classes unless specifically requested
if _class.__module__.startswith(
KPOPS_MODULE,
KPOPS_MODULE
) and not module_name.startswith(KPOPS_MODULE):
continue
yield _class
2 changes: 1 addition & 1 deletion kpops/component_handlers/helm_wrapper/dry_run_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def print_helm_diff(self, stdout: str, helm_release_name: str, log: Logger) -> N
:param log: The Logger object of the component class
"""
current_release = list(
self._helm.get_manifest(helm_release_name, self.namespace),
self._helm.get_manifest(helm_release_name, self.namespace)
)
if current_release:
log.info(f"Helm release {helm_release_name} already exists")
Expand Down
10 changes: 3 additions & 7 deletions kpops/component_handlers/helm_wrapper/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def __init__(self, helm_config: HelmConfig) -> None:
self._version = self.get_version()
if self._version.major != 3:
msg = f"The supported Helm version is 3.x.x. The current Helm version is {self._version.major}.{self._version.minor}.{self._version.patch}"
raise RuntimeError(
msg,
)
raise RuntimeError(msg)

def add_repo(
self,
Expand Down Expand Up @@ -124,7 +122,7 @@ def uninstall(
return self.__execute(command)
except ReleaseNotFoundException:
log.warning(
f"Release with name {release_name} not found. Could not uninstall app.",
f"Release with name {release_name} not found. Could not uninstall app."
)

def template(
Expand Down Expand Up @@ -187,9 +185,7 @@ def get_version(self) -> Version:
version_match = re.search(r"^v(\d+(?:\.\d+){0,2})", short_version)
if version_match is None:
msg = f"Could not parse the Helm version.\n\nHelm output:\n{short_version}"
raise RuntimeError(
msg,
)
raise RuntimeError(msg)
version = map(int, version_match.group(1).split("."))
return Version(*version)

Expand Down
23 changes: 8 additions & 15 deletions kpops/component_handlers/helm_wrapper/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,19 @@ class RepoAuthFlags(BaseModel):
"""

username: str | None = Field(
default=None,
description=describe_attr("username", __doc__),
default=None, description=describe_attr("username", __doc__)
)
password: str | None = Field(
default=None,
description=describe_attr("password", __doc__),
default=None, description=describe_attr("password", __doc__)
)
ca_file: Path | None = Field(
default=None,
description=describe_attr("ca_file", __doc__),
default=None, description=describe_attr("ca_file", __doc__)
)
cert_file: Path | None = Field(
default=None,
description=describe_attr("cert_file", __doc__),
default=None, description=describe_attr("cert_file", __doc__)
)
insecure_skip_tls_verify: bool = Field(
default=False,
description=describe_attr("insecure_skip_tls_verify", __doc__),
default=False, description=describe_attr("insecure_skip_tls_verify", __doc__)
)

class Config(DescConfig):
Expand Down Expand Up @@ -78,13 +73,11 @@ class HelmRepoConfig(BaseModel):
"""

repository_name: str = Field(
default=...,
description=describe_attr("repository_name", __doc__),
default=..., description=describe_attr("repository_name", __doc__)
)
url: str = Field(default=..., description=describe_attr("url", __doc__))
repo_auth_flags: RepoAuthFlags = Field(
default=RepoAuthFlags(),
description=describe_attr("repo_auth_flags", __doc__),
default=RepoAuthFlags(), description=describe_attr("repo_auth_flags", __doc__)
)

class Config(DescConfig):
Expand Down Expand Up @@ -138,7 +131,7 @@ def to_command(self) -> list[str]:
[
"--set-file",
",".join([f"{key}={path}" for key, path in self.set_file.items()]),
],
]
)
if self.create_namespace:
command.append("--create-namespace")
Expand Down
2 changes: 1 addition & 1 deletion kpops/component_handlers/helm_wrapper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def trim_release_name(name: str, suffix: str = "") -> str:
if len(name) > RELEASE_NAME_MAX_LEN:
new_name = name[: (RELEASE_NAME_MAX_LEN - len(suffix))] + suffix
log.critical(
f"Invalid Helm release name '{name}'. Truncating to {RELEASE_NAME_MAX_LEN} characters: \n {name} --> {new_name}",
f"Invalid Helm release name '{name}'. Truncating to {RELEASE_NAME_MAX_LEN} characters: \n {name} --> {new_name}"
)
name = new_name
return name
Loading

0 comments on commit 5a6c3d1

Please sign in to comment.