Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

airflow get execution context dictionary kubernetes pod name

import airflow.configuration as config
from airflow.contrib.operators.kubernetes_pod_operator import KubernetesPodOperator as AirflowKubernetesPodOperator

class KubernetesPodOperator(AirflowKubernetesPodOperator):

    def execute(self, context):

        environment = config.conf.get('webserver', 'web_server_name')

        ti = context['ti']
        dag_id = ti.dag_id
        task_id = ti.task_id
        run_id = context['run_id']
        try_number = str(ti._try_number)

        labels = { 
            'ENVIRONMENT' : environment,
            'DAG_ID'      : dag_id, 
            'TASK_ID'     : task_id, 
            'RUN_ID'      : run_id,
            'TRY_NUMBER'  : try_number,
        }

        self.env_vars.update(labels)
        super().execute(context)
Comment

PREVIOUS NEXT
Code Example
Python :: is tkinter built into python 
Python :: multiplying float variables python and print 
Python :: reduce size of list 
Python :: python convert docx to pdf linux 
Python :: os cd python 
Python :: pandas concatenation (concat) using list comprehension 
Python :: How to print specific figure in python 
Python :: benifits fo nested classes in python 
Python :: Python - Common Conditional Statements 
Python :: python getting line length using list comprehension 
Python :: python Find Hash 
Python :: how to downlaod file using python 
Python :: python downsample image 
Python :: _rocketcore pypi 
Python :: looping over folder to extract zip winrar python 
Python :: in np array how to make element as 1 if it exceeds the threshold 
Python :: pie chart add outline python 
Python :: make a copy for parsing dataframe python 
Python :: python-wordpress-xmlrpc custom fields 
Python :: iterating over the two ranges simultaneously 
Python :: assert_series_equal 
Python :: try finally return precedent 
Python :: fight club is the best movie ever 
Python :: Modifying a set in Python 
Python :: change the Values to Numpy Array 
Python :: create new column with first character of string pyspark 
Python :: python list comprehension exercises 
Python :: genrate requirments.txt pytohn 
Python :: create layer file arcpy 
Python :: como colocar uma variavel no print python 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =