From da68847f7aad849b623ece92faa122d182b06799 Mon Sep 17 00:00:00 2001 From: Paul Natsuo Kishimoto Date: Wed, 3 Apr 2024 12:41:06 +0200 Subject: [PATCH] Avoid deprecated genno.config.STORE --- message_ix_models/report/__init__.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/message_ix_models/report/__init__.py b/message_ix_models/report/__init__.py index f50d2cc46f..687b7a8eb4 100644 --- a/message_ix_models/report/__init__.py +++ b/message_ix_models/report/__init__.py @@ -30,20 +30,22 @@ log = logging.getLogger(__name__) -# Add to the configuration keys stored by Reporter.configure(). -genno.config.STORE.add("output_path") -genno.config.STORE.add("output_dir") +# Ignore a section in global.yaml used to define YAML anchors +try: + # genno ≥ 1.25 + genno.config.handles("_iamc formats", False, False)(genno.config.store) +except AttributeError: + # genno < 1.25 + # TODO Remove once the minimum supported version in message-ix-models is ≥ 1.25 + @genno.config.handles("_iamc formats") + def _(c: Reporter, info): + pass + #: List of callbacks for preparing the Reporter. CALLBACKS: List[Callable] = [] -# Ignore a section in global.yaml used to define YAML anchors -@genno.config.handles("_iamc formats") -def _(c: Reporter, info): - pass - - @genno.config.handles("iamc") def iamc(c: Reporter, info): """Handle one entry from the ``iamc:`` config section.