Implement GMPL → MUIO conversion pipeline (ClickSAND / UTOPIA to OSeMOSYS UI JSON)#108
Implement GMPL → MUIO conversion pipeline (ClickSAND / UTOPIA to OSeMOSYS UI JSON)#108parthdagia05 wants to merge 1 commit intoEAPD-DRB:mainfrom
Conversation
Implements 3-layer architecture: - GMPLParser (syntax extraction) - SliceInterpreter (wildcard expansion to tuples) - MuioTransformer (tuple → MUIO JSON schema) Includes validation scripts and UTOPIA/MUIO fixtures.
|
@parthdagia05 Incredible work on this pipeline. 3,000 lines is a massive undertaking, and breaking it down into a strict 3-layer architecture (Parser -> Interpreter -> Transformer) is exactly the right move for maintainability. Parsing GMPL wildcard slices ( From the Track 1 (OG-CLEWS integration) perspective, this is exactly the kind of robust ingestion foundation the ecosystem needs. While my focus in PR #24 is on the execution side—translating the solver outputs into macroeconomic time-series vectors and managing the stateful converging loop—we rely heavily on the initial case data being structurally perfect. Once the OG-Core integration matures, users will likely need to upload custom I will be keeping a close eye on this as it merges so we can ensure the ingestion schemas perfectly align with the convergence pipelines downstream. |
|
@NamanmeetSingh Sorry for the late reply, and thanks a lot for the detailed feedback! |
|
@SeaCelo this PR is ready for a review. |
|
Closing this to reduce noise. The scope here is broader than what fits the current narrow-fix pattern happy to break it down into smaller issue-linked PRs if any sub-pieces are still useful. |
Feature: OSeMOSYS GMPL to MUIO JSON Transformation Pipeline ⚙️
Summary
This PR implements a complete, structured pipeline for transforming standard OSeMOSYS GMPL models (e.g., ClickSAND / UTOPIA format) into MUIO-compatible JSON case structures. It automates the conversion of standard OSeMOSYS
.datfiles into the structured JSON format required by the OSeMOSYS UI and Cloud platforms.The implementation follows a modular 3-layer architecture to ensure clean separation between syntax parsing, semantic expansion, and schema transformation.
Motivation
Currently, two primary data presentation formats exist within the ecosystem:
This PR bridges the gap by introducing a Python-based transformation engine capable of parsing standard GMPL, interpreting wildcard slice semantics, and generating exact MUIO JSON schemas.
Architecture
The pipeline flows through three distinct phases:
GMPL (.dat / .txt)→ Phase 1: GMPLParser → Phase 2: SliceInterpreter → Phase 3: MuioTransformer →MUIO JSONPhase 1 — GMPLParser (Syntax Layer)
Focuses on pure structural extraction of GMPL content without applying transformation logic.
:=placement variations, comment stripping (#), andend;terminations.Phase 2 — SliceInterpreter (Semantic Layer)
Expands GMPL slice notation into normalized tuples.
[REGION,*,FUEL,MODE,*]) into normalized mapping:(region, tech, fuel, mode, year) → value.Phase 3 — MuioTransformer (Application Layer)
Transforms normalized tuples into the final MUIO JSON schema.
FUELtoCOMMODITYand injects MUIO-specific sets (STORAGEINTRADAY,UDC, etc.).TECHNOLOGY→T_0,COMMODITY→C_0).genData.jsonand creates the scenario envelope (SC_0).Validation & Testing
Comprehensive validation scripts are included to ensure transformation accuracy:
validate_parser.py|validate_interpreter.py|validate_transformer.pyTesting Fixtures:
Assertions Covered: Correct slice expansion, ID determinism, set injection, and JSON record shape completeness. All checks pass.
Impact & Compatibility
Future Extensions (Optional)
While the core engine is complete, a small wrapper can be added to:
Feedback on architecture, mapping completeness, or integration strategy is welcome.