|
37 | 37 | from airflow.cli.simple_table import AirflowConsole |
38 | 38 | from airflow.cli.utils import fetch_dag_run_from_run_id_or_logical_date_string |
39 | 39 | from airflow.dag_processing.bundles.manager import DagBundlesManager |
40 | | -from airflow.dag_processing.dagbag import DagBag, sync_bag_to_db |
| 40 | +from airflow.dag_processing.dagbag import BundleDagBag, DagBag, sync_bag_to_db |
41 | 41 | from airflow.exceptions import AirflowConfigException, AirflowException |
42 | 42 | from airflow.jobs.job import Job |
43 | 43 | from airflow.models import DagModel, DagRun, TaskInstance |
@@ -378,10 +378,12 @@ def dag_list_dags(args, session: Session = NEW_SESSION) -> None: |
378 | 378 |
|
379 | 379 | for bundle in all_bundles: |
380 | 380 | if bundle.name in bundles_to_search: |
381 | | - dagbag = DagBag(bundle.path, bundle_path=bundle.path, bundle_name=bundle.name) |
382 | | - dagbag.collect_dags() |
383 | | - dags_list.extend(list(dagbag.dags.values())) |
384 | | - dagbag_import_errors += len(dagbag.import_errors) |
| 381 | + bundle_dagbag = BundleDagBag( |
| 382 | + bundle.path, bundle_path=bundle.path, bundle_name=bundle.name |
| 383 | + ) |
| 384 | + bundle_dagbag.collect_dags() |
| 385 | + dags_list.extend(list(bundle_dagbag.dags.values())) |
| 386 | + dagbag_import_errors += len(bundle_dagbag.import_errors) |
385 | 387 | else: |
386 | 388 | dagbag = DagBag() |
387 | 389 | dagbag.collect_dags() |
@@ -474,8 +476,10 @@ def dag_list_import_errors(args, session: Session = NEW_SESSION) -> None: |
474 | 476 |
|
475 | 477 | for bundle in all_bundles: |
476 | 478 | if bundle.name in bundles_to_search: |
477 | | - dagbag = DagBag(bundle.path, bundle_path=bundle.path, bundle_name=bundle.name) |
478 | | - for filename, errors in dagbag.import_errors.items(): |
| 479 | + bundle_dagbag = BundleDagBag( |
| 480 | + bundle.path, bundle_path=bundle.path, bundle_name=bundle.name |
| 481 | + ) |
| 482 | + for filename, errors in bundle_dagbag.import_errors.items(): |
479 | 483 | data.append({"bundle_name": bundle.name, "filepath": filename, "error": errors}) |
480 | 484 | else: |
481 | 485 | dagbag = DagBag() |
@@ -526,7 +530,9 @@ def dag_report(args) -> None: |
526 | 530 | if bundle.name not in bundles_to_reserialize: |
527 | 531 | continue |
528 | 532 | bundle.initialize() |
529 | | - dagbag = DagBag(bundle.path, bundle_path=bundle.path, bundle_name=bundle.name, include_examples=False) |
| 533 | + dagbag = BundleDagBag( |
| 534 | + bundle.path, bundle_path=bundle.path, bundle_name=bundle.name, include_examples=False |
| 535 | + ) |
530 | 536 | all_dagbag_stats.extend(dagbag.dagbag_stats) |
531 | 537 |
|
532 | 538 | AirflowConsole().print_as( |
@@ -690,7 +696,7 @@ def dag_reserialize(args, session: Session = NEW_SESSION) -> None: |
690 | 696 | if bundle.name not in bundles_to_reserialize: |
691 | 697 | continue |
692 | 698 | bundle.initialize() |
693 | | - dag_bag = DagBag( |
| 699 | + dag_bag = BundleDagBag( |
694 | 700 | bundle.path, bundle_path=bundle.path, bundle_name=bundle.name, include_examples=False |
695 | 701 | ) |
696 | 702 | sync_bag_to_db(dag_bag, bundle.name, bundle_version=bundle.get_current_version(), session=session) |
0 commit comments