class_docstr: Launching Cloud Dataflow jobs written in python.
  
  Note that both dataflow_default_options and options will be merged to specify pipeline
  execution parameter, and dataflow_default_options is expected to save high-level options,
  for instances, project and zone information, which apply to all dataflow operators in the DAG.
  
  This class is deprecated.
  
  Please use :class:`providers.apache.beam.operators.beam.BeamRunPythonPipelineOperator`.
  
  .. seealso::
      For more detail on job submission have a look at the reference:
      https://cloud.google.com/dataflow/pipelines/specifying-exec-params
  
  .. seealso::
      For more information on how to use this operator, take a look at the guide:
      :ref:`howto/operator:DataflowCreatePythonJobOperator`
  
  :param py_file: Reference to the python dataflow pipeline file.py, e.g.,
      /some/local/file/path/to/your/python/pipeline/file. (templated)
  :param job_name: The 'job_name' to use when executing the Dataflow job
      (templated). This ends up being set in the pipeline options, so any entry
      with key ``'jobName'`` or ``'job_name'`` in ``options`` will be overwritten.
  :param py_options: Additional python options, e.g., ["-m", "-v"].
  :param dataflow_default_options: Map of default job options.
  :param options: Map of job specific options.The key must be a dictionary.
      The value can contain different types:
  
      * If the value is None, the single option - ``--key`` (without value) will be added.
      * If the value is False, this option will be skipped
      * If the value is True, the single option - ``--key`` (without value) will be added.
      * If the value is list, the many options will be added for each key.
        If the value is ``['A', 'B']`` and the key is ``key`` then the ``--key=A --key=B`` options
        will be left
      * Other value types will be replaced with the Python textual representation.
  
      When defining labels (``labels`` option), you can also provide a dictionary.
  :param py_interpreter: Python version of the beam pipeline.
      If None, this defaults to the python3.
      To track python versions supported by beam and related
      issues check: https://issues.apache.org/jira/browse/BEAM-1251
  :param py_requirements: Additional python package(s) to install.
      If a value is passed to this parameter, a new virtual environment has been created with
      additional packages installed.
  
      You could also install the apache_beam package if it is not installed on your system or you want
      to use a different version.
  :param py_system_site_packages: Whether to include system_site_packages in your virtualenv.
      See virtualenv documentation for more information.
  
      This option is only relevant if the ``py_requirements`` parameter is not None.
  :param gcp_conn_id: The connection ID to use connecting to Google Cloud.
  :param project_id: Optional, the Google Cloud project ID in which to start a job.
      If set to None or missing, the default project_id from the Google Cloud connection is used.
  :param location: Job location.
  :param poll_sleep: The time in seconds to sleep between polling Google
      Cloud Platform for the dataflow job status while the job is in the
      JOB_STATE_RUNNING state.
  :param drain_pipeline: Optional, set to True if want to stop streaming job by draining it
      instead of canceling during killing task instance. See:
      https://cloud.google.com/dataflow/docs/guides/stopping-a-pipeline
  :param cancel_timeout: How long (in seconds) operator should wait for the pipeline to be
      successfully cancelled when task is being killed.
  :param wait_until_finished: (Optional)
      If True, wait for the end of pipeline execution before exiting.
      If False, only submits job.
      If None, default behavior.
  
      The default behavior depends on the type of pipeline:
  
      * for the streaming pipeline, wait for jobs to start,
      * for the batch pipeline, wait for the jobs to complete.
  
      .. warning::
  
          You cannot call ``PipelineResult.wait_until_finish`` method in your pipeline code for the operator
          to work properly. i. e. you must use asynchronous execution. Otherwise, your pipeline will
          always wait until finished. For more information, look at:
          `Asynchronous execution
          <https://cloud.google.com/dataflow/docs/guides/specifying-exec-params#python_10>`__
  
      The process of starting the Dataflow job in Airflow consists of two steps:
  
      * running a subprocess and reading the stderr/stderr log for the job id.
      * loop waiting for the end of the job ID from the previous step.
        This loop checks the status of the job.
  
      Step two is started just after step one has finished, so if you have wait_until_finished in your
      pipeline code, step two will not start until the process stops. When this process stops,
      steps two will run, but it will only execute one iteration as the job will be in a terminal state.
  
      If you in your pipeline do not call the wait_for_pipeline method but pass wait_until_finish=True
      to the operator, the second loop will wait for the job's terminal state.
  
      If you in your pipeline do not call the wait_for_pipeline method, and pass wait_until_finish=False
      to the operator, the second loop will check once is job not in terminal state and exit the loop.
class_docstr_tok: ["Launching","Cloud","Dataflow","jobs","written","in","python",".","Note","that","both","dataflow_default_options","and","options","will","be","merged","to","specify","pipeline","execution","parameter",",","and","dataflow_default_options","is","expected","to","save","high-level","options",",","for","instances",",","project","and","zone","information",",","which","apply","to","all","dataflow","operators","in","the","DAG",".","This","class","is","deprecated",".","Please","use",":","class",":","`","providers.apache.beam.operators.beam.BeamRunPythonPipelineOperator","`",".","..","seealso",":",":","For","more","detail","on","job","submission","have","a","look","at","the","reference",":","https",":","\/\/cloud.google.com\/dataflow\/pipelines\/specifying-exec-params","..","seealso",":",":","For","more","information","on","how","to","use","this","operator",",","take","a","look","at","the","guide",":",":","ref",":","`","howto\/operator",":","DataflowCreatePythonJobOperator","`",":","param","py_file",":","Reference","to","the","python","dataflow","pipeline","file.py",",","e.g.",",","\/some\/local\/file\/path\/to\/your\/python\/pipeline\/file",".","(","templated",")",":","param","job_name",":","The","'job_name","'","to","use","when","executing","the","Dataflow","job","(","templated",")",".","This","ends","up","being","set","in","the","pipeline","options",",","so","any","entry","with","key","``","'jobName","'","``","or","``","'job_name","'","``","in","``","options","``","will","be","overwritten",".",":","param","py_options",":","Additional","python","options",",","e.g.",",","[","``","-m","''",",","``","-v","''","]",".",":","param","dataflow_default_options",":","Map","of","default","job","options",".",":","param","options",":","Map","of","job","specific","options.The","key","must","be","a","dictionary",".","The","value","can","contain","different","types",":","*","If","the","value","is","None",",","the","single","option","-","``","--","key","``","(","without","value",")","will","be","added",".","*","If","the","value","is","False",",","this","option","will","be","skipped","*","If","the","value","is","True",",","the","single","option","-","``","--","key","``","(","without","value",")","will","be","added",".","*","If","the","value","is","list",",","the","many","options","will","be","added","for","each","key",".","If","the","value","is","``","[","'","A","'",",","'","B","'","]","``","and","the","key","is","``","key","``","then","the","``","--","key=A","--","key=B","``","options","will","be","left","*","Other","value","types","will","be","replaced","with","the","Python","textual","representation",".","When","defining","labels","(","``","labels","``","option",")",",","you","can","also","provide","a","dictionary",".",":","param","py_interpreter",":","Python","version","of","the","beam","pipeline",".","If","None",",","this","defaults","to","the","python3",".","To","track","python","versions","supported","by","beam","and","related","issues","check",":","https",":","\/\/issues.apache.org\/jira\/browse\/BEAM-1251",":","param","py_requirements",":","Additional","python","package","(","s",")","to","install",".","If","a","value","is","passed","to","this","parameter",",","a","new","virtual","environment","has","been","created","with","additional","packages","installed",".","You","could","also","install","the","apache_beam","package","if","it","is","not","installed","on","your","system","or","you","want","to","use","a","different","version",".",":","param","py_system_site_packages",":","Whether","to","include","system_site_packages","in","your","virtualenv",".","See","virtualenv","documentation","for","more","information",".","This","option","is","only","relevant","if","the","``","py_requirements","``","parameter","is","not","None",".",":","param","gcp_conn_id",":","The","connection","ID","to","use","connecting","to","Google","Cloud",".",":","param","project_id",":","Optional",",","the","Google","Cloud","project","ID","in","which","to","start","a","job",".","If","set","to","None","or","missing",",","the","default","project_id","from","the","Google","Cloud","connection","is","used",".",":","param","location",":","Job","location",".",":","param","poll_sleep",":","The","time","in","seconds","to","sleep","between","polling","Google","Cloud","Platform","for","the","dataflow","job","status","while","the","job","is","in","the","JOB_STATE_RUNNING","state",".",":","param","drain_pipeline",":","Optional",",","set","to","True","if","want","to","stop","streaming","job","by","draining","it","instead","of","canceling","during","killing","task","instance",".","See",":","https",":","\/\/cloud.google.com\/dataflow\/docs\/guides\/stopping-a-pipeline",":","param","cancel_timeout",":","How","long","(","in","seconds",")","operator","should","wait","for","the","pipeline","to","be","successfully","cancelled","when","task","is","being","killed",".",":","param","wait_until_finished",":","(","Optional",")","If","True",",","wait","for","the","end","of","pipeline","execution","before","exiting",".","If","False",",","only","submits","job",".","If","None",",","default","behavior",".","The","default","behavior","depends","on","the","type","of","pipeline",":","*","for","the","streaming","pipeline",",","wait","for","jobs","to","start",",","*","for","the","batch","pipeline",",","wait","for","the","jobs","to","complete",".","..","warning",":",":","You","can","not","call","``","PipelineResult.wait_until_finish","``","method","in","your","pipeline","code","for","the","operator","to","work","properly",".","i.","e.","you","must","use","asynchronous","execution",".","Otherwise",",","your","pipeline","will","always","wait","until","finished",".","For","more","information",",","look","at",":","`","Asynchronous","execution","<","https",":","\/\/cloud.google.com\/dataflow\/docs\/guides\/specifying-exec-params","#","python_10",">","`","__","The","process","of","starting","the","Dataflow","job","in","Airflow","consists","of","two","steps",":","*","running","a","subprocess","and","reading","the","stderr\/stderr","log","for","the","job","id",".","*","loop","waiting","for","the","end","of","the","job","ID","from","the","previous","step",".","This","loop","checks","the","status","of","the","job",".","Step","two","is","started","just","after","step","one","has","finished",",","so","if","you","have","wait_until_finished","in","your","pipeline","code",",","step","two","will","not","start","until","the","process","stops",".","When","this","process","stops",",","steps","two","will","run",",","but","it","will","only","execute","one","iteration","as","the","job","will","be","in","a","terminal","state",".","If","you","in","your","pipeline","do","not","call","the","wait_for_pipeline","method","but","pass","wait_until_finish=True","to","the","operator",",","the","second","loop","will","wait","for","the","job","'s","terminal","state",".","If","you","in","your","pipeline","do","not","call","the","wait_for_pipeline","method",",","and","pass","wait_until_finish=False","to","the","operator",",","the","second","loop","will","check","once","is","job","not","in","terminal","state","and","exit","the","loop","."]
docstr: Execute the python dataflow job.
docstr_tok: ["Execute","the","python","dataflow","job","."]
code: def execute(self, context: Context):
      """Execute the python dataflow job."""
      self.beam_hook = BeamHook(runner=BeamRunnerType.DataflowRunner)
      self.dataflow_hook = DataflowHook(
          gcp_conn_id=self.gcp_conn_id,
          poll_sleep=self.poll_sleep,
          impersonation_chain=None,
          drain_pipeline=self.drain_pipeline,
          cancel_timeout=self.cancel_timeout,
          wait_until_finished=self.wait_until_finished,
      )
  
      job_name = self.dataflow_hook.build_dataflow_job_name(
          job_name=self.job_name
      )
      pipeline_options = self.dataflow_default_options.copy()
      pipeline_options["job_name"] = job_name
      pipeline_options["project"] = (
          self.project_id or self.dataflow_hook.project_id
      )
      pipeline_options["region"] = self.location
      pipeline_options.update(self.options)
  
      # Convert argument names from lowerCamelCase to snake case.
      def camel_to_snake(name):
          return re.sub(
              "[A-Z]", lambda x: "_" + x.group(0).lower(), name
          )
  
      formatted_pipeline_options = {
          camel_to_snake(key): pipeline_options[key]
          for key in pipeline_options
      }
  
      def set_current_job_id(job_id):
          self.job_id = job_id
  
      process_line_callback = (
          process_line_and_extract_dataflow_job_id_callback(
              on_new_job_id_callback=set_current_job_id
          )
      )
  
      with ExitStack() as exit_stack:
          if self.py_file.lower().startswith("gs://"):
              gcs_hook = GCSHook(self.gcp_conn_id)
              tmp_gcs_file = exit_stack.enter_context(
                  gcs_hook.provide_file(object_url=self.py_file)
              )
              self.py_file = tmp_gcs_file.name
  
          with self.dataflow_hook.provide_authorized_gcloud():
              self.beam_hook.start_python_pipeline(
                  variables=formatted_pipeline_options,
                  py_file=self.py_file,
                  py_options=self.py_options,
                  py_interpreter=self.py_interpreter,
                  py_requirements=self.py_requirements,
                  py_system_site_packages=self.py_system_site_packages,
                  process_line_callback=process_line_callback,
              )
  
          self.dataflow_hook.wait_for_done(
              job_name=job_name,
              location=self.location,
              job_id=self.job_id,
              multiple_jobs=False,
          )
  
      return {"job_id": self.job_id}
  
imports: from __future__ import annotations
  import copy
  import re
  import uuid
  import warnings
  from contextlib import ExitStack
  from enum import Enum
  from functools import cached_property
  from typing import TYPE_CHECKING, Any, Sequence
  from airflow.configuration import conf
  from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
  from airflow.providers.apache.beam.hooks.beam import BeamHook, BeamRunnerType
  from airflow.providers.google.cloud.hooks.dataflow import DEFAULT_DATAFLOW_LOCATION, DataflowHook, process_line_and_extract_dataflow_job_id_callback
  from airflow.providers.google.cloud.hooks.gcs import GCSHook
  from airflow.providers.google.cloud.links.dataflow import DataflowJobLink
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
  from airflow.providers.google.cloud.triggers.dataflow import TemplateJobStartTrigger
  from airflow.version import version
label_desc: Use image node_id 2 for calling the DataflowCreatePythonJobOperator obj's underlying member method code with example usage: obj.execute(context) and returns: dict, re