A client package for running Dagger pipelines in Python.
Project description
Dagger 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"])
.with_entrypoint(["cowsay"])
)
# run cowsay with requested message
result = await ctr.with_exec(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
Built Distribution
File details
Details for the file dagger_io-0.14.0.tar.gz
.
File metadata
- Download URL: dagger_io-0.14.0.tar.gz
- Upload date:
- Size: 80.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.30
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e1108a09421d8d56711a15f8d61cbd234f6ccb2367b1c1df2dd44f902aae678 |
|
MD5 | 7071384bb5fc2fa31e7ca776d3b7f605 |
|
BLAKE2b-256 | a36b59487e1a92e07ffd8cbcb9c9776ab8583c87832fbb331062fcc7fcbc109c |
File details
Details for the file dagger_io-0.14.0-py3-none-any.whl
.
File metadata
- Download URL: dagger_io-0.14.0-py3-none-any.whl
- Upload date:
- Size: 76.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.30
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b840c9608187b15ee6cd497186acb7ecffc32191ae8871cb42d142cad7bab399 |
|
MD5 | 0bac95c86f3e1a6d5f89cbe82a7e9a64 |
|
BLAKE2b-256 | 200f917a9efd38b06d7e307479b45b208ad59df42028e713337141964b97b7f3 |