From 46250f0ac0504f6e985a791149fe8b841e528b45 Mon Sep 17 00:00:00 2001 From: Paul Natsuo Kishimoto Date: Thu, 31 Aug 2023 16:57:08 +0200 Subject: [PATCH] Force use of "iamc:" genno config handler during migration - Remove deprecated Key.from_str_or_key(). --- message_ix_models/report/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/message_ix_models/report/__init__.py b/message_ix_models/report/__init__.py index 870069a882..c6cf4739db 100644 --- a/message_ix_models/report/__init__.py +++ b/message_ix_models/report/__init__.py @@ -70,7 +70,7 @@ def iamc(c: Reporter, info): from message_ix_models.report.util import collapse # Common - base_key = Key.from_str_or_key(info["base"]) + base_key = Key(info["base"]) # Use message_ix_models custom collapse() method info.setdefault("collapse", {}) @@ -376,6 +376,13 @@ def prepare_reporter( except ModuleNotFoundError: pass # Currently in message_data + # Force re-installation of the function iamc() in this file as the handler for + # "iamc:" sections in global.yaml. Until message_data.reporting is removed, then + # importing it will cause the iamc() function in *that* file to override the one + # registered above. + # TODO Remove, once message_data.reporting is removed. + genno.config.handles("iamc")(iamc) + # Handle `report/config` setting passed from calling code context.setdefault("report", dict()) context.report.setdefault("config", dict())