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)
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 ¶
Declares a field of a params dataclass as a command-line flag.
Parameters:
-
flags(str, default:()) –The flag's spellings, such as
-rand--request. At least one. -
default(Any, default:MISSING) –The value when the flag isn't given. If omitted, the flag is required. A
boolfield must usedefault=False. -
help(str, default:'') –The text
agl workflows <workflow>shows beside the flag.
Returns:
-
Any–The
dataclasses.fieldto assign to the annotated field.
Raises:
-
InputError–No flags, a flag
agl runuses or can't accept, or a bad default.