Armada Airflow Operator

This class provides integration with Airflow and Armada

armada.operators.armada module

class armada.operators.armada.ArmadaOperator(name, armada_channel_args, job_service_channel_args, armada_queue, job_request_items, lookout_url_template=None, poll_interval=30, **kwargs)

Bases: BaseOperator

Implementation of an ArmadaOperator for airflow.

Airflow operators inherit from BaseOperator.

execute(context)

Executes the Armada Operator.

Runs an Armada job and calls the job_service_client for polling.

render_template_fields(context, jinja_env=None)

Template all attributes listed in self.template_fields.

This mutates the attributes in-place and is irreversible.

template_fields(: Sequence[str _ = (‘job_request_items’,_ )

armada.operators.armada_deferrable module

class armada.operators.armada_deferrable.ArmadaDeferrableOperator(name, armada_channel_args, job_service_channel_args, armada_queue, job_request_items, lookout_url_template=None, poll_interval=30, **kwargs)

Bases: BaseOperator

Implementation of a deferrable armada operator for airflow.

Distinguished from ArmadaOperator by its ability to defer itself after submitting its job_request_items.

See https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/deferring.html for more information about deferrable airflow operators.

Airflow operators inherit from BaseOperator.

execute(context)

Executes the Armada Operator. Only meant to be called by airflow.

Submits an Armada job and defers itself to ArmadaJobCompleteTrigger to wait until the job completes.

render_template_fields(context, jinja_env=None)

Template all attributes listed in self.template_fields.

This mutates the attributes in-place and is irreversible.

resume_job_complete(context, event, job_id)

Resumes this operator after deferring itself to ArmadaJobCompleteTrigger. Only meant to be called from within Airflow.

Reports the result of the job and returns.

template_fields(: Sequence[str _ = (‘job_request_items’,_ )

class armada.operators.armada_deferrable.ArmadaJobCompleteTrigger(job_id, job_service_channel_args, armada_queue, job_set_id, airflow_task_name)

Bases: BaseTrigger

An airflow trigger that monitors the job state of an armada job.

Triggers when the job is complete.

async run()

Runs the trigger. Meant to be called by an airflow triggerer process.

serialize()

Returns the information needed to reconstruct this Trigger.

armada.operators.jobservice module

class armada.operators.jobservice.JobServiceClient(channel)

Bases: object

The JobService Client

Implementation of gRPC stubs from JobService

get_job_status(queue, job_set_id, job_id)

Get job status of a given job in a queue and job_set_id.

Uses the GetJobStatus rpc to get a status of your job

health()

Health Check for GRPC Request

armada.operators.jobservice.get_retryable_job_service_client(target, credentials=None, compression=None)

Get a JobServiceClient that has retry configured

armada.operators.jobservice_asyncio module

class armada.operators.jobservice_asyncio.JobServiceAsyncIOClient(channel)

Bases: object

The JobService AsyncIO Client

AsyncIO implementation of gRPC stubs from JobService

async get_job_status(queue, job_set_id, job_id)

Get job status of a given job in a queue and job_set_id.

Uses the GetJobStatus rpc to get a status of your job

async health()

Health Check for GRPC Request

armada.operators.jobservice_asyncio.get_retryable_job_service_asyncio_client(target, credentials, compression)

Get a JobServiceAsyncIOClient that has retry configured

armada.operators.utils module

class armada.operators.utils.JobState(value)

Bases: Enum

An enumeration.

CANCELLED(_ = _ )

CONNECTION_ERR(_ = _ )

DUPLICATE_FOUND(_ = _ )

FAILED(_ = _ )

JOB_ID_NOT_FOUND(_ = _ )

RUNNING(_ = _ )

SUBMITTED(_ = _ )

SUCCEEDED(_ = _ )

armada.operators.utils.airflow_error(job_state, name, job_id)

Throw an error on a terminal event if job errored out

AirflowFailException tells Airflow Schedule to not reschedule the task

armada.operators.utils.annotate_job_request_items(context, job_request_items)

Annotates the inbound job request items with Airflow context elements

armada.operators.utils.default_job_status_callable(armada_queue, job_set_id, job_id, job_service_client)

armada.operators.utils.get_annotation_key_prefix()

Provides the annotation key prefix, which can be specified in env var ANNOTATION_KEY_PREFIX. A default is provided if the env var is not defined

armada.operators.utils.job_state_from_pb(state)

armada.operators.utils.search_for_job_complete(armada_queue, job_set_id, airflow_task_name, job_id, poll_interval=30, job_service_client=None, job_status_callable=, time_out_for_failure=7200)

Poll JobService cache until you get a terminated event.

A terminated event is SUCCEEDED, FAILED or CANCELLED

async armada.operators.utils.search_for_job_complete_async(armada_queue, job_set_id, airflow_task_name, job_id, job_service_client, log, time_out_for_failure=7200)

Poll JobService cache asyncronously until you get a terminated event.

A terminated event is SUCCEEDED, FAILED or CANCELLED