class_docstr: Wraps the Apache Livy batch REST API, allowing to submit a Spark application to the underlying cluster.
  
  :param file: path of the file containing the application to execute (required). (templated)
  :param class_name: name of the application Java/Spark main class. (templated)
  :param args: application command line arguments. (templated)
  :param jars: jars to be used in this sessions. (templated)
  :param py_files: python files to be used in this session. (templated)
  :param files: files to be used in this session. (templated)
  :param driver_memory: amount of memory to use for the driver process. (templated)
  :param driver_cores: number of cores to use for the driver process. (templated)
  :param executor_memory: amount of memory to use per executor process. (templated)
  :param executor_cores: number of cores to use for each executor. (templated)
  :param num_executors: number of executors to launch for this session. (templated)
  :param archives: archives to be used in this session. (templated)
  :param queue: name of the YARN queue to which the application is submitted. (templated)
  :param name: name of this session. (templated)
  :param conf: Spark configuration properties. (templated)
  :param proxy_user: user to impersonate when running the job. (templated)
  :param livy_conn_id: reference to a pre-defined Livy Connection.
  :param livy_conn_auth_type: The auth type for the Livy Connection.
  :param polling_interval: time in seconds between polling for job completion. Don't poll for values >=0
  :param extra_options: A dictionary of options, where key is string and value
      depends on the option that's being modified.
  :param extra_headers: A dictionary of headers passed to the HTTP request to livy.
  :param retry_args: Arguments which define the retry behaviour.
  :param deferrable: Run operator in the deferrable mode
          See Tenacity documentation at https://github.com/jd/tenacity
class_docstr_tok: ["Wraps","the","Apache","Livy","batch","REST","API",",","allowing","to","submit","a","Spark","application","to","the","underlying","cluster",".",":","param","file",":","path","of","the","file","containing","the","application","to","execute","(","required",")",".","(","templated",")",":","param","class_name",":","name","of","the","application","Java\/Spark","main","class",".","(","templated",")",":","param","args",":","application","command","line","arguments",".","(","templated",")",":","param","jars",":","jars","to","be","used","in","this","sessions",".","(","templated",")",":","param","py_files",":","python","files","to","be","used","in","this","session",".","(","templated",")",":","param","files",":","files","to","be","used","in","this","session",".","(","templated",")",":","param","driver_memory",":","amount","of","memory","to","use","for","the","driver","process",".","(","templated",")",":","param","driver_cores",":","number","of","cores","to","use","for","the","driver","process",".","(","templated",")",":","param","executor_memory",":","amount","of","memory","to","use","per","executor","process",".","(","templated",")",":","param","executor_cores",":","number","of","cores","to","use","for","each","executor",".","(","templated",")",":","param","num_executors",":","number","of","executors","to","launch","for","this","session",".","(","templated",")",":","param","archives",":","archives","to","be","used","in","this","session",".","(","templated",")",":","param","queue",":","name","of","the","YARN","queue","to","which","the","application","is","submitted",".","(","templated",")",":","param","name",":","name","of","this","session",".","(","templated",")",":","param","conf",":","Spark","configuration","properties",".","(","templated",")",":","param","proxy_user",":","user","to","impersonate","when","running","the","job",".","(","templated",")",":","param","livy_conn_id",":","reference","to","a","pre-defined","Livy","Connection",".",":","param","livy_conn_auth_type",":","The","auth","type","for","the","Livy","Connection",".",":","param","polling_interval",":","time","in","seconds","between","polling","for","job","completion",".","Do","n't","poll","for","values",">","=0",":","param","extra_options",":","A","dictionary","of","options",",","where","key","is","string","and","value","depends","on","the","option","that","'s","being","modified",".",":","param","extra_headers",":","A","dictionary","of","headers","passed","to","the","HTTP","request","to","livy",".",":","param","retry_args",":","Arguments","which","define","the","retry","behaviour",".",":","param","deferrable",":","Run","operator","in","the","deferrable","mode","See","Tenacity","documentation","at","https",":","\/\/github.com\/jd\/tenacity"]
code: def execute(self, context: Context) -> Any:
      self._batch_id = self.hook.post_batch(**self.spark_params)
      self.log.info("Generated batch-id is %s", self._batch_id)
  
      # Wait for the job to complete
      if not self.deferrable:
          if self._polling_interval > 0:
              self.poll_for_termination(self._batch_id)
          context["ti"].xcom_push(
              key="app_id",
              value=self.hook.get_batch(self._batch_id)["appId"],
          )
          return self._batch_id
  
      state = self.hook.get_batch_state(
          self._batch_id, retry_args=self.retry_args
      )
      self.log.debug(
          "Batch with id %s is in state: %s",
          self._batch_id,
          state.value,
      )
      if state not in self.hook.TERMINAL_STATES:
          self.defer(
              timeout=self.execution_timeout,
              trigger=LivyTrigger(
                  batch_id=self._batch_id,
                  spark_params=self.spark_params,
                  livy_conn_id=self._livy_conn_id,
                  polling_interval=self._polling_interval,
                  extra_options=self._extra_options,
                  extra_headers=self._extra_headers,
              ),
              method_name="execute_complete",
          )
      else:
          self.log.info(
              "Batch with id %s terminated with state: %s",
              self._batch_id,
              state.value,
          )
          self.hook.dump_batch_logs(self._batch_id)
          if state != BatchState.SUCCESS:
              raise AirflowException(
                  f"Batch {self._batch_id} did not succeed"
              )
  
          context["ti"].xcom_push(
              key="app_id",
              value=self.hook.get_batch(self._batch_id)["appId"],
          )
          return self._batch_id
  
file_path: airflow/airflow/providers/apache/livy/operators/livy.py
imports: from __future__ import annotations
  import time
  from functools import cached_property
  from typing import TYPE_CHECKING, Any, Sequence
  from deprecated.classic import deprecated
  from airflow.configuration import conf
  from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
  from airflow.models import BaseOperator
  from airflow.providers.apache.livy.hooks.livy import BatchState, LivyHook
  from airflow.providers.apache.livy.triggers.livy import LivyTrigger
label_desc: Use image node_id 4 for calling the LivyOperator obj's underlying member method code with example usage: obj.execute(context) and returns: self, self