tatiana opened a new issue, #56657:
URL: https://github.com/apache/airflow/issues/56657
### Apache Airflow version
3.1.0
### If "Other Airflow 2/3 version" selected, which one?
_No response_
### What happened?
Airflow `dag.test()` stopped working in Airflow 3.1.
### What you think should happen instead?
The command `dag.test()` should work as in Airlfow 3.0.
### How to reproduce
Create this DAG file as `example_bug.py`:
```
from airflow import DAG
from airflow.decorators import dag, task
@dag(
dag_id="simple_dag",
)
def simple_dag():
"""A simple DAG with two Python tasks."""
@task
def start():
print("Starting the DAG...")
return "Hello from start!"
@task
def end(message: str):
print(f"Received message: {message}")
print("Ending the DAG!")
msg = start()
end(msg)
dag = simple_dag()
if __name__ == "__main__":
dag.test()
```
And run in a Python virtual environment with:
```
python example_bug.py
```
Observe stacktrace similar to:
```
Traceback (most recent call last):
File "/Users/tatiana.alchueyr/Code/astronomer-cosmos/example_bug.py", line
27, in <module>
dag.test()
File "/Users/tatiana.alchueyr/Library/Application
Support/hatch/env/virtual/astronomer-cosmos/4lAAXoPP/tests.py3.10-3.1-1.10/lib/python3.10/site-packages/airflow/sdk/definitions/dag.py",
line 1202, in test
dr: DagRun = get_or_create_dagrun(
File "/Users/tatiana.alchueyr/Library/Application
Support/hatch/env/virtual/astronomer-cosmos/4lAAXoPP/tests.py3.10-3.1-1.10/lib/python3.10/site-packages/airflow/models/dagrun.py",
line 2170, in get_or_create_dagrun
dr = dag.create_dagrun(
File "/Users/tatiana.alchueyr/Library/Application
Support/hatch/env/virtual/astronomer-cosmos/4lAAXoPP/tests.py3.10-3.1-1.10/lib/python3.10/site-packages/airflow/utils/session.py",
line 98, in wrapper
return func(*args, **kwargs)
File "/Users/tatiana.alchueyr/Library/Application
Support/hatch/env/virtual/astronomer-cosmos/4lAAXoPP/tests.py3.10-3.1-1.10/lib/python3.10/site-packages/airflow/serialization/serialized_objects.py",
line 3257, in create_dagrun
orm_dagrun = _create_orm_dagrun(
File "/Users/tatiana.alchueyr/Library/Application
Support/hatch/env/virtual/astronomer-cosmos/4lAAXoPP/tests.py3.10-3.1-1.10/lib/python3.10/site-packages/airflow/utils/session.py",
line 98, in wrapper
return func(*args, **kwargs)
File "/Users/tatiana.alchueyr/Library/Application
Support/hatch/env/virtual/astronomer-cosmos/4lAAXoPP/tests.py3.10-3.1-1.10/lib/python3.10/site-packages/airflow/serialization/serialized_objects.py",
line 2314, in _create_orm_dagrun
raise AirflowException(f"Cannot create DagRun for DAG {dag.dag_id}
because the dag is not serialized")
airflow.exceptions.AirflowException: Cannot create DagRun for DAG simple_dag
because the dag is not serialized
```
### Operating System
MacOS
### Versions of Apache Airflow Providers
_No response_
### Deployment
Other
### Deployment details
This issue happens in the local environment, not in a deployed Airflow
environment.
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] 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]