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 (run from this directory, ./sdk/python, or adjust export path accordingly):

dagger call -m ../../toolchains/python-sdk-dev dev-container with-exec --args uv,lock,-U directory --path . export --path .

Update a single pinned development dependency (run from this directory, ./sdk/python, or adjust export path accordingly):

dagger call -m ../../toolchains/python-sdk-dev dev-container with-exec --args uv,lock,-P,<DEPNAME> directory --path . export --path .

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dagger_io-0.20.5-py3-none-any.whl (109.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dagger_io-0.20.5.tar.gz
  • Upload date:
  • Size: 120.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Wolfi","version":"20230201","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dagger_io-0.20.5.tar.gz
Algorithm Hash digest
SHA256 96d8e5f5a2797ba4c1c81af856b16790b8672a15694f9f3646aa0bf341c13f13
MD5 c3c68b39d21cdff9574e005ce38a5ca0
BLAKE2b-256 c12d6ad507584cf9cbb89709be3a1f614561c742b0f6cb30cd71139999374618

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagger_io-0.20.5-py3-none-any.whl
  • Upload date:
  • Size: 109.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Wolfi","version":"20230201","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dagger_io-0.20.5-py3-none-any.whl
Algorithm Hash digest
SHA256 90e4bb465de27be9e3cb9a5bf3f2967b8078b00d716de5387e776f74bf34e878
MD5 81d6cd30e9c1d55899d87944151b6b6a
BLAKE2b-256 a81c30b9a5e3017be5a1e9a6b6d90111992e76bf4bce961a37a67b210747f99d

See more details on using hashes here.

Supported by

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