Skip to content

Refactor CO2Record to only include necessary trace fields #348

@nadnein

Description

@nadnein

Refactor CO2Record to only include necessary trace fields

Problem

Currently, CO2Record stores all trace record fields, including timestamp fields (submit, start, complete) and other fields that are not needed for CO₂ calculation.

When CO2Records are combined via plus(), some of these fields (like timestamps) accumulate as lists, causing:

  • Nextflow validation warnings:
DEBUG nextflow.trace.TraceRecord - Not a valid trace value -- field: 'submit'; value: '[1771840416539, 1771840432042]'; format: 'null'
  • Potential data inconsistencies
  • Larger and harder-to-predict CO2Record objects

Proposed Long-term Solution

Refactor CO2Record so it only includes the trace record fields actually needed for CO₂ computation. This would involve:

  1. Defining a whitelist of allowed trace fields for CO2 calculation.
  2. Updating all CO2Record constructors to only store these fields.
  3. Removing aggregation logic for unneeded fields in plus() and related methods.
  4. Updating tests to only expect these fields in the CO2Record output.

Benefits:

  • Clear separation of concerns: CO2Record = CO₂ metrics only
  • Prevents similar issues with timestamp and irrelevant fields
  • Smaller, more predictable objects for reporting and aggregation

Metadata

Metadata

Assignees

No one assigned

    Labels

    💎 enhancementNew feature or request🔀 refactorChange things to leave it the same🧼 cleanupClean code / aesthetic changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions