Skip to content

Commit

Permalink
Remove workaround for pipeline steps (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted authored Jul 11, 2023
1 parent 42116dc commit d043822
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
8 changes: 3 additions & 5 deletions kpops/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,9 @@ def filter_component(component: PipelineComponent) -> bool:
def get_steps_to_apply(
pipeline: Pipeline, steps: str | None
) -> list[PipelineComponent]:
return (
list(pipeline)
if not steps or steps == '""' # workaround to allow "" as empty value for CI
else filter_steps_to_apply(pipeline, steps=parse_steps(steps))
)
if steps:
return filter_steps_to_apply(pipeline, steps=parse_steps(steps))
return list(pipeline)


def reverse_pipeline_steps(pipeline, steps) -> Iterator[PipelineComponent]:
Expand Down
21 changes: 12 additions & 9 deletions tests/cli/test_pipeline_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@
from kpops.cli.main import get_steps_to_apply
from kpops.pipeline_generator.pipeline import Pipeline

PREFIX = "example-prefix-"


@patch("kpops.cli.main.log.info")
def tests_filter_steps_to_apply(log_info):
@dataclass
class TestComponent:
name: str
prefix: str = "example-prefix-"
prefix: str = PREFIX

test_component_1 = TestComponent(PREFIX + "example1")
test_component_2 = TestComponent(PREFIX + "example2")
test_component_3 = TestComponent(PREFIX + "example3")

class TestPipeline:
components = [
TestComponent("example-prefix-example1"),
TestComponent("example-prefix-example2"),
TestComponent("example-prefix-example3"),
test_component_1,
test_component_2,
test_component_3,
]

def __iter__(self):
Expand All @@ -27,8 +33,8 @@ def __iter__(self):
filtered_steps = get_steps_to_apply(pipeline, steps="example2,example3")

assert len(filtered_steps) == 2
assert TestComponent("example-prefix-example2") in filtered_steps
assert TestComponent("example-prefix-example3") in filtered_steps
assert test_component_2 in filtered_steps
assert test_component_3 in filtered_steps

assert log_info.call_count == 2
log_info.assert_any_call("KPOPS_PIPELINE_STEPS is defined.")
Expand All @@ -41,6 +47,3 @@ def __iter__(self):

filtered_steps = get_steps_to_apply(pipeline, steps="")
assert len(filtered_steps) == 3

filtered_steps = get_steps_to_apply(pipeline, steps='""')
assert len(filtered_steps) == 3

0 comments on commit d043822

Please sign in to comment.