From 335a025c030db55f563e5dd21aaa0f2a7e632018 Mon Sep 17 00:00:00 2001 From: shenchucheng Date: Fri, 15 Dec 2023 19:38:48 +0800 Subject: [PATCH] fix cContextVar OPTIONS LookupError --- metagpt/config.py | 2 ++ metagpt/const.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/metagpt/config.py b/metagpt/config.py index 19bd02c87..d7f5c1249 100644 --- a/metagpt/config.py +++ b/metagpt/config.py @@ -45,9 +45,11 @@ class Config(metaclass=Singleton): default_yaml_file = METAGPT_ROOT / "config/config.yaml" def __init__(self, yaml_file=default_yaml_file): + golbal_options = OPTIONS.get() self._init_with_config_files_and_env(yaml_file) logger.debug("Config loading done.") self._update() + golbal_options.update(OPTIONS.get()) def _update(self): # logger.info("Config loading done.") diff --git a/metagpt/const.py b/metagpt/const.py index f6f64a27d..47864d134 100644 --- a/metagpt/const.py +++ b/metagpt/const.py @@ -17,7 +17,7 @@ import metagpt -OPTIONS = contextvars.ContextVar("OPTIONS") +OPTIONS = contextvars.ContextVar("OPTIONS", default={}) def get_metagpt_package_root():