agent.process.base module

Provides the base representation of a process.

exception agent.process.base.Failed(msg, step_name=None)

Bases: RuntimeError

The process has failed and cannot recover.

This exception should be raised when all recourse to recover has been exhausted, and no further retries are possible or desired.

class agent.process.base.Process(submission_id, process_id=None)

Bases: object

class Status

Bases: enum.Enum

Supported statuses.

FAILED = 'failed'
FAILED_TO_END = 'failed_to_end'
FAILED_TO_START = 'failed_to_start'
IN_PROGRESS = 'in_progress'
PENDING = 'pending'
SUCCEEDED = 'succeeded'
TERMINATED = 'terminated'
agent
Return type

Agent

before_start(trigger, emit, *args, **kwargs)

Emit a pending status before the process starts.

fail(exception=None, message=None)

Fail and make no further attempt to recover.

Return type

None

name
on_failure(step_name, trigger, emit)

Emit a failure status when the process fails.

Return type

None

on_success(step_name, trigger, emit)

Emit a success state when a step is completed.

Return type

None

step_names
steps = []
class agent.process.base.ProcessType

Bases: type

Metaclass for Process.

The goal is to preserve the order of steps based on the order in which they are defined on a Process subclass.

Adds a property called steps to the class, which is a list of instance methods that should be called in order to carry out the process.

exception agent.process.base.Recoverable

Bases: RuntimeError

The process failed, but there is some hope of recovery if retried.

exception agent.process.base.Retry

Bases: RuntimeError

The process should be retried.

agent.process.base.is_step(func)
Return type

bool

agent.process.base.step(max_retries=3, delay=2, backoff=2, max_delay=None, jitter=0)

Mark an instance method as a step, and configure its retry characteristics.

Parameters

max_retries (int) – If provided, the maximum number of times to retry the step.

Return type

Callable