potiuk commented on PR #29143:
URL: https://github.com/apache/airflow/pull/29143#issuecomment-1411031392

   > I suggest showing reproducible examples. The current example for the 
PythonSensor is not easily reproducible because it doesn't show imports.
   
   Yes I understand that. 
   
   What I am suggesting to also surround import with "exaampleinclude" start. 
There is no reason exampleicnlude start/end comments shoud be limited to in-dag.
   
   the new `example_python_sensors.dag` could look like this (and gradually we 
could extract other sensors in similar way to separate files):
   
   ```
   # Licensed to the Apache Software Foundation (ASF) under one
   # or more contributor license agreements.  See the NOTICE file
   # distributed with this work for additional information
   # regarding copyright ownership.  The ASF licenses this file
   # to you under the Apache License, Version 2.0 (the
   # "License"); you may not use this file except in compliance
   # with the License.  You may obtain a copy of the License at
   #
   #   http://www.apache.org/licenses/LICENSE-2.0
   #
   # Unless required by applicable law or agreed to in writing,
   # software distributed under the License is distributed on an
   # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   # KIND, either express or implied.  See the License for the
   # specific language governing permissions and limitations
   # under the License.
   
   # [START example_python_sensors]
       import datetime
       from airflow.decorators import dag, task
       from airflow.sensors.python import PythonSensor
       @dag(start_date=datetime.datetime(2023, 1, 1), schedule=None)
       def example():
           # TaskFlow sensor
           @task.sensor
           def wait_for_success_taskflow():
               return datetime.datetime.now().minute % 2 == 0
           wait_for_success_taskflow()
           # Equivalent functionality using PythonSensor class
           def wait_for_success_pythonsensor():
               return datetime.datetime.now().minute % 2 == 0
           PythonSensor(task_id="wait_for_success_pythonsensor", 
python_callable=wait_for_success_pythonsensor)
       example()
   # [END example_python_sensors]
   ```
   (whole file).
   
   The weekday
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to