Skip to content

Commit

Permalink
fix metadata test error of value fields
Browse files Browse the repository at this point in the history
The management of metadata fields may be flawed, necessitating an examination of the eq method or the manner in which fields are retrieved. We will open a separate pull request to address this issue.
  • Loading branch information
MooooCat committed Jul 15, 2024
1 parent 01f156e commit 085dfb2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sdgx/data_models/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Metadata(BaseModel):
"""

@field_validator("column_list")
# @classmethod
def check_column_list(cls, v) -> Any:
# check if v has duplicate element
if len(v) == len(set(v)):
Expand All @@ -70,6 +71,7 @@ def check_column_list(cls, v) -> Any:
discrete_columns: Set[str] = set()
datetime_columns: Set[str] = set()
datetime_format: Dict = defaultdict(str)
const_values: Dict = defaultdict(str)

# version info
version: str = "1.0"
Expand Down Expand Up @@ -206,6 +208,7 @@ def set(self, key: str, value: Any):
key in self.model_fields
and key not in self.tag_fields
and key not in self.format_fields
and key not in self.value_fields
):
raise MetadataInitError(
f"Set {key} not in tag_fields, try set it directly as m.{key} = value"
Expand Down Expand Up @@ -252,6 +255,9 @@ def add(self, key: str, values: str | Iterable[str]):
# already in fields that contains dict
if key in list(self.format_fields):
self.get(key).update(values)

if key in list(self.value_fields):
self.get(key).update(values)

# in extend
if self._extend.get(key, None) is None:
Expand Down

0 comments on commit 085dfb2

Please sign in to comment.