Python Quickstart

A working Pipelogic component takes typed backend data, transforms it, and emits typed output. This page walks you from an empty folder to a published component in about ten minutes.

Prerequisites

You don't need Docker, you don't need to install the SDK. ppl release ships your sources to the platform; the platform builds the container image remotely.

1. Scaffold the component

Pick a folder name that matches the component you're building. For this guide we'll write convert-image-grayscale:

mkdir convert-image-grayscale && cd convert-image-grayscale
mkdir src
touch component.yml src/main.py src/requirements.txt

ppl init will set up the workspace metadata for you in step 5.

2. Write component.yml

The metadata file declares the component's name, runtime, typed I/O, and tags:

name: "Convert image to grayscale"
language: py
platform: linux/amd64
build_system: 2
tags: ["latest", "default"]
worker:
  input_type: Image
  output_type: Image

3. Pin dependencies

src/requirements.txt:

opencv-python-headless==4.11.0.86

Two important rules:

  • Name
    Pin every dependency exactly
    Type
    ==1.2.3, never >=, ~=, or unpinned
    Description

    Loose pins make builds non-reproducible and let new CVEs roll in silently.

  • Name
    Do not list numpy
    Type
    forbidden
    Description

    pipelogic already depends on numpy at the version the platform expects. Listing it again invites version conflicts.

4. Write the worker

src/main.py:

from pipelogic.worker import run
from pipelogic.cv import Image, ColorSpace


def to_grayscale(image: Image) -> Image:
    return Image(image.to_gray(), color_space=ColorSpace.GRAY)


run(to_grayscale)

What's happening:

  • pipelogic.cv.Image wraps an incoming backend image. image.to_gray() returns a (H, W) uint8 ndarray regardless of whether the input was BGR, RGB, RGBA, BGRA, or already GRAY.
  • The output Image(arr, ColorSpace.GRAY) is serialized automatically when the worker returns.
  • run(...) blocks until the backend closes.

You never assemble dicts by hand — the high-level wrappers do it for you. See API: cv for the full surface.

5. Initialize and release

Log in once:

ppl login

Initialize the component. This registers the component in your workspace and writes the .pipecomponent metadata file:

ppl init

Push a release. The platform compiles the component remotely, builds a container image, and uploads the new version to your workspace:

ppl release

When the release finishes, the new version is selectable in the App under Components.

6. Use it in a backend

Open app.pipelogic.ai, create a new backend, and drag in:

  1. Input image file (or any other Image producer)
  2. Your new Convert image to grayscale
  3. Output browser video (to see the result live)

Connect each Image output to the next input and click Run.

What's next

Was this page helpful?