You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that some of our dependencies have added the <2 pin as well and removing it from our direct dependencies is no longer sufficient to install Pydantic 2 in CI. Adding >=2 results in a resolution conflict. Will need to find another way.
It seems that some of our dependencies have added the <2 pin as well and removing it from our direct dependencies is no longer sufficient to install Pydantic 2 in CI. Adding >=2 results in a resolution conflict. Will need to find another way.
Also it is likely some other incompatibilities (aka "teething problems" with Pydantic 2) might simply get fixed - Pydantic 2.0.1 has been released yesterday with ~40 bugs fixed. so waiting is probably a very good strategy in general.
Andthat's a good news actually that other deps limited it for now, because it seems that likely even no-constraints installation will be fine for 2.6.0 - 2.6.2.
Example error from migration Job in K8S tests (when you look at summary and download the failed log artifacts you can brows them and in the migration job you will find this):
2023-07-05T09:31:04.936389433Z stderr F /home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_config.py:257 UserWarning: Valid config keys have changed in V2:
2023-07-05T09:31:04.936397782Z stderr F * 'orm_mode' has been renamed to 'from_attributes'
2023-07-05T09:31:05.062051199Z stdout F [2023-07-05T09:31:05.061+0000] {cli_action_loggers.py:83} DEBUG - Calling callbacks: []
2023-07-05T09:31:05.062066769Z stderr F Traceback (most recent call last):
2023-07-05T09:31:05.062072845Z stderr F File "/home/airflow/.local/bin/airflow", line 8, in <module>
2023-07-05T09:31:05.062162218Z stderr F sys.exit(main())
2023-07-05T09:31:05.062165605Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/__main__.py", line 48, in main
2023-07-05T09:31:05.062213762Z stderr F args.func(args)
2023-07-05T09:31:05.062216746Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/cli_config.py", line 52, in command
2023-07-05T09:31:05.062285355Z stderr F return func(*args, **kwargs)
2023-07-05T09:31:05.062289578Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/cli.py", line 112, in wrapper
2023-07-05T09:31:05.062340064Z stderr F return f(*args, **kwargs)
2023-07-05T09:31:05.062346687Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/commands/db_command.py", line 88, in upgradedb
2023-07-05T09:31:05.062417707Z stderr F db.upgradedb(
2023-07-05T09:31:05.062421133Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/session.py", line 76, in wrapper
2023-07-05T09:31:05.062488343Z stderr F return func(*args, session=session, **kwargs)
2023-07-05T09:31:05.062495223Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/db.py", line 1569, in upgradedb
2023-07-05T09:31:05.062880304Z stderr F import_all_models()
2023-07-05T09:31:05.062884917Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/__init__.py", line 60, in import_all_models
2023-07-05T09:31:05.062926532Z stderr F __getattr__(name)
2023-07-05T09:31:05.062929423Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/__init__.py", line 78, in __getattr__
2023-07-05T09:31:05.062997617Z stderr F val = import_string(f"{path}.{name}")
2023-07-05T09:31:05.063001825Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/module_loading.py", line 36, in import_string
2023-07-05T09:31:05.063055324Z stderr F module = import_module(module_path)
2023-07-05T09:31:05.063059364Z stderr F File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
2023-07-05T09:31:05.063134198Z stderr F return _bootstrap._gcd_import(name[level:], package, level)
2023-07-05T09:31:05.063142828Z stderr F File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2023-07-05T09:31:05.06323632Z stderr F File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2023-07-05T09:31:05.06328635Z stderr F File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2023-07-05T09:31:05.063339005Z stderr F File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2023-07-05T09:31:05.063399209Z stderr F File "<frozen importlib._bootstrap_external>", line 843, in exec_module
2023-07-05T09:31:05.063487119Z stderr F File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2023-07-05T09:31:05.06353937Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/skipmixin.py", line 25, in <module>
2023-07-05T09:31:05.063609088Z stderr F from airflow.serialization.pydantic.dag_run import DagRunPydantic
2023-07-05T09:31:05.063612022Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/airflow/serialization/pydantic/dag_run.py", line 27, in <module>
2023-07-05T09:31:05.063656021Z stderr F class DagRunPydantic(BaseModelPydantic):
2023-07-05T09:31:05.063657927Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 172, in __new__
2023-07-05T09:31:05.06374619Z stderr F complete_model_class(
2023-07-05T09:31:05.063749628Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 420, in complete_model_class
2023-07-05T09:31:05.063884186Z stderr F schema = cls.__get_pydantic_core_schema__(cls, handler)
2023-07-05T09:31:05.063887206Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/main.py", line 533, in __get_pydantic_core_schema__
2023-07-05T09:31:05.064028145Z stderr F return __handler(__source)
2023-07-05T09:31:05.064040108Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_schema_generation_shared.py", line 82, in __call__
2023-07-05T09:31:05.06409642Z stderr F schema = self._handler(__source_type)
2023-07-05T09:31:05.064099722Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 264, in generate_schema
2023-07-05T09:31:05.064204129Z stderr F return self._generate_schema_for_type(
2023-07-05T09:31:05.064206503Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 285, in _generate_schema_for_type
2023-07-05T09:31:05.064311296Z stderr F schema = self._generate_schema(obj)
2023-07-05T09:31:05.064316069Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 475, in _generate_schema
2023-07-05T09:31:05.064453975Z stderr F return self._model_schema(obj)
2023-07-05T09:31:05.064457652Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 351, in _model_schema
2023-07-05T09:31:05.064563542Z stderr F {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
2023-07-05T09:31:05.064566708Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 351, in <dictcomp>
2023-07-05T09:31:05.064668327Z stderr F {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
2023-07-05T09:31:05.06467106Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 616, in _generate_md_field_schema
2023-07-05T09:31:05.064819744Z stderr F common_field = self._common_field_schema(name, field_info, decorators)
2023-07-05T09:31:05.064822125Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 658, in _common_field_schema
2023-07-05T09:31:05.064989175Z stderr F schema = self._apply_annotations(
2023-07-05T09:31:05.064997161Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 1316, in _apply_annotations
2023-07-05T09:31:05.065285199Z stderr F schema = get_inner_schema(source_type)
2023-07-05T09:31:05.065288123Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_schema_generation_shared.py", line 82, in __call__
2023-07-05T09:31:05.065336079Z stderr F schema = self._handler(__source_type)
2023-07-05T09:31:05.065338463Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 1277, in inner_handler
2023-07-05T09:31:05.065650573Z stderr F schema = self._generate_schema(obj)
2023-07-05T09:31:05.065655344Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 537, in _generate_schema
2023-07-05T09:31:05.065809391Z stderr F return self._arbitrary_type_schema(obj, obj)
2023-07-05T09:31:05.065859693Z stderr F File "/home/airflow/.local/lib/python3.8/site-packages/pydantic/_internal/_generate_schema.py", line 580, in _arbitrary_type_schema
2023-07-05T09:31:05.066024014Z stderr F raise PydanticSchemaGenerationError(
2023-07-05T09:31:05.066029887Z stderr F pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'pendulum.datetime.DateTime'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.
2023-07-05T09:31:05.066033448Z stderr F
BTW. This is one of the great examples where having few "integration" tests where we run end-to-end tests in our CI actually makes sense - because no unit tests were able to catch this one.
Would upgrading to pydantic 2 break core Airflow functionality? I have sometimes updated other packages (pandas, pyarrow) beyond the constraints Airflow sets. The latest release of polars depends on pydantic 2.0 but I can't break Airflow over my eagerness to update.
Would upgrading to pydantic 2 break core Airflow functionality? I have sometimes updated other packages (pandas, pyarrow) beyond the constraints Airflow sets. The latest release of polars depends on pydantic 2.0 but I can't break Airflow over my eagerness to update.
As @uranusjr wrote - no, it should not break anything once you use 2.7.1. In 2.7.0 you will have warnings about some deprecated Pydantic features, but it should be harmless otherwise. In 2.7.1 you should get the warnings suppressed. 2.8.0 will likely require you to use Pydantic 2. We are not yet "actively" using Pydantic, it's mostly in-development support. It also allows you to serialize Pydantic models (if for example you pass them as XComs) but I think upcoming 2.7.1 should generally make them work for both Pydantic 1 and 2.
If you are not passing Pydantic models this way - you should be generally unaffected.
Activity
Limit Pydantic to < 2.0.0 until we solve 2.0.0 incompatibilities
Limit Pydantic to < 2.0.0 until we solve 2.0.0 incompatibilities (#32312
Limit Pydantic to < 2.0.0 until we solve 2.0.0 incompatibilities (#32312
uranusjr commentedon Jul 3, 2023
Do we have a way to identify incompatibilities so they can be fixed? Maybe a CI job for example?
potiuk commentedon Jul 3, 2023
It's enough to remove the limit and set
full-tests-neededfor the PR and fix the problems. No need for special job.potiuk commentedon Jul 3, 2023
Feel free to pick it up if you want :)
uranusjr commentedon Jul 3, 2023
Ah right, will do that
uranusjr commentedon Jul 5, 2023
It seems that some of our dependencies have added the
<2pin as well and removing it from our direct dependencies is no longer sufficient to install Pydantic 2 in CI. Adding>=2results in a resolution conflict. Will need to find another way.potiuk commentedon Jul 5, 2023
Likely waiting for them to support Pydantic 2 :)
potiuk commentedon Jul 5, 2023
Also it is likely some other incompatibilities (aka "teething problems" with Pydantic 2) might simply get fixed - Pydantic 2.0.1 has been released yesterday with ~40 bugs fixed. so waiting is probably a very good strategy in general.
Andthat's a good news actually that other deps limited it for now, because it seems that likely even no-constraints installation will be fine for 2.6.0 - 2.6.2.
Limit Pydantic < 2.0.0 until Airflow resolves incompatibilities
uranusjr commentedon Jul 5, 2023
Hey the CI is actually passing with Pydantic 2.0.1. Maybe this is it and there’s nothing to fix at our part.
potiuk commentedon Jul 5, 2023
Nope. Not passing. There are K8S and Docker compose failing (and errors in it suggest Pydantic being the reason).
potiuk commentedon Jul 5, 2023
I might take a look at that later - but I think there are a few more changes to be added.
potiuk commentedon Jul 5, 2023
Example error from migration Job in K8S tests (when you look at summary and download the failed log artifacts you can brows them and in the migration job you will find this):
potiuk commentedon Jul 5, 2023
This is what I saw before as well
potiuk commentedon Jul 5, 2023
BTW. This is one of the great examples where having few "integration" tests where we run end-to-end tests in our CI actually makes sense - because no unit tests were able to catch this one.
Limit Pydantic < 2.0.0 until Airflow resolves incompatibilities
Limit Pydantic < 2.0.0 until Airflow resolves incompatibilities
Limit Pydantic < 2.0.0 until Airflow resolves incompatibilities (#52)
uranusjr commentedon Jul 6, 2023
Hey I think I got things working
Limit Pydantic < 2.0.0 until Airflow resolves incompatibilities (#1981)
Limit Pydantic < 2.0.0 until Airflow resolves incompatibilities (#1981)
ldacey commentedon Sep 6, 2023
Would upgrading to pydantic 2 break core Airflow functionality? I have sometimes updated other packages (pandas, pyarrow) beyond the constraints Airflow sets. The latest release of polars depends on pydantic 2.0 but I can't break Airflow over my eagerness to update.
uranusjr commentedon Sep 6, 2023
I think 2.7 still has some incompatibilities in serialisation, but it should work adequately.
potiuk commentedon Sep 6, 2023
As @uranusjr wrote - no, it should not break anything once you use 2.7.1. In 2.7.0 you will have warnings about some deprecated Pydantic features, but it should be harmless otherwise. In 2.7.1 you should get the warnings suppressed. 2.8.0 will likely require you to use Pydantic 2. We are not yet "actively" using Pydantic, it's mostly in-development support. It also allows you to serialize Pydantic models (if for example you pass them as XComs) but I think upcoming 2.7.1 should generally make them work for both Pydantic 1 and 2.
If you are not passing Pydantic models this way - you should be generally unaffected.