Skip to content

Commit

Permalink
Rename cluster_policy to task_policy (#23468)
Browse files Browse the repository at this point in the history
* Rename cluster_policy to task_policy

* rename task_policy as example_task_policy.
  • Loading branch information
humit0 authored May 11, 2022
1 parent cd49a8b commit 422791f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tests/cluster_policies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _check_task_rules(current_task: BaseOperator):
)


def cluster_policy(task: BaseOperator):
def example_task_policy(task: BaseOperator):
"""Ensure Tasks have non-default owners."""
_check_task_rules(task)

Expand All @@ -81,11 +81,11 @@ def dag_policy(dag: DAG):
# [END example_dag_cluster_policy]


# [START example_task_cluster_policy]
class TimedOperator(BaseOperator, ABC):
timeout: timedelta


# [START example_task_cluster_policy]
def task_policy(task: TimedOperator):
if task.task_type == 'HivePartitionSensor':
task.queue = "sensor_queue"
Expand Down
6 changes: 3 additions & 3 deletions tests/models/test_dagbag.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ def test_collect_dags_from_db(self):
assert serialized_dag.dag_id == dag.dag_id
assert set(serialized_dag.task_dict) == set(dag.task_dict)

@patch("airflow.settings.task_policy", cluster_policies.cluster_policy)
@patch("airflow.settings.task_policy", cluster_policies.example_task_policy)
def test_task_cluster_policy_violation(self):
"""
test that file processing results in import error when task does not
Expand All @@ -974,7 +974,7 @@ def test_task_cluster_policy_violation(self):
}
assert expected_import_errors == dagbag.import_errors

@patch("airflow.settings.task_policy", cluster_policies.cluster_policy)
@patch("airflow.settings.task_policy", cluster_policies.example_task_policy)
def test_task_cluster_policy_nonstring_owner(self):
"""
test that file processing results in import error when task does not
Expand All @@ -994,7 +994,7 @@ def test_task_cluster_policy_nonstring_owner(self):
}
assert expected_import_errors == dagbag.import_errors

@patch("airflow.settings.task_policy", cluster_policies.cluster_policy)
@patch("airflow.settings.task_policy", cluster_policies.example_task_policy)
def test_task_cluster_policy_obeyed(self):
"""
test that dag successfully imported without import errors when tasks
Expand Down

0 comments on commit 422791f

Please sign in to comment.