Rename (confusing) dag.sub_dag to dag.partial_subset (#11542)

There was a method on the DAG class called `sub_dag()` that had nothing
to do with Sub-DAGs or the SubDagOperator - It instead created a new
"partial" dag that contained only a selected subset of tasks.

To remove this confusion when seeing `dag.sub_dag()` used in code I have
renamed this function, and included a compat shim in case anyone is
using it outside of Airflow core.
This commit is contained in:
Ash Berlin-Taylor 2020-10-15 14:04:40 +01:00 коммит произвёл GitHub
Родитель 03a632e0ad
Коммит 1ddeddc582
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -103,7 +103,7 @@ def dag_backfill(args, dag=None):
args.start_date = args.start_date or args.end_date
if args.task_regex:
dag = dag.sub_dag(
dag = dag.partial_subset(
task_regex=args.task_regex,
include_upstream=not args.ignore_dependencies)

Просмотреть файл

@ -411,7 +411,7 @@ def task_clear(args):
if args.task_regex:
for idx, dag in enumerate(dags):
dags[idx] = dag.sub_dag(
dags[idx] = dag.partial_subset(
task_regex=args.task_regex,
include_downstream=args.downstream,
include_upstream=args.upstream)

Просмотреть файл

@ -1347,8 +1347,18 @@ class DAG(BaseDag, LoggingMixin):
result._log = self._log
return result
def sub_dag(self, task_regex, include_downstream=False,
include_upstream=True):
def sub_dag(self, *args, **kwargs):
"""This method is deprecated in favor of partial_subset"""
warnings.warn(
"This method is deprecated and will be removed in a future version. Please use partial_subset",
DeprecationWarning,
stacklevel=2,
)
return self.partial_subset(*args, **kwargs)
def partial_subset(
self, task_regex, include_downstream=False, include_upstream=True
):
"""
Returns a subset of the current dag as a deep copy of the current dag
based on a regex that should match one or many tasks, and includes