airflow.providers.apache.livy.hooks.livy
¶
This module contains the Apache Livy hook.
Module Contents¶
-
class
airflow.providers.apache.livy.hooks.livy.
BatchState
[source]¶ Bases:
enum.Enum
Batch session states
-
class
airflow.providers.apache.livy.hooks.livy.
LivyHook
(livy_conn_id: str = default_conn_name, extra_options: Optional[Dict[str, Any]] = None)[source]¶ Bases:
airflow.providers.http.hooks.http.HttpHook
,airflow.utils.log.logging_mixin.LoggingMixin
Hook for Apache Livy through the REST API.
- Parameters
livy_conn_id (str) -- reference to a pre-defined Livy Connection.
See also
For more details refer to the Apache Livy API reference: https://livy.apache.org/docs/latest/rest-api.html
-
get_conn
(self, headers: Optional[Dict[str, Any]] = None)[source]¶ Returns http session for use with requests
- Parameters
headers (dict) -- additional headers to be passed through as a dictionary
- Returns
requests session
- Return type
-
run_method
(self, endpoint: str, method: str = 'GET', data: Optional[Any] = None, headers: Optional[Dict[str, Any]] = None)[source]¶ Wrapper for HttpHook, allows to change method on the same HttpHook
- Parameters
- Returns
http response
- Return type
-
post_batch
(self, *args, **kwargs)[source]¶ Perform request to submit batch
- Returns
batch session id
- Return type
-
get_batch_state
(self, session_id: Union[int, str])[source]¶ Fetch the state of the specified batch
-
static
build_post_batch_body
(file: str, args: Optional[Sequence[Union[str, int, float]]] = None, class_name: Optional[str] = None, jars: Optional[List[str]] = None, py_files: Optional[List[str]] = None, files: Optional[List[str]] = None, archives: Optional[List[str]] = None, name: Optional[str] = None, driver_memory: Optional[str] = None, driver_cores: Optional[Union[int, str]] = None, executor_memory: Optional[str] = None, executor_cores: Optional[int] = None, num_executors: Optional[Union[int, str]] = None, queue: Optional[str] = None, proxy_user: Optional[str] = None, conf: Optional[Dict[Any, Any]] = None)[source]¶ Build the post batch request body. For more information about the format refer to .. seealso:: https://livy.apache.org/docs/latest/rest-api.html
- Parameters
file (str) -- Path of the file containing the application to execute (required).
proxy_user (str) -- User to impersonate when running the job.
class_name (str) -- Application Java/Spark main class string.
args (Sequence[Union[str, int, float]]) -- Command line arguments for the application s.
jars (Sequence[str]) -- jars to be used in this sessions.
py_files (Sequence[str]) -- Python files to be used in this session.
files (Sequence[str]) -- files to be used in this session.
driver_memory (str) -- Amount of memory to use for the driver process string.
driver_cores (Union[str, int]) -- Number of cores to use for the driver process int.
executor_memory (str) -- Amount of memory to use per executor process string.
executor_cores (Union[int, str]) -- Number of cores to use for each executor int.
num_executors (Union[str, int]) -- Number of executors to launch for this session int.
archives (Sequence[str]) -- Archives to be used in this session.
queue (str) -- The name of the YARN queue to which submitted string.
name (str) -- The name of this session string.
conf (dict) -- Spark configuration properties.
- Returns
request body
- Return type