From 7e45b6a9758c6a145b1dd3ef7e6d1026b9e33754 Mon Sep 17 00:00:00 2001 From: Luke <2609441+lc0rp@users.noreply.github.com> Date: Tue, 4 Jul 2023 17:55:00 -0400 Subject: [PATCH] Fix Config.plugins_config - call model_post_init explicitly until pydantic 2.0 (#4858) As per https://github.com/pydantic/pydantic/issues/1729#issuecomment-1300576214, the implementation of `model_post_init()` is postponed until Pydantic v2. As a result, the initialization of PluginConfig is being skipped. This fix calls `plugin.model_post_init()` explicitly. The recency of the Pydantic v2 release means that some of the other extensions we use do not support it yet. Specifically, extensions such as spacy and openapi-python-client are currently limited to Pydantic versions that are less than 2.0. There may be other extensions that have the same limitation as well. --------- Co-authored-by: Reinier van der Leer --- autogpt/config/config.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autogpt/config/config.py b/autogpt/config/config.py index a84a8595..bec3e921 100644 --- a/autogpt/config/config.py +++ b/autogpt/config/config.py @@ -83,6 +83,13 @@ class Config(SystemSettings): plugins: list[str] authorise_key: str + def __init__(self, **kwargs): + super().__init__(**kwargs) + + # Hotfix: Call model_post_init explictly as it doesn't seem to be called for pydantic<2.0.0 + # https://github.com/pydantic/pydantic/issues/1729#issuecomment-1300576214 + self.model_post_init(**kwargs) + # Executed immediately after init by Pydantic def model_post_init(self, **kwargs) -> None: if not self.plugins_config.plugins: