Courseiva

PMLE Automating and Orchestrating ML Pipelines Practice Question

A machine learning engineer is using Vertex AI Pipelines and wants to run a custom Python function as a component. They need to pass a dataset artifact from a previous component and output a model artifact. Which decorator should they use to define the component in the Kubeflow Pipelines SDK v2?

⚠ Common exam trap

Candidates often confuse @dsl.component (for custom Python functions with artifact I/O) with @dsl.container (for pre-built container images) when the question emphasizes running a custom Python function.

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

The correct decorator is @dsl.component because in Kubeflow Pipelines SDK v2, this decorator is used to define a custom Python function as a reusable pipeline component. It automatically handles input and output artifact serialization, such as passing a dataset artifact from a previous component and outputting a model artifact, by leveraging the component's type annotations and the KFP artifact system.

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.task

    Why it's wrong here

    @dsl.task is not a Kubeflow Pipelines SDK v2 decorator; no such component definition exists. It is tempting as a generic lightweight task marker, but the correct decorator for a Python function component with typed artifact inputs and outputs is @dsl.component.

  • ✗

    @dsl.pipeline

    Why it's wrong here

    @dsl.pipeline decorates the pipeline function that orchestrates components, not an individual component. It is tempting because it also uses Python functions, but it defines the workflow graph and accepts no artifact-typed component signature, so it cannot produce the required model output.

  • ✓

    @dsl.component

    Why this is correct

    The @dsl.component decorator converts a plain Python function into a KFP v2 pipeline component, with typed parameters and artifacts. It supports declaring an input dataset artifact and an output model artifact, satisfying the stem's requirement for a custom Python component.

  • ✗

    @dsl.container

    Why it's wrong here

    @dsl.container defines a component from a pre-built container image and command, not from a Python function. It is tempting when packaging code as an image, but it cannot wrap the engineer's Python function directly nor infer artifact inputs and outputs from type annotations.

About these practice questions

This PMLE question is part of Courseiva's 775-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

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.