Skip to content

Emissions CSV export#1753

Open
aaccensi wants to merge 2 commits into
emissionsfrom
emissions-export
Open

Emissions CSV export#1753
aaccensi wants to merge 2 commits into
emissionsfrom
emissions-export

Conversation

@aaccensi
Copy link
Copy Markdown
Member

@aaccensi aaccensi commented May 20, 2026

Context

As part of the emissions project we want to be able to export the emissions data in a CSV. The existing ConfiguredCSVSerializer serializes graph data to CSV based on a YAML config in ETSource, but it only supported simple query-based columns. The emissions export requires iterating over nodes in a group and reading attributes directly from each node, including support for both the energy and molecules graphs.

Implemented changes

Expanded ConfiguredCSVSerializer to support two new column types:

  • node_group: A hidden column whose value names a node group. The config row is expanded into one CSV row per node in that group, combining nodes from both the energy and molecules graphs.
  • node_attribute: Evaluates a Ruby expression against node_api for each expanded node. Supports an optional transform: expression (with value bound to the result) for post-processing, e.g. unit conversion or conditional mapping.

Other changes:

  • Added an optional period: parameter (:present or :future) to the serializer to select which graph to use for node expansion. Existing column types (present, future, unit, query) are unaffected.
  • Fixed label: being silently ignored for non-query column types.
  • Added emissions_present and emissions_future CSV endpoints backed by a new emissions_csv.yml config in ETSource.

Related

This effort is in 3 places but only 2 of them have PRs (to merge back into the general emissions branch)

Checklist

  • I have tested these changes
  • I have updated documentation as needed
  • I have tagged the relevant people for review

@aaccensi aaccensi requested a review from noracato May 20, 2026 14:52
@aaccensi aaccensi marked this pull request as ready for review May 20, 2026 14:52
@aaccensi aaccensi force-pushed the emissions-export branch from 1b41948 to f67417e Compare May 21, 2026 06:50
@aaccensi aaccensi force-pushed the emissions-export branch from f67417e to a60a0e2 Compare May 21, 2026 07:10
@kndehaan kndehaan requested a review from mabijkerk May 21, 2026 07:24
Copy link
Copy Markdown
Member

@noracato noracato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very elegant solution with the transform attribute. Nice find!

Specs look good as well! Great work

@kndehaan
Copy link
Copy Markdown
Member

@noracato @aaccensi we updated the direct_emissions_csv.yml on ETSource to contain all the relevant groups. Robin also updated the spec fixture file on ETEngine. Does this spec file indeed need to be updated as well or should we undo this commit?

Copy link
Copy Markdown
Member

ETEngine should generally only be touched by devs. The specs are fast internal tests to see if the code is behaving correctly under different cases and circumstances. I will revert the commit for you.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants