Courseiva

PMLE Automating and Orchestrating ML Pipelines Practice Question

A data scientist wants to define a lightweight Python function component in Vertex AI Pipelines using Kubeflow Pipelines SDK v2. Which decorator should be applied to the function to make it a pipeline component?

⚠ Common exam trap

PMLE often tests the distinction between @dsl.component (defines a component) and @dsl.pipeline (defines the pipeline), and includes legacy v1 decorators like func_to_component to confuse candidates about SDK v2 syntax.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

@dsl.component

In Kubeflow Pipelines SDK v2, the @dsl.component decorator converts a lightweight Python function into a pipeline component. This is the standard v2 approach for defining function-based components. @dsl.pipeline is used to define the pipeline itself, not individual components.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    @dsl.pipeline

    Why it's wrong here

    @dsl.pipeline decorates the function that assembles and returns a pipeline definition, not an individual component. It is tempting because both decorators appear in the same script, but applying it to a component function produces a pipeline object rather than a reusable step with typed inputs and outputs.

  • ✗

    @kfp.v2.components.func_to_component

    Why it's wrong here

    The decorator `@kfp.v2.components.func_to_component` is incorrect because it is designed for converting Python functions into *containerised* Kubeflow Pipeline components, which involves building a Docker image for execution. The question specifically asks for a *lightweight Python function component*, which in Kubeflow Pipelines SDK v2 (used by Vertex AI Pipelines) does not require containerisation. This option is tempting as its name implies function-to-component conversion, and it would be the correct choice if defining a component that needs a custom execution environment via a Docker image.

  • ✓

    @dsl.component

    Why this is correct

    The @dsl.component decorator converts a plain Python function into a lightweight KFP v2 component, with the function's signature defining its inputs and outputs. This is the specific mechanism the stem requests for authoring a Python function component in Kubeflow Pipelines SDK v2.

  • ✗

    @kfp.dsl.component

    Why it's wrong here

    Kubeflow Pipelines SDK v2 exposes the lightweight component decorator as @dsl.component; @kfp.dsl.component is not the v2 API surface. The kfp.dsl path is tempting because v1 examples and older tutorials use that namespace, but v2 code must import from kfp import dsl.

About these practice questions

Courseiva writes every PMLE question from scratch — 775 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Google Cloud exam blueprint

This PMLE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PMLE exam.