airflow.contrib.sensors.python_sensor

Module Contents

class airflow.contrib.sensors.python_sensor.PythonSensor(python_callable, op_args=None, op_kwargs=None, provide_context=False, templates_dict=None, *args, **kwargs)[source]

Bases: airflow.sensors.base_sensor_operator.BaseSensorOperator

Waits for a Python callable to return True.

User could put input argument in templates_dict e.g templates_dict = {'start_ds': 1970} and access the argument by calling kwargs['templates_dict']['start_ds'] in the the callable

Parameters
  • python_callable (python callable) – A reference to an object that is callable

  • op_kwargs (dict) – a dictionary of keyword arguments that will get unpacked in your function

  • op_args (list) – a list of positional arguments that will get unpacked when calling your callable

  • provide_context (bool) – if set to true, Airflow will pass a set of keyword arguments that can be used in your function. This set of kwargs correspond exactly to what you can use in your jinja templates. For this to work, you need to define **kwargs in your function header.

  • templates_dict (dict of str) – a dictionary where the values are templates that will get templated by the Airflow engine sometime between __init__ and execute takes place and are made available in your callable’s context after the template has been applied.

template_fields = ['templates_dict', 'op_args', 'op_kwargs'][source]
poke(self, context)[source]

Was this entry helpful?