o-nikolas commented on code in PR #27362:
URL: https://github.com/apache/airflow/pull/27362#discussion_r1011110762


##########
docs/apache-airflow/concepts/cluster-policies.rst:
##########
@@ -26,9 +26,9 @@ If you want to check or mutate DAGs or Tasks on a 
cluster-wide level, then a Clu
 
 There are three types of cluster policy:
 
-* ``dag_policy``: Takes a :class:`~airflow.models.dag.DAG` parameter called 
``dag``. Runs at load time.
-* ``task_policy``: Takes a :class:`~airflow.models.baseoperator.BaseOperator` 
parameter called ``task``. Runs at load time.
-* ``task_instance_mutation_hook``: Takes a 
:class:`~airflow.models.taskinstance.TaskInstance` parameter called 
``task_instance``. Called right before task execution.
+* ``dag_policy``: Takes a :class:`~airflow.models.dag.DAG` parameter called 
``dag``. Runs at load time of the dag from DagBag.

Review Comment:
   The rest of this doc is using the all-caps DAG nomenclature, I'd stick with 
that. Also, a link to the DagBag class might be helpful.
   ```suggestion
   * ``dag_policy``: Takes a :class:`~airflow.models.dag.DAG` parameter called 
``dag``. Runs at load time of the DAG from DagBag.
   ```



##########
docs/apache-airflow/concepts/cluster-policies.rst:
##########
@@ -26,9 +26,9 @@ If you want to check or mutate DAGs or Tasks on a 
cluster-wide level, then a Clu
 
 There are three types of cluster policy:
 
-* ``dag_policy``: Takes a :class:`~airflow.models.dag.DAG` parameter called 
``dag``. Runs at load time.
-* ``task_policy``: Takes a :class:`~airflow.models.baseoperator.BaseOperator` 
parameter called ``task``. Runs at load time.
-* ``task_instance_mutation_hook``: Takes a 
:class:`~airflow.models.taskinstance.TaskInstance` parameter called 
``task_instance``. Called right before task execution.
+* ``dag_policy``: Takes a :class:`~airflow.models.dag.DAG` parameter called 
``dag``. Runs at load time of the dag from DagBag.
+* ``task_policy``: Takes a :class:`~airflow.models.baseoperator.BaseOperator` 
parameter called ``task``. The policy gets executed when task is created during 
parsing of the task from DagBag at the load time. This means that the whole 
task definition can be altered in the task policy. It does not relate to 
specific task running in ``dag run``. The ``task_policy`` defined is applied to 
all the task_instances that will be executed in the future.
+* ``task_instance_mutation_hook``: Takes a 
:class:`~airflow.models.taskinstance.TaskInstance` parameter called 
``task_instance``. The task_instance_mutation applies not to task but to the 
``task instance`` which is the instance of task that relates to particular 
DagRun. It is executed in "worker" not in dag file processor just before the 
task_instance is executed. The policy is only applied to the currently executed 
run (i.e. instance) of that task.

Review Comment:
   ```suggestion
   * ``task_instance_mutation_hook``: Takes a 
:class:`~airflow.models.taskinstance.TaskInstance` parameter called 
``task_instance``. The ``task_instance_mutation`` applies not to a task but to 
the instance of a task that relates to a particular DagRun. It is executed in a 
"worker", not in the dag file processor, just before the task instance is 
executed. The policy is only applied to the currently executed run (i.e. 
instance) of that task.
   ```



##########
docs/apache-airflow/concepts/cluster-policies.rst:
##########
@@ -26,9 +26,9 @@ If you want to check or mutate DAGs or Tasks on a 
cluster-wide level, then a Clu
 
 There are three types of cluster policy:
 
-* ``dag_policy``: Takes a :class:`~airflow.models.dag.DAG` parameter called 
``dag``. Runs at load time.
-* ``task_policy``: Takes a :class:`~airflow.models.baseoperator.BaseOperator` 
parameter called ``task``. Runs at load time.
-* ``task_instance_mutation_hook``: Takes a 
:class:`~airflow.models.taskinstance.TaskInstance` parameter called 
``task_instance``. Called right before task execution.
+* ``dag_policy``: Takes a :class:`~airflow.models.dag.DAG` parameter called 
``dag``. Runs at load time of the dag from DagBag.
+* ``task_policy``: Takes a :class:`~airflow.models.baseoperator.BaseOperator` 
parameter called ``task``. The policy gets executed when task is created during 
parsing of the task from DagBag at the load time. This means that the whole 
task definition can be altered in the task policy. It does not relate to 
specific task running in ``dag run``. The ``task_policy`` defined is applied to 
all the task_instances that will be executed in the future.

Review Comment:
   ```suggestion
   * ``task_policy``: Takes a 
:class:`~airflow.models.baseoperator.BaseOperator` parameter called ``task``. 
The policy gets executed when the task is created during parsing of the task 
from DagBag at load time. This means that the whole task definition can be 
altered in the task policy. It does not relate to a specific task running in a 
DagRun. The ``task_policy`` defined is applied to all the task instances that 
will be executed in the future.
   ```



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