1. Orchestration
  2. Retries

A failed step is tried again on its own. If it still fails, the run stops there, and you can rerun from that step without redoing the ones that finished.

Rendering diagram…

​
Automatic retries

Every step takes retries: the number of extra attempts after the first one.

@ava.step(retries=2)
def fetch_rates() -> dict: ...
Default7 extra attempts, so 8 in total. This is also the maximum.
Applies toPython, agent and classifier steps
A retry startsRight after the failure

​
Stop retrying

Raise ava.NonRetryableError when another attempt cannot help.

@ava.step
def charge(order: Order) -> Receipt:
    if order.total <= 0:
        raise ava.NonRetryableError("Order total must be positive")
    ...

​
When you do not know if it happened

A payment request times out. Did the charge go through? Raise ava.OutcomeUnknownError, and choose with on_uncertain what Avalanche does next.

@ava.step(on_uncertain="hold")
def charge(order: Order, ctx: ava.RunContext) -> Receipt:
    try:
        return payments.charge(order, idempotency_key=ctx.step_key)
    except TimeoutError as error:
        raise ava.OutcomeUnknownError("No answer from the payment service") from error
on_uncertainWhat happens
"retry" (default)Try again, like any other failure
"hold"Pause the step until a person says: it happened, retry it, or fail it
"fail"Fail the step at once

ctx.step_key is the same on every attempt of a step. Pass it to services that accept an idempotency key, so a retry never does the same thing twice.

​
Rerun from a step

When a run has failed, fix the cause and rerun from the failed step. The steps before it are reused: their saved outputs are read, and they do not run again.

Rendering diagram…

In the UI, select the step and choose Rerun from here. From the command line:

ava run process_invoice --rerun-of RUN_ID --from build_entry
ChoiceRuns
This step and everything after (default)The chosen step and all steps downstream
Only this step (--only)The chosen step alone

State machines cannot be rerun.