A client package for running Dagger pipelines in Python.
Actively maintained. Last release 5 days ago, commits in 26 of the last 26 weeks. A safe choice.
pip install dagger-ioDagger Python SDK
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:])