def test_get_classpath(self): # Test the classpath in/out airflow obj1 = NamedHivePartitionSensor(partition_names=['test_partition'], task_id='meta_partition_test_1') obj1_classpath = SensorInstance.get_classpath(obj1) obj1_importpath = ( "airflow.providers.apache.hive.sensors.named_hive_partition.NamedHivePartitionSensor" ) assert obj1_classpath == obj1_importpath def test_callable(): return obj3 = PythonSensor(python_callable=test_callable, task_id='python_sensor_test') obj3_classpath = SensorInstance.get_classpath(obj3) obj3_importpath = "airflow.sensors.python.PythonSensor" assert obj3_classpath == obj3_importpath
def register_in_sensor_service(self, ti, context): """ Register ti in smart sensor service :param ti: Task instance object. :param context: TaskInstance template context from the ti. :return: boolean """ poke_context = self.get_poke_context(context) execution_context = self.get_execution_context(context) return SensorInstance.register(ti, poke_context, execution_context)
def register_in_sensor_service(self, ti, context): """ Register ti in smart sensor service :param ti: Task instance object. :param context: TaskInstance template context from the ti. :return: boolean """ docs_url = get_docs_url('concepts/smart-sensors.html#migrating-to-deferrable-operators') warnings.warn( 'Your sensor is using Smart Sensors, which are deprecated.' f' Please use Deferrable Operators instead. See {docs_url} for more info.', DeprecationWarning, ) poke_context = self.get_poke_context(context) execution_context = self.get_execution_context(context) return SensorInstance.register(ti, poke_context, execution_context)