getaaron opened a new issue, #35962: URL: https://github.com/apache/airflow/issues/35962
### Apache Airflow version 2.7.3 ### What happened The [taskflow docs](https://github.com/apache/airflow/blob/main/docs/apache-airflow/tutorial/taskflow.rst?plain=1#L176-L213) say that tasks can be reused outside of a dag like so: ```python from airflow.decorators import dag, task @task def say_hi(): print('hi') @dag() def my_dag(): say_hi() @dag() def other_dag(): say_hi() ``` When I run this test: ```python dag_bag = DagBag(dag_folder=dags_path, include_examples=False) assert dag_bag.dagbag_stats, "no dags found" for stat in dag_bag.dagbag_stats: assert stat.task_num > 0, f"no tasks found in dag file {stat.file}" ``` I get the error: ``` E AssertionError: no tasks found in dag file /[…]/example.py E assert 0 > 0 E + where 0 = FileLoadStat(file='/[…]/example.py', duration=datetime.timedelta(microseconds=30214), dag_num=0, task_num=0, dags='[]').task_num ``` Notice dag_num=0, task_num=0. ### What you think should happen instead I expect dag_num=2, and task_num= either 1 or 2 depending on how you count the reused tasks. ### How to reproduce Included above. ### Operating System Ubuntu 22.04.3 LTS ### Versions of Apache Airflow Providers n/a but ``` apache-airflow-providers-celery==3.4.1 apache-airflow-providers-cncf-kubernetes==6.1.0 apache-airflow-providers-common-sql==1.8.0 apache-airflow-providers-ftp==3.6.1 apache-airflow-providers-http==4.7.0 apache-airflow-providers-imap==3.4.0 apache-airflow-providers-oracle==3.0.0 apache-airflow-providers-pagerduty==3.4.0 apache-airflow-providers-slack==7.2.0 apache-airflow-providers-sqlite==3.5.0 ``` ### Deployment Official Apache Airflow Helm Chart ### Deployment details _No response_ ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md) -- 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]
