"""Compile a two-step greeting pipeline; submission happens through the UI."""

from kfp import compiler, dsl


@dsl.component(base_image="python:3.11-slim")
def make_greeting(name: str) -> str:
    message = f"Hello, {name}!"
    print(message)
    return message


@dsl.component(base_image="python:3.11-slim")
def count_words(message: str) -> int:
    count = len(message.split())
    print(f"Received: {message}")
    print(f"Word count: {count}")
    return count


@dsl.pipeline(name="hello-studio")
def hello_studio(name: str = "world"):
    greeting = make_greeting(name=name)
    greeting.set_caching_options(False)
    count_words(message=greeting.output).set_caching_options(False)


if __name__ == "__main__":
    compiler.Compiler().compile(hello_studio, "hello_pipeline.yaml")
    print("Created hello_pipeline.yaml")
