Skip to content

Run.params

The parameters the workflow was run with, parsed into a class of your own. Declare each one with arg(), and name the class in the workflow's Run, as Run[Params].

@dataclass(frozen=True)
class Params:
    request: str = arg("-r", "--request", help="What to implement.")
    dry_run: bool = arg("--dry-run", default=False, help="Plan only.")

@workflow
async def implement(run: Run[Params]) -> None:
    await run.step(builder, run.params.request)
agl run implement -n login-page -r "Add a login page" --dry-run

A parameter can be a str, int, float or bool. One without a default is required. A bool is a switch: declare it with default=False, and its flag sets it to true. -n, --name, --from, -h and --help belong to AGL.

agl workflows implement shows a workflow's parameters. A resumed run keeps the ones it started with.

Reference

agl.sdk.Run.params instance-attribute

The workflow's own parameters, as the flags on agl run filled them in.

agl.sdk.arg

arg(*flags: str, default: T, help: str = '') -> T
arg(*flags: str, help: str = '') -> Any

Declares a field of a params dataclass as a command-line flag.

Parameters:

  • flags (str, default: () ) –

    The flag's spellings, such as -r and --request. At least one.

  • default (Any, default: MISSING ) –

    The value when the flag isn't given. If omitted, the flag is required. A bool field must use default=False.

  • help (str, default: '' ) –

    The text agl workflows <workflow> shows beside the flag.

Returns:

  • Any –

    The dataclasses.field to assign to the annotated field.

Raises:

  • InputError –

    No flags, a flag agl run uses or can't accept, or a bad default.