astronomer.providers.apache.livy.triggers.livy

This module contains the Apache Livy Trigger.

Module Contents

Classes

LivyTrigger

Check for the state of a previously submitted job with batch_id

class astronomer.providers.apache.livy.triggers.livy.LivyTrigger(batch_id, spark_params, livy_conn_id='livy_default', polling_interval=0, extra_options=None, extra_headers=None, livy_hook_async=None)[source]

Bases: airflow.triggers.base.BaseTrigger

Check for the state of a previously submitted job with batch_id

Parameters:
  • batch_id (Union[int, str]) – Batch job id

  • spark_params (Dict[Any, Any]) – Spark parameters; for example, spark_params = {“file”: “test/pi.py”, “class_name”: “org.apache.spark.examples.SparkPi”, “args”: [“/usr/lib/spark/bin/run-example”, “SparkPi”, “10”],”jars”: “command-runner.jar”, “driver_cores”: 1, “executor_cores”: 4,”num_executors”: 1}

  • livy_conn_id (str) – reference to a pre-defined Livy Connection.

  • polling_interval (int) – time in seconds between polling for job completion. If poll_interval=0, in that case return the batch_id and if polling_interval > 0, poll the livy job for termination in the polling interval defined.

  • extra_options (Optional[Dict[str, Any]]) – A dictionary of options, where key is string and value depends on the option that’s being modified.

  • extra_headers (Optional[Dict[str, Any]]) – A dictionary of headers passed to the HTTP request to livy.

  • livy_hook_async (Optional[astronomer.providers.apache.livy.hooks.livy.LivyHookAsync]) – LivyHookAsync object

serialize()[source]

Serializes LivyTrigger arguments and classpath.

async run()[source]

Checks if the _polling_interval > 0, in that case it pools Livy for batch termination asynchrnonously. else returns the success response

async poll_for_termination(batch_id)[source]

Pool Livy for batch termination asynchrnonously.

Parameters:

batch_id (Union[int, str]) – id of the batch session to monitor.