Skip to content

[Bug]: Incomplete emissions limits handler crashes #331

Description

@DavidLikesLearning

Bug Description

Some datasets, like the 26 zone CONUS at (https://datadocs.openenergyoutlook.org/en/latest/datasets.html) supporting DOI 10.1088/1748-9326/ae6c3d and other publications, involve emissions limits applied to fuel imports from other zones. When taking a subset of the a region with an emission limit, but not the import fuel, we have an inequality constraint with an empty left hand side. The handling for the warning in limits.py:944 crashes with a TypeError from expecting a 2-tuple where the logging module provides a 1-tupe with an 2-tuple inside.

Steps to Reproduce

  1. Create a database with emission limits formatted like those of the CONUS 26z database, that is, acting on fuel imports.
  2. Remove a relevant fuel import.
  3. Run temoa

Code or Configuration Example

see bash file

repro.sh

Error Message / Stack Trace

--- Logging error ---
Traceback (most recent call last):
File ".../logging/init.py", line 1151, in emit
msg = self.format(record)
...
File ".../logging/init.py", line 400, in getMessage
msg = msg % self.args
TypeError: not enough arguments for format string
Call stack:
...
File ".../temoa/components/limits.py", line 944, in limit_emission_constraint
logger.warning(msg, (e, emission_limit))
Message: "Warning: No technology produces emission '%s', though limit was specified as %s.\n"
Arguments: (('sox', 1000.0),)

ERROR Rule failed when generating expression for Constraint
limit_emission_constraint with index ('utopia', 2000, 'sox', 'le'):
TypeError: not enough arguments for format string
ERROR Constructing component 'limit_emission_constraint' from data=None failed:
TypeError: not enough arguments for format string
ERROR An unhandled error occurred during the Temoa run.

Expected Behavior

Just a warning on the incomplete emissions constraint would rock.

Actual Behavior

TypeError crashes the run

Environment

Please provide details about your environment. This helps us reproduce the issue.

Operating System: macOS 26.2
Python Version: 3.13.5
Project Version: Temoa 4.0.0a2
Relevant Dependencies: Pyomo 6.10.0, highspy 1.14.0

Checklist

  • I have searched existing issues to ensure this bug hasn't already been reported.
  • I have provided clear steps to reproduce the bug.
  • I have provided a minimal, reproducible code example (if applicable).
  • I have included any relevant error messages or stack traces.
  • I have described the expected and actual behavior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions