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.12.tar.gz (91.7 kB view details)

Uploaded Source

Built Distribution

dagger_io-0.18.12-py3-none-any.whl (87.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dagger_io-0.18.12.tar.gz
Algorithm Hash digest
SHA256 7f51a294445aab9cb4d51fc530ae10ef4fb92f896d0fe83a97880558daa33905
MD5 d34c589c360e65494933578ecb6a5a92
BLAKE2b-256 3a5cd20973eb053d5fcbb8c8b85e3fd41099fc6383dd41b82aedab461b4fae36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagger_io-0.18.12-py3-none-any.whl
Algorithm Hash digest
SHA256 9f803e5b37ac4eedf64ff6eb45890fbf0619977937bdaa77af46dc50890c22ca
MD5 fc2b646924e5970636947730f3e303c6
BLAKE2b-256 f9b44c491dc8f8b67d0601e5812b0006e7c04db719407ea4c5d2b26d2ad3913e

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