Skip to content

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

Description

@micahpw

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions