Module
Experimental Dagger modules support.
- @dagger.mod.object_type(cls: T | None = None) T | Callable[[T], T]
Exposes a Python class as a
dagger.ObjectTypeDef
.Used with
field()
andfunction()
to expose the object’s members.Example usage:
>>> @object_type >>> class Foo: >>> @function >>> def bar(self) -> str: >>> return "foobar"
- dagger.mod.field(*, default: Callable[[], Any] | object = Ellipsis, name: str | None = None) Any
Exposes an attribute as a
dagger.FieldTypeDef
.Should be used in a class decorated with
object_type()
.Example usage:
>>> @object_type >>> class Foo: >>> bar: str = field(default="foobar") >>> args: list[str] = field(default=list)
- Parameters:
default – The default value for the field or a 0-argument callable to initialize a field’s value.
name – An alternative name for the API. Useful to avoid conflicts with reserved words.
- @dagger.mod.function(func: Func | None = None, *, name: str | None = None, doc: str | None = None) Func | Callable[[Func], Func]
Exposes a Python function as a
dagger.Function
.Example usage:
>>> @function >>> def foo() -> str: >>> return "bar"
- Parameters:
func – Should be a top-level function or instance method in a class decorated with
object_type()
. Can be an async function.name – An alternative name for the API. Useful to avoid conflicts with reserved words.
doc – An alternative description for the API. Useful to use the docstring for other purposes.