NatLabRockies / NatLabRockies/GridAnalysisToolkit

Constructing any scenario handler with no data source crashes instead of returning a usable empty object

Open
#24 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

PlexosScenario() — zero arguments, no simulation_files — raises AttributeError: 'NoneType' object has no attribute 'get_metadata' instead of succeeding. Confirmed pre-existing on main, unrelated to #22/the tilde-path fix (that fix's new FileNotFoundError correctly does not fire here, since no input was given at all — this is a distinct code path).

Repro

from gat.scenariohandlers import PlexosScenario
PlexosScenario()  # AttributeError, not a usable empty scenario

Root cause

BaseScenario.__init__ (src/gat/scenariohandlers/base.py) unconditionally computes:

self._tech_map = self.generator_technology_map

with no guard for 'no parser / no data source was ever provided.' For PlexosScenario, generator_technology_map is a @property that dereferences self.parser.get_metadata(...) — and self.parser is None whenever no solution files were given (a documented, legitimate case per the constructor's simulation_files: Optional[...] signature — e.g. 'construct now, attach data later' workflows).

Scope note

This likely affects every handler (Sienna, ReEDS, EGRET), not just Plexos — each has its own generator_technology_map implementation that may or may not tolerate a missing parser. Fixing it properly means either (a) making each handler's generator_technology_map null-safe (return {} when there's no data), or (b) having BaseScenario.__init__ skip tech-map computation when no data source is present — and auditing each subclass's 'do I have data' signal, since they may differ (self.parser, self._backend, etc.). Left unscoped here deliberately — needs its own investigation across all four handlers rather than a one-line patch.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the zero-argument PlexosScenario() reproduction and read src/gat/scenariohandlers/base.py, especially BaseScenario.init. Then inspect each handler's generator_technology_map and data-source signal for Plexos, Sienna, ReEDS, and EGRET. Done means all handlers can be constructed without input and expose a usable empty scenario without dereferencing a missing parser or backend.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.