airflow.providers.amazon.aws.triggers.batch

Module Contents

Classes

BatchOperatorTrigger

Trigger for BatchOperator.

BatchSensorTrigger

Checks for the status of a submitted job_id to AWS Batch until it reaches a failure or a success state.

class airflow.providers.amazon.aws.triggers.batch.BatchOperatorTrigger(job_id=None, max_retries=10, aws_conn_id='aws_default', region_name=None, poll_interval=30)[source]

Bases: airflow.triggers.base.BaseTrigger

Trigger for BatchOperator. The trigger will asynchronously poll the boto3 API and wait for the Batch job to be in the SUCCEEDED state.

Parameters
  • job_id (str | None) – A unique identifier for the cluster.

  • max_retries (int) – The maximum number of attempts to be made.

  • aws_conn_id (str | None) – The Airflow connection used for AWS credentials.

  • region_name (str | None) – region name to use in AWS Hook

  • poll_interval (int) – The amount of time in seconds to wait between attempts.

serialize()[source]

Serializes BatchOperatorTrigger arguments and classpath.

hook()[source]
async run()[source]

Runs the trigger in an asynchronous context.

The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.

If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).

In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.

class airflow.providers.amazon.aws.triggers.batch.BatchSensorTrigger(job_id, region_name, aws_conn_id='aws_default', poke_interval=5)[source]

Bases: airflow.triggers.base.BaseTrigger

Checks for the status of a submitted job_id to AWS Batch until it reaches a failure or a success state. BatchSensorTrigger is fired as deferred class with params to poll the job state in Triggerer.

Parameters
  • job_id (str) – the job ID, to poll for job completion or not

  • region_name (str | None) – AWS region name to use Override the region_name in connection (if provided)

  • aws_conn_id (str | None) – connection id of AWS credentials / region name. If None, credential boto3 strategy will be used

  • poke_interval (float) – polling period in seconds to check for the status of the job

serialize()[source]

Serializes BatchSensorTrigger arguments and classpath.

hook()[source]
async run()[source]

Make async connection using aiobotocore library to AWS Batch, periodically poll for the Batch job status.

The status that indicates job completion are: ‘SUCCEEDED’|’FAILED’.

Was this entry helpful?