From 367103938a5e407651ff412884038c326bc7a468 Mon Sep 17 00:00:00 2001 From: Matt Seddon <37993418+mattseddon@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:39:34 +1100 Subject: [PATCH] fix type issues produced by new version of pydantic (#638) --- src/datachain/lib/dataset_info.py | 4 ++-- src/datachain/lib/webdataset_laion.py | 10 +++++----- src/datachain/model/bbox.py | 4 ++-- src/datachain/model/pose.py | 10 +++++----- src/datachain/model/segment.py | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/datachain/lib/dataset_info.py b/src/datachain/lib/dataset_info.py index ece6d742a..a8f8ef949 100644 --- a/src/datachain/lib/dataset_info.py +++ b/src/datachain/lib/dataset_info.py @@ -23,8 +23,8 @@ class DatasetInfo(DataModel): finished_at: Optional[datetime] = Field(default=None) num_objects: Optional[int] = Field(default=None) size: Optional[int] = Field(default=None) - params: dict[str, str] = Field(default=dict) - metrics: dict[str, Any] = Field(default=dict) + params: dict[str, str] = Field(default={}) + metrics: dict[str, Any] = Field(default={}) error_message: str = Field(default="") error_stack: str = Field(default="") diff --git a/src/datachain/lib/webdataset_laion.py b/src/datachain/lib/webdataset_laion.py index 70a56efb9..d3e974394 100644 --- a/src/datachain/lib/webdataset_laion.py +++ b/src/datachain/lib/webdataset_laion.py @@ -49,11 +49,11 @@ class WDSLaion(WDSBasic): class LaionMeta(BaseModel): file: File index: Optional[int] = Field(default=None) - b32_img: list[float] = Field(default=None) - b32_txt: list[float] = Field(default=None) - l14_img: list[float] = Field(default=None) - l14_txt: list[float] = Field(default=None) - dedup: list[float] = Field(default=None) + b32_img: list[float] = Field(default=[]) + b32_txt: list[float] = Field(default=[]) + l14_img: list[float] = Field(default=[]) + l14_txt: list[float] = Field(default=[]) + dedup: list[float] = Field(default=[]) def process_laion_meta(file: File) -> Iterator[LaionMeta]: diff --git a/src/datachain/model/bbox.py b/src/datachain/model/bbox.py index 7ab8679df..89fbc2617 100644 --- a/src/datachain/model/bbox.py +++ b/src/datachain/model/bbox.py @@ -17,7 +17,7 @@ class BBox(DataModel): """ title: str = Field(default="") - coords: list[int] = Field(default=None) + coords: list[int] = Field(default=[]) @staticmethod def from_list(coords: list[float], title: str = "") -> "BBox": @@ -60,7 +60,7 @@ class OBBox(DataModel): """ title: str = Field(default="") - coords: list[int] = Field(default=None) + coords: list[int] = Field(default=[]) @staticmethod def from_list(coords: list[float], title: str = "") -> "OBBox": diff --git a/src/datachain/model/pose.py b/src/datachain/model/pose.py index 685fd6e41..13f476059 100644 --- a/src/datachain/model/pose.py +++ b/src/datachain/model/pose.py @@ -15,8 +15,8 @@ class Pose(DataModel): corresponds to a specific body part. """ - x: list[int] = Field(default=None) - y: list[int] = Field(default=None) + x: list[int] = Field(default=[]) + y: list[int] = Field(default=[]) @staticmethod def from_list(points: list[list[float]]) -> "Pose": @@ -55,9 +55,9 @@ class Pose3D(DataModel): where each index corresponds to a specific body part. """ - x: list[int] = Field(default=None) - y: list[int] = Field(default=None) - visible: list[float] = Field(default=None) + x: list[int] = Field(default=[]) + y: list[int] = Field(default=[]) + visible: list[float] = Field(default=[]) @staticmethod def from_list(points: list[list[float]]) -> "Pose3D": diff --git a/src/datachain/model/segment.py b/src/datachain/model/segment.py index 8143b43db..7d58790e0 100644 --- a/src/datachain/model/segment.py +++ b/src/datachain/model/segment.py @@ -17,8 +17,8 @@ class Segment(DataModel): """ title: str = Field(default="") - x: list[int] = Field(default=None) - y: list[int] = Field(default=None) + x: list[int] = Field(default=[]) + y: list[int] = Field(default=[]) @staticmethod def from_list(points: list[list[float]], title: str = "") -> "Segment":