Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom dag_folder not settings.DAGS_FOLDER for FileLoadStat #45073

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/models/dagbag.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def collect_dags(
file_parse_end_dttm = timezone.utcnow()
stats.append(
FileLoadStat(
file=filepath.replace(settings.DAGS_FOLDER, ""),
file=filepath.replace(str(dag_folder), ""),
duration=file_parse_end_dttm - file_parse_start_dttm,
dag_num=len(found_dags),
task_num=sum(len(dag.tasks) for dag in found_dags),
Expand Down
7 changes: 7 additions & 0 deletions tests/models/test_dagbag.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,13 @@ def test_dagbag_dag_collection(self):
dagbag = DagBag(dag_folder=TEST_DAGS_FOLDER, include_examples=False)
assert dagbag.dags

def test_dagbag_collect_dags_stats_have_filepath_without_dag_folder(self):
with conf_vars({("core", "DAGS_FOLDER"): "/different/path"}):
dagbag = DagBag(dag_folder=TEST_DAGS_FOLDER, include_examples=False)

assert dagbag.dagbag_stats
assert str(TEST_DAGS_FOLDER) not in dagbag.dagbag_stats[0].file

def test_dabgag_captured_warnings(self):
dag_file = os.path.join(TEST_DAGS_FOLDER, "test_dag_warnings.py")
dagbag = DagBag(dag_folder=dag_file, include_examples=False, collect_dags=False)
Expand Down