diff --git a/geoapps_utils/base.py b/geoapps_utils/base.py index 68fa045f..4c6a741e 100644 --- a/geoapps_utils/base.py +++ b/geoapps_utils/base.py @@ -13,6 +13,7 @@ import logging import sys import tempfile +import warnings from abc import ABC, abstractmethod from copy import copy from pathlib import Path @@ -208,25 +209,29 @@ def collect_input_from_dict( """ update = data.copy() nested_fields: list[str] = [] - for field, info in model.model_fields.items(): - # Already a BaseModel, no need to nest - if isinstance(update.get(field, None), BaseModel): - continue - - if ( - isinstance(info.annotation, type) - and not isinstance(info.annotation, GenericAlias) - and issubclass(info.annotation, BaseModel) - ): - # Nest and deal with aliases - update = Options.collect_input_from_dict(info.annotation, update) - nested = info.annotation.model_construct(**update).model_dump( - exclude_unset=True - ) - - if any(nested): - update[field] = nested - nested_fields += nested + + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=UserWarning, module="pydantic") + + for field, info in model.model_fields.items(): + # Already a BaseModel, no need to nest + if isinstance(update.get(field, None), BaseModel): + continue + + if ( + isinstance(info.annotation, type) + and not isinstance(info.annotation, GenericAlias) + and issubclass(info.annotation, BaseModel) + ): + # Nest and deal with aliases + update = Options.collect_input_from_dict(info.annotation, update) + nested = info.annotation.model_construct(**update).model_dump( + exclude_unset=True + ) + + if any(nested): + update[field] = nested + nested_fields += nested for field in nested_fields: if field in update: