uranusjr commented on code in PR #26649:
URL: https://github.com/apache/airflow/pull/26649#discussion_r979606199


##########
docs/apache-airflow/best-practices.rst:
##########
@@ -216,6 +216,39 @@ or if you need to deserialize a json object from the 
variable :
 For security purpose, you're recommended to use the :ref:`Secrets 
Backend<secrets_backend_configuration>`
 for any variable that contains sensitive data.
 
+Timetables
+----------
+Avoid using Airflow Variables/Connections or accessing airflow database at the 
top level of your timetable code.
+Database access should be delayed until the execution time of the DAG. This 
means that you should not have variables/connections retrieval
+as argument to your timetable class initialization or have Variable/connection 
at the top level of your custom timetable module.
+
+Bad example:
+
+.. code-block: python

Review Comment:
   ```suggestion
   .. code-block:: python
   ```



##########
docs/apache-airflow/best-practices.rst:
##########
@@ -216,6 +216,39 @@ or if you need to deserialize a json object from the 
variable :
 For security purpose, you're recommended to use the :ref:`Secrets 
Backend<secrets_backend_configuration>`
 for any variable that contains sensitive data.
 
+Timetables
+----------
+Avoid using Airflow Variables/Connections or accessing airflow database at the 
top level of your timetable code.
+Database access should be delayed until the execution time of the DAG. This 
means that you should not have variables/connections retrieval
+as argument to your timetable class initialization or have Variable/connection 
at the top level of your custom timetable module.
+
+Bad example:
+
+.. code-block: python
+
+    from airflow.models.variable import Variable
+    from airflow.timetables.interval import CronDataIntervalTimetable
+
+
+    class CustomTimetable(CronDataIntervalTimetable):
+        def __init__(self, *args, something=Variable.get('something'), 
**kwargs):
+            self._something = something
+            super().__init__(*args, **kwargs)
+
+Good example:
+
+.. code-block: python

Review Comment:
   ```suggestion
   .. code-block:: python
   ```



-- 
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