Skip to main content

A client package for running Dagger pipelines in Python.

Project description

Dagger Python SDK

PyPI Version Conda Version Supported Python Versions License Code style Ruff

A client package for running Dagger pipelines.

What is the Dagger Python SDK?

The Dagger Python SDK contains everything you need to develop CI/CD pipelines in Python, and run them on any OCI-compatible container runtime.

Requirements

  • Python 3.10 or later
  • Docker, or another OCI-compatible container runtime

A compatible version of the Dagger CLI is automatically downloaded and run by the SDK for you, although it’s possible to manage it manually.

Installation

From PyPI, using pip:

pip install dagger-io

You can also install via Conda, from the conda-forge channel:

conda install dagger-io

Example

Create a main.py file:

import sys

import anyio
import dagger
from dagger import dag


async def main(args: list[str]):
    async with dagger.connection():
        # build container with cowsay entrypoint
        ctr = (
            dag.container()
            .from_("python:alpine")
            .with_exec(["pip", "install", "cowsay"])
        )

        # run cowsay with requested message
        result = await ctr.with_exec(["cowsay", *args]).stdout()

    print(result)


anyio.run(main, sys.argv[1:])

Run with:

$ python main.py "Simple is better than complex"
  _____________________________
| Simple is better than complex |
  =============================
                             \
                              \
                                ^__^
                                (oo)\_______
                                (__)\       )\/\
                                    ||----w |
                                    ||     ||

Note It may take a while for it to finish, especially on first run with cold cache.

If you need to debug, you can stream the logs from the engine with the log_output config:

config = dagger.Config(log_output=sys.stderr)
async with dagger.connection(config):
    ...

Learn more

Development

The SDK is managed with a Dagger module in ./dev. To see which tasks are available run:

dagger call -m dev

Common tasks

Run pytest in supported Python versions:

dagger call -m dev test default

Check for linting violations:

dagger call -m dev lint

Re-format code following common styling conventions:

dagger call -m dev format export --path=.

Update pinned development dependencies:

uv lock -U

Build and preview the reference documentation:

dagger call -m dev docs preview up

Add --help to any command to check all the available options.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dagger_io-0.18.5.tar.gz (87.6 kB view details)

Uploaded Source

Built Distribution

dagger_io-0.18.5-py3-none-any.whl (84.6 kB view details)

Uploaded Python 3

File details

Details for the file dagger_io-0.18.5.tar.gz.

File metadata

  • Download URL: dagger_io-0.18.5.tar.gz
  • Upload date:
  • Size: 87.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for dagger_io-0.18.5.tar.gz
Algorithm Hash digest
SHA256 303e0b04ff339dd996446d1d8ad586b01334d999eee349e8fd524b0eebf68d28
MD5 e3fcbbeafd4071b90222063de8f83a65
BLAKE2b-256 2aabaf6be01776723bd1acf17f58f3e3936af5161759bd0902fefe66606dc935

See more details on using hashes here.

File details

Details for the file dagger_io-0.18.5-py3-none-any.whl.

File metadata

File hashes

Hashes for dagger_io-0.18.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a5be79fefe77186f66a4b8daa3933feace392e2a9d0c14fd0d1b6852ac6c440e
MD5 ec7ce5aeff3d6515722b29d8e4285df3
BLAKE2b-256 a9646e459c1cd928c1ba3d3bcef7544f4cd1ac1ff00a891c70617253058f32a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page