Skip to content

Commit

Permalink
Update metadata.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MooooCat committed Feb 5, 2024
1 parent 7976a05 commit 4dfe87a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sdgx/data_models/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def set(self, key: str, value: Any):
raise MetadataInitError("Cannot set _extend directly")

old_value = self.get(key)
if key in self.model_fields and key not in self.tag_fields:
if key in self.model_fields and key not in self.tag_fields and key not in self.format_fields:
raise MetadataInitError(
f"Set {key} not in tag_fields, try set it directly as m.{key} = value"
)
Expand Down Expand Up @@ -208,6 +208,11 @@ def add(self, key: str, values: str | Iterable[str]):

# dict support, this prevents the value in the key-value pair from being discarded
if isinstance(values, dict):
# already in fields that contains dict
if key in list(self.format_fields):
self.get(key).update(values)

# in extend
if self._extend.get(key, None) is None:
self._extend[key] = values
else:
Expand Down

0 comments on commit 4dfe87a

Please sign in to comment.