python
This module only supports python apps using UV for builds.Current linters supported: pylint, ruff, mypy, pytest, pyright
Installation
dagger install github.com/act3-ai/dagger/python@v0.5.2Entrypoint
Return Type
Python !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| src | Directory ! | - | top-level source code directory |
| base | Container | - | base development container |
| syncArgs | [String ! ] | - | extra arguments for uv sync command |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATHfunc (m *MyModule) Example(src *dagger.Directory) *dagger.Python {
return dag.
Python(src)
}@function
def example(src: dagger.Directory, ) -> dagger.Python:
return (
dag.python(src)
)@func()
example(src: Directory, ): Python {
return dag
.python(src)
}Types
Python 🔗
base() 🔗
Base container (with cache mounts added)
Return Type
Container ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH basefunc (m *MyModule) Example(src *dagger.Directory) *dagger.Container {
return dag.
Python(src).
Base()
}@function
def example(src: dagger.Directory, ) -> dagger.Container:
return (
dag.python(src)
.base()
)@func()
example(src: Directory, ): Container {
return dag
.python(src)
.base()
}ruff() 🔗
contains commands for running ruff on a Python project.
Return Type
Ruff ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH rufffunc (m *MyModule) Example(src *dagger.Directory) *dagger.PythonRuff {
return dag.
Python(src).
Ruff()
}@function
def example(src: dagger.Directory, ) -> dagger.PythonRuff:
return (
dag.python(src)
.ruff()
)@func()
example(src: Directory, ): PythonRuff {
return dag
.python(src)
.ruff()
}service() 🔗
create function test service
Return Type
Service ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH servicefunc (m *MyModule) Example(src *dagger.Directory) *dagger.Service {
return dag.
Python(src).
Service()
}@function
def example(src: dagger.Directory, ) -> dagger.Service:
return (
dag.python(src)
.service()
)@func()
example(src: Directory, ): Service {
return dag
.python(src)
.service()
}functionTest() 🔗
Return the result of running function test
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| dir | String | "ftest" | function test directory |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH function-testfunc (m *MyModule) Example(ctx context.Context, src *dagger.Directory) string {
return dag.
Python(src).
FunctionTest(ctx)
}@function
async def example(src: dagger.Directory, ) -> str:
return await (
dag.python(src)
.function_test()
)@func()
async example(src: Directory, ): Promise<string> {
return dag
.python(src)
.functionTest()
}container() 🔗
returns a base UV container and builds dev dependencies using uv sync
Return Type
Container ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH containerfunc (m *MyModule) Example(src *dagger.Directory) *dagger.Container {
return dag.
Python(src).
Container()
}@function
def example(src: dagger.Directory, ) -> dagger.Container:
return (
dag.python(src)
.container()
)@func()
example(src: Directory, ): Container {
return dag
.python(src)
.container()
}withIndexAuth() 🔗
Add creds for private python package index
Return Type
Python !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| name | String ! | - | name of index in pyproject.toml |
| username | String ! | - | username to authenticate with |
| password | Secret ! | - | password to authenticate with |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH with-index-auth --name string --username string --password env:MYSECRETfunc (m *MyModule) Example(src *dagger.Directory, name string, username string, password *dagger.Secret) *dagger.Python {
return dag.
Python(src).
WithIndexAuth(name, username, password)
}@function
def example(src: dagger.Directory, name: str, username: str, password: dagger.Secret) -> dagger.Python:
return (
dag.python(src)
.with_index_auth(name, username, password)
)@func()
example(src: Directory, name: string, username: string, password: Secret): Python {
return dag
.python(src)
.withIndexAuth(name, username, password)
}withEnvVariable() 🔗
add an environment variable to the base container
Return Type
Python !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| name | String ! | - | No description provided |
| value | String ! | - | No description provided |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH with-env-variable --name string --value stringfunc (m *MyModule) Example(src *dagger.Directory, name string, value string) *dagger.Python {
return dag.
Python(src).
WithEnvVariable(name, value)
}@function
def example(src: dagger.Directory, name: str, value: str) -> dagger.Python:
return (
dag.python(src)
.with_env_variable(name, value)
)@func()
example(src: Directory, name: string, value: string): Python {
return dag
.python(src)
.withEnvVariable(name, value)
}withNetrc() 🔗
adds a netrc file as a secret to the base container
Return Type
Python !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| netrc | Secret ! | - | netrc file to add, in format of dagger.secret (--netrc file://mynetrc) |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH with-netrc --netrc env:MYSECRETfunc (m *MyModule) Example(src *dagger.Directory, netrc *dagger.Secret) *dagger.Python {
return dag.
Python(src).
WithNetrc(netrc)
}@function
def example(src: dagger.Directory, netrc: dagger.Secret) -> dagger.Python:
return (
dag.python(src)
.with_netrc(netrc)
)@func()
example(src: Directory, netrc: Secret): Python {
return dag
.python(src)
.withNetrc(netrc)
}checkLock() 🔗
check that the lockfile is in sync with pyproject.toml
Return Type
String ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH check-lockfunc (m *MyModule) Example(ctx context.Context, src *dagger.Directory) string {
return dag.
Python(src).
CheckLock(ctx)
}@function
async def example(src: dagger.Directory, ) -> str:
return await (
dag.python(src)
.check_lock()
)@func()
async example(src: Directory, ): Promise<string> {
return dag
.python(src)
.checkLock()
}mypy() 🔗
contains commands for running mypy on a Python project.
Return Type
Mypy ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH mypyfunc (m *MyModule) Example(src *dagger.Directory) *dagger.PythonMypy {
return dag.
Python(src).
Mypy()
}@function
def example(src: dagger.Directory, ) -> dagger.PythonMypy:
return (
dag.python(src)
.mypy()
)@func()
example(src: Directory, ): PythonMypy {
return dag
.python(src)
.mypy()
}publish() 🔗
publish python package/wheel
Return Type
Container !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| buildArgs | [String ! ] | - | extra args to pass into uv build |
| publishUrl | String ! | - | url to publish python package/wheel to |
| username | String ! | - | username for private publish url |
| password | Secret ! | - | password for private publish url, must be given in dagger.Secret format, in ex. env://MY_TOKEN |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH publish --publish-url string --username string --password env:MYSECRETfunc (m *MyModule) Example(src *dagger.Directory, publishUrl string, username string, password *dagger.Secret) *dagger.Container {
return dag.
Python(src).
Publish(publishUrl, username, password)
}@function
def example(src: dagger.Directory, publish_url: str, username: str, password: dagger.Secret) -> dagger.Container:
return (
dag.python(src)
.publish(publish_url, username, password)
)@func()
example(src: Directory, publishUrl: string, username: string, password: Secret): Container {
return dag
.python(src)
.publish(publishUrl, username, password)
}pylint() 🔗
contains commands for running pylint on a Python project.
Return Type
Pylint ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH pylintfunc (m *MyModule) Example(src *dagger.Directory) *dagger.PythonPylint {
return dag.
Python(src).
Pylint()
}@function
def example(src: dagger.Directory, ) -> dagger.PythonPylint:
return (
dag.python(src)
.pylint()
)@func()
example(src: Directory, ): PythonPylint {
return dag
.python(src)
.pylint()
}pyright() 🔗
contains commands for running pyright on a Python project.
Return Type
Pyright ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH pyrightfunc (m *MyModule) Example(src *dagger.Directory) *dagger.PythonPyright {
return dag.
Python(src).
Pyright()
}@function
def example(src: dagger.Directory, ) -> dagger.PythonPyright:
return (
dag.python(src)
.pyright()
)@func()
example(src: Directory, ): PythonPyright {
return dag
.python(src)
.pyright()
}pytest() 🔗
contains commands for running pytest on a Python project.
Return Type
Pytest ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
--src DIR_PATH pytestfunc (m *MyModule) Example(src *dagger.Directory) *dagger.PythonPytest {
return dag.
Python(src).
Pytest()
}@function
def example(src: dagger.Directory, ) -> dagger.PythonPytest:
return (
dag.python(src)
.pytest()
)@func()
example(src: Directory, ): PythonPytest {
return dag
.python(src)
.pytest()
}Ruff 🔗
lint() 🔗
Runs ruff check and returns a container that will fail on any errors.
Return Type
Container !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| outputFormat | String | "full" | No description provided |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
ruff \
lintfunc (m *MyModule) Example() *dagger.Container {
return dag.
Python().
Ruff().
Lint()
}@function
def example() -> dagger.Container:
return (
dag.python()
.ruff()
.lint()
)@func()
example(): Container {
return dag
.python()
.ruff()
.lint()
}report() 🔗
Runs ruff check and returns a results in a json file.
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
ruff \
reportfunc (m *MyModule) Example() *dagger.File {
return dag.
Python().
Ruff().
Report()
}@function
def example() -> dagger.File:
return (
dag.python()
.ruff()
.report()
)@func()
example(): File {
return dag
.python()
.ruff()
.report()
}fix() 🔗
Runs ruff format against a given source directory. Returns a Changeset that can be used to apply any changes found to the host.
Return Type
Changeset !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| exclude | [String ! ] | - | file pattern to exclude from ruff format |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
ruff \
fixfunc (m *MyModule) Example() *dagger.Changeset {
return dag.
Python().
Ruff().
Fix()
}@function
def example() -> dagger.Changeset:
return (
dag.python()
.ruff()
.fix()
)@func()
example(): Changeset {
return dag
.python()
.ruff()
.fix()
}Mypy 🔗
run commands with mypy
lint() 🔗
Runs mypy on a given source directory. Returns a container that will fail on any errors.
Return Type
Container !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| outputFormat | String | - | No description provided |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
mypy \
lintfunc (m *MyModule) Example() *dagger.Container {
return dag.
Python().
Mypy().
Lint()
}@function
def example() -> dagger.Container:
return (
dag.python()
.mypy()
.lint()
)@func()
example(): Container {
return dag
.python()
.mypy()
.lint()
}report() 🔗
Runs mypy and returns results in a json file.
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
mypy \
reportfunc (m *MyModule) Example() *dagger.File {
return dag.
Python().
Mypy().
Report()
}@function
def example() -> dagger.File:
return (
dag.python()
.mypy()
.report()
)@func()
example(): File {
return dag
.python()
.mypy()
.report()
}Pylint 🔗
lint() 🔗
Runs pylint on a given source directory. Returns a container that will fail on any errors.
Return Type
Container !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| outputFormat | String | "text" | No description provided |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
pylint \
lintfunc (m *MyModule) Example() *dagger.Container {
return dag.
Python().
Pylint().
Lint()
}@function
def example() -> dagger.Container:
return (
dag.python()
.pylint()
.lint()
)@func()
example(): Container {
return dag
.python()
.pylint()
.lint()
}report() 🔗
Runs pylint and returns results in a json file
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
pylint \
reportfunc (m *MyModule) Example() *dagger.File {
return dag.
Python().
Pylint().
Report()
}@function
def example() -> dagger.File:
return (
dag.python()
.pylint()
.report()
)@func()
example(): File {
return dag
.python()
.pylint()
.report()
}Pyright 🔗
lint() 🔗
Runs pyright on a given source directory. Returns a container that will fail on any errors.
Return Type
Container ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
pyright \
lintfunc (m *MyModule) Example() *dagger.Container {
return dag.
Python().
Pyright().
Lint()
}@function
def example() -> dagger.Container:
return (
dag.python()
.pyright()
.lint()
)@func()
example(): Container {
return dag
.python()
.pyright()
.lint()
}report() 🔗
Runs pyright and returns results in a json file.
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
pyright \
reportfunc (m *MyModule) Example() *dagger.File {
return dag.
Python().
Pyright().
Report()
}@function
def example() -> dagger.File:
return (
dag.python()
.pyright()
.report()
)@func()
example(): File {
return dag
.python()
.pyright()
.report()
}Pytest 🔗
test() 🔗
Runs pytest and returns a container that will fail on any errors.
Return Type
Container !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| testPaths | [String ! ] | - | provide optional test paths for pytest to use, otherwise pytest will autodiscover from the given source dir |
| extraArgs | [String ! ] | - | extra arguments to pytest, e.g., add "--cov-fail-under=80" to fail if coverage is below 80% |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
pytest \
testfunc (m *MyModule) Example() *dagger.Container {
return dag.
Python().
Pytest().
Test()
}@function
def example() -> dagger.Container:
return (
dag.python()
.pytest()
.test()
)@func()
example(): Container {
return dag
.python()
.pytest()
.test()
}report() 🔗
Runs pytest and returns results in multiple file formats. Current formats: json, xml, and html.
Return Type
PytestResults !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| testPaths | [String ! ] | - | provide optional test paths for pytest to use, otherwise pytest will autodiscover from the given source dir |
| extraArgs | [String ! ] | - | extra arguments to pytest, e.g., add "--cov-fail-under=80" to fail if coverage is below 80% |
Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
pytest \
reportfunc (m *MyModule) Example() *dagger.PythonPytestResults {
return dag.
Python().
Pytest().
Report()
}@function
def example() -> dagger.PythonPytestResults:
return (
dag.python()
.pytest()
.report()
)@func()
example(): PythonPytestResults {
return dag
.python()
.pytest()
.report()
}PytestResults 🔗
xml() 🔗
returns results of unit-test as xml in a file.
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
pytest \
report \
xmlfunc (m *MyModule) Example() *dagger.File {
return dag.
Python().
Pytest().
Report().
Xml()
}@function
def example() -> dagger.File:
return (
dag.python()
.pytest()
.report()
.xml()
)@func()
example(): File {
return dag
.python()
.pytest()
.report()
.xml()
}json() 🔗
returns results of unit-test as json in a file.
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
pytest \
report \
jsonfunc (m *MyModule) Example() *dagger.File {
return dag.
Python().
Pytest().
Report().
Json()
}@function
def example() -> dagger.File:
return (
dag.python()
.pytest()
.report()
.json()
)@func()
example(): File {
return dag
.python()
.pytest()
.report()
.json()
}html() 🔗
returns results of unit-test as html in a directory
Return Type
Directory ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
pytest \
report \
htmlfunc (m *MyModule) Example() *dagger.Directory {
return dag.
Python().
Pytest().
Report().
Html()
}@function
def example() -> dagger.Directory:
return (
dag.python()
.pytest()
.report()
.html()
)@func()
example(): Directory {
return dag
.python()
.pytest()
.report()
.html()
}merged() 🔗
A directory with all results merged in
Return Type
Directory ! Example
dagger -m github.com/act3-ai/dagger/python@7f9a02e94771fed62c6d4876f603522430d84bd4 call \
pytest \
report \
mergedfunc (m *MyModule) Example() *dagger.Directory {
return dag.
Python().
Pytest().
Report().
Merged()
}@function
def example() -> dagger.Directory:
return (
dag.python()
.pytest()
.report()
.merged()
)@func()
example(): Directory {
return dag
.python()
.pytest()
.report()
.merged()
}