Skip to main content

Pipeline SDK Version Size Downloads License Discord

Created by mystic.ai

Try premade models for free that have been made using this library: https://www.mystic.ai/explore

Table of Contents

About

Pipeline is a python library that provides a simple way to construct computational flows for AI/ML models. The library is suitable for both development and production environments supporting inference and training/finetuning. This library is also a direct interface to Mystic which provides a compute engine to run pipelines at scale and on enterprise GPUs. This SDK can also be used with Pipeline Core on a private hosted cluster.

The syntax used for defining AI/ML pipelines shares some similarities in syntax to sessions in Tensorflow v1, and Flows found in Prefect.

Installation and quickstart

To install pipeline run:

pip install pipeline-ai

To create a new pipeline navigate to the directory you want to create the pipeline in and run:

pipeline container init -n quickstart

This will create two files in the directory:

  • pipeline.yaml - The configuration file for the container to run the pipeline.
  • new_pipeline.py - The python file to populate with your pipeline.

Models

Below are some popular models that have been premade by the community on Mystic. You can find more models in the explore section of Mystic, and the source code for these models is also referenced in the table.

Model Category Description Source
meta/llama2-7B LLM A 7B parameter LLM created by Meta (vllm accelerated) source
meta/llama2-13B LLM A 13B parameter LLM created by Meta (vllm accelerated) source
meta/llama2-70B LLM A 70B parameter LLM created by Meta (vllm accelerated) source
runwayml/stable-diffusion-1.5 Vision Text -> Image source
stabilityai/stable-diffusion-xl-refiner-1.0 Vision SDXL Text -> Image source
matthew/e5_large-v2 LLM Text embedding source
matthew/musicgen_large Audio Music generation source
matthew/blip Vision Image captioning source

Example and tutorials

Tutorial Description
Entity objects Use entity objects to persist values and store things
Cold start optimisations Premade functions to do heavy tasks seperately
Input/output types Defining what goes in and out of your pipes
Files Inputing or outputing files from your runs
Pipeline building Building pipelines - how it works
Runs Running a pipeline remotely - how it works

Below is some sample python that demonstrates various features and how to use the Pipeline SDK to create a simple pipeline that can be run locally or on Mystic.

from pathlib import Path
from typing import List

import torch
from diffusers import StableDiffusionPipeline

from pipeline import Pipeline, Variable, pipe, entity
from pipeline.cloud import compute_requirements
from pipeline.objects import File
from pipeline.objects.graph import InputField, InputSchema


class ModelKwargs(InputSchema): # TUTORIAL: Input/output types
    height: int | None = InputField(default=512, ge=64, le=1024)
    width: int | None = InputField(default=512, ge=64, le=1024)
    num_inference_steps: int | None = InputField(default=50)
    num_images_per_prompt: int | None = InputField(default=1, ge=1, le=4)
    guidance_scale: int | None = InputField(default=7.5)


@entity # TUTORIAL: Entity objects
class StableDiffusionModel:
    @pipe(on_startup=True, run_once=True) # TUTORIAL: Cold start optimisations
    def load(self):
        model_id = "runwayml/stable-diffusion-v1-5"
        device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
        self.pipe = StableDiffusionPipeline.from_pretrained(
            model_id,
        )
        self.pipe = self.pipe.to(device)

    @pipe
    def predict(self, prompt: str, kwargs: ModelKwargs) -> List[File]: # TUTORIAL: Input/output types
        defaults = kwargs.to_dict()
        images = self.pipe(prompt, **defaults).images

        output_images = []
        for i, image in enumerate(images):
            path = Path(f"/tmp/sd/image-{i}.jpg")
            path.parent.mkdir(parents=True, exist_ok=True)
            image.save(str(path))
            output_images.append(File(path=path, allow_out_of_context_creation=True)) # TUTORIAL: Files

        return output_images


with Pipeline() as builder: # TUTORIAL: Pipeline building
    prompt = Variable(str)
    kwargs = Variable(ModelKwargs)
    model = StableDiffusionModel()
    model.load()
    output = model.predict(prompt, kwargs)
    builder.output(output)

my_pl = builder.get_pipeline()

Development

This project is made with poetry, so firstly setup poetry on your machine.

Once that is done, please run

./setup.sh

With this you should be good to go. This sets up dependencies, pre-commit hooks and pre-push hooks.

You can manually run pre commit hooks with

pre-commit run --all-files

To run tests manually please run

pytest

For developing v4, i.e. containerized pipelines, you need to override the installed pipeline-ai python package on the container. This can be done by bind mounting your target pipeline directory, e.g. using raw docker

License

Pipeline is licensed under Apache Software License Version 2.0.

Metadata

Release files for pipeline-ai 2.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pipeline-ai 2.8.0
File Size Uploaded Provenance Actions
pipeline_ai-2.8.0.tar.gz 901.6 kB Without provenance Details for pipeline_ai-2.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pipeline-ai 2.8.0
File Interpreter ABI Platform Actions
pipeline_ai-2.8.0-py3-none-any.whl Python 3 none any Details for pipeline_ai-2.8.0-py3-none-any.whl

Total release size: 1.9 MB

Release files / pipeline_ai-2.8.0.tar.gz

Download URL pipeline_ai-2.8.0.tar.gz
Size 901.6 kB
Tags Source
SHA-256 checksum
How to use checksums
31e416ea4cefdb5e20ee711c537a0139490ab64ec732dec6a7e90740ffc0aa77
BLAKE2b-256 checksum
How to use checksums
d776c68f222a561c1438d6912808a5e8968f45782745ffbe461343de778c92ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / pipeline_ai-2.8.0-py3-none-any.whl

Download URL pipeline_ai-2.8.0-py3-none-any.whl
Size 1.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4a276bacbec309317454628a50f73e994aaf00dc44c531085a7f250d25fdeaaf
BLAKE2b-256 checksum
How to use checksums
3ece166f50356555c3c0f5b0c1ead251e15569253f4662f6e55eef0eac2ac8f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Security for pipeline-ai 2.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.8.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page