Skip to content

Commit

Permalink
Disable warnings from model_dump
Browse files Browse the repository at this point in the history
When using model_dump to access attributes in experimental template decorator code, a warning is being raised due to the strings we place in the Pydantic objects not matching the declared field types. Disable these warnings.

Signed-off-by: Alice Purcell <[email protected]>
  • Loading branch information
alicederyn committed Sep 27, 2024
1 parent feede18 commit 26e6f12
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hera/workflows/io/_io_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _get_as_arguments(self) -> ModelArguments:
if isinstance(self, V1BaseModel):
self_dict = self.dict()
elif _PYDANTIC_VERSION == 2 and isinstance(self, V2BaseModel):
self_dict = self.model_dump()
self_dict = self.model_dump(warnings="none")

for field, _, annotation in _construct_io_from_fields(type(self)):
# The value may be a static value (of any time) if it has a default value, so we need to serialize it
Expand Down Expand Up @@ -217,7 +217,7 @@ def _get_as_invocator_output(self) -> List[Union[Artifact, Parameter]]:
if isinstance(self, V1BaseModel):
self_dict = self.dict()
elif _PYDANTIC_VERSION == 2 and isinstance(self, V2BaseModel):
self_dict = self.model_dump()
self_dict = self.model_dump(warnings="none")

for field, _, annotation in _construct_io_from_fields(type(self)):
if field in {"exit_code", "result"}:
Expand Down

0 comments on commit 26e6f12

Please sign in to comment.