Skip to content

Commit

Permalink
Remove Pydantic 1 compatibility code (#33998)
Browse files Browse the repository at this point in the history
(cherry picked from commit 601b9cd)
  • Loading branch information
uranusjr authored and ephraimbuddy committed Sep 4, 2023
1 parent 891fae5 commit 79256eb
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 10 deletions.
4 changes: 0 additions & 4 deletions airflow/serialization/pydantic/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Config:
"""Make sure it deals automatically with SQLAlchemy ORM classes."""

from_attributes = True
orm_mode = True # Pydantic 1.x compatibility.


class TaskOutletDatasetReferencePydantic(BaseModelPydantic):
Expand All @@ -48,7 +47,6 @@ class Config:
"""Make sure it deals automatically with SQLAlchemy ORM classes."""

from_attributes = True
orm_mode = True # Pydantic 1.x compatibility.


class DatasetPydantic(BaseModelPydantic):
Expand All @@ -68,7 +66,6 @@ class Config:
"""Make sure it deals automatically with SQLAlchemy ORM classes."""

from_attributes = True
orm_mode = True # Pydantic 1.x compatibility.


class DatasetEventPydantic(BaseModelPydantic):
Expand All @@ -87,4 +84,3 @@ class Config:
"""Make sure it deals automatically with SQLAlchemy ORM classes."""

from_attributes = True
orm_mode = True # Pydantic 1.x compatibility.
1 change: 0 additions & 1 deletion airflow/serialization/pydantic/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ class Config:
"""Make sure it deals automatically with SQLAlchemy ORM classes."""

from_attributes = True
orm_mode = True # Pydantic 1.x compatibility.
1 change: 0 additions & 1 deletion airflow/serialization/pydantic/taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class Config:
"""Make sure it deals automatically with SQLAlchemy ORM classes."""

from_attributes = True
orm_mode = True # Pydantic 1.x compatibility.

def xcom_pull(
self,
Expand Down
5 changes: 1 addition & 4 deletions airflow/serialization/serialized_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,7 @@ def serialize(
elif use_pydantic_models and _ENABLE_AIP_44:

def _pydantic_model_dump(model_cls: type[BaseModel], var: Any) -> dict[str, Any]:
try:
return model_cls.model_validate(var).model_dump() # type: ignore[attr-defined]
except AttributeError: # Pydantic 1.x compatibility.
return model_cls.from_orm(var).dict() # type: ignore[attr-defined]
return model_cls.model_validate(var).model_dump(mode="json")

if isinstance(var, Job):
return cls._encode(_pydantic_model_dump(JobPydantic, var), type_=DAT.BASE_JOB)
Expand Down

0 comments on commit 79256eb

Please sign in to comment.