proofrock opened a new issue, #32332:
URL: https://github.com/apache/airflow/issues/32332

   ### Apache Airflow version
   
   2.6.2
   
   ### What happened
   
   I install Airflow with:
   
   ```
   pip install apache-airflow['postgresql']
   pip install psycopg2-binary
   # airflow.cfg: executor = LocalExecutor
   # airflow.cfg: sql_alchemy_conn = 
postgresql+psycopg2://airflow:airflow@localhost/airflow
   airflow db init
   ```
   
   Last week everything was fine. Today, the last command fails with:
   
   ```
   DB: postgresql+psycopg2://airflow:***@localhost/airflow
   
/home/adminuser/pyairflow/lib/python3.9/site-packages/pydantic/_internal/_config.py:257
 UserWarning: Valid config keys have changed in V2:
   * 'orm_mode' has been renamed to 'from_attributes'
   Traceback (most recent call last):
     File "/home/adminuser/pyairflow/bin/airflow", line 8, in <module>
       sys.exit(main())
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/__main__.py", 
line 48, in main
       args.func(args)
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/cli/cli_config.py",
 line 52, in command
       return func(*args, **kwargs)
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/cli/commands/db_command.py",
 line 37, in initdb
       db.initdb()
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/utils/session.py",
 line 76, in wrapper
       return func(*args, session=session, **kwargs)
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/utils/db.py", 
line 711, in initdb
       import_all_models()
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/models/__init__.py",
 line 60, in import_all_models
       __getattr__(name)
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/models/__init__.py",
 line 78, in __getattr__
       val = import_string(f"{path}.{name}")
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/utils/module_loading.py",
 line 36, in import_string
       module = import_module(module_path)
     File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
       return _bootstrap._gcd_import(name[level:], package, level)
     File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
     File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
     File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
     File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
     File "<frozen importlib._bootstrap_external>", line 790, in exec_module
     File "<frozen importlib._bootstrap>", line 228, in 
_call_with_frames_removed
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/models/skipmixin.py",
 line 25, in <module>
       from airflow.serialization.pydantic.dag_run import DagRunPydantic
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/serialization/pydantic/dag_run.py",
 line 24, in <module>
       from airflow.serialization.pydantic.dataset import DatasetEventPydantic
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/airflow/serialization/pydantic/dataset.py",
 line 40, in <module>
       class TaskOutletDatasetReferencePydantic(BaseModelPydantic):
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py",
 line 95, in __new__
       private_attributes = inspect_namespace(
     File 
"/home/adminuser/pyairflow/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py",
 line 328, in inspect_namespace
       raise PydanticUserError(
   pydantic.errors.PydanticUserError: A non-annotated attribute was detected: 
`dag_id = <class 'str'>`. All model fields require a type annotation; if 
`dag_id` is not meant to be a field, you may be able to resolve this error by 
annotating it as a `ClassVar` or updating `model_config['ignored_types']`.
   
   For further information visit 
https://errors.pydantic.dev/2.0/u/model-field-missing-annotation
   ```
   
   
   ### What you think should happen instead
   
   The db init used to complete without any issue, on a clean Debian VM just 
like the one I'm testing on.
   
   ### How to reproduce
   
   In a fresh Azure VM with Debian 11 I use this script:
   
   ```
   sudo -u postgres psql -c "CREATE USER airflow PASSWORD 'airflow';"
   sudo -u postgres psql -c "CREATE DATABASE airflow;"
   sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA 
public TO airflow;"
   
   python3 -m venv ~/pyairflow
   echo 'alias afpip="~/pyairflow/bin/pip3"' >> ~/.bash_profile
   echo 'alias afpython="~/pyairflow/bin/python3"' >> ~/.bash_profile
   source ~/.bash_profile
   afpip install apache-airflow['postgresql']
   afpip install psycopg2-binary
   
   airflow > /dev/null 2>&1
   mv ~/airflow/airflow.cfg ~/airflow/airflow.cfg.orig
   cat ~/airflow/airflow.cfg.orig | sed -e 's/^executor =.*$/executor = 
LocalExecutor/g' | sed -e 's/^sql_alchemy_conn =.*$/sql_alchemy_conn = 
postgresql+psycopg2:\/\/airflow:airflow@localhost\/airflow/g' > 
~/airflow/airflow.cfg
   
   airflow db init
   ```
   
   ### Operating System
   
   Linux Debian 11, an Azure VM
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-common-sql==1.5.2
   apache-airflow-providers-ftp==3.4.2
   apache-airflow-providers-http==4.4.2
   apache-airflow-providers-imap==3.2.2
   apache-airflow-providers-sqlite==3.4.2
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   As above
   
   ### Anything else
   
   Same problem should be reported 
[here](https://www.reddit.com/r/apache_airflow/comments/14oji77/airflow_262_and_pydantic_warningserrors/).
   
   I am not an expert in python :-(
   
   ### 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]

Reply via email to