Skip to content

Support Monitor Layout types + PostgreSQL Example - #616

Merged
superwhiskers merged 8 commits into
developfrom
lukel/monitor-long-dev
Oct 30, 2026
Merged

superwhiskers merged 8 commits into
developfrom
lukel/monitor-long-dev

Conversation

@lukelowry

@lukelowry lukelowry commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds an output_layout solver option for monitor output. With "output_layout": "long", each row of output_file holds one variable at one sample instead of one column per variable, so results load straight into SQL tables no matter how many variables are monitored.

Closes #597.

Wide output is unchanged, and printing is faster:

Format develop This PR
CSV 0.199 s 0.156 s
JSON 0.377 s 0.179 s
YAML 0.310 s 0.181 s

Print time only, 2000 monitors × 4 variables over 500 samples.

Proposed changes

  • Add VariableMonitorLayout (WIDE, LONG) to SinkSpec, set by output_layout next to output_file in the solver file. It defaults to wide, and long is not supported with reference_file.
  • Long rows are sample, t, class, id, variable, value rather than the t, id, value sketched in the issue:
    • class and id are the device's class and id from the case file, since an id alone can repeat across classes.
    • variable gets its own column, so queries can filter or group by variable without parsing names.
    • sample is needed for a unique key, since the samples just before and after an event share the same t.
  • Monitors hand their variables to the controller once (appendEntries), and the controller writes every format and layout from that list. This replaces the per-format virtuals in VariableMonitorBase and the formatting code in VariableMonitor.
  • The layout is a template parameter of each sink (Sink<FormatT, Layout>), resolved at compile time.
  • Monitored getters must return a real value (static_assert in set()); every existing getter does.
  • Remove the unused VariableMonitorController::addVariable.
  • Add a DynamicSimulation/PostgreSQL example that runs an ACTIVSg2000 bus fault and loads the long output into PostgreSQL with Docker Compose or Podman.
  • Mark case-file monitors for removal in a follow-up PR.

Checklist

  • All tests pass.
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit™ style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • The CHANGELOG.md has been updated to reflect the changes.

Further comments

@pelesh Feedback on PR length/scope

@tsybinae Thank you for the suggestion and guidance.

@lukelowry lukelowry self-assigned this Oct 11, 2026
@lukelowry lukelowry added the enhancement New feature or request label Oct 11, 2026
@lukelowry
lukelowry force-pushed the lukel/monitor-long-dev branch 2 times, most recently from bba5a78 to 757dcfe Compare October 14, 2026 22:24
@tsybinae

Copy link
Copy Markdown
Collaborator

Hi. I am reviewing the code. It builds, runs, and produces the csv. The timestamp looks a bit odd, for instance, row 569215 looks like this

1704,7.0916666666666668e+00,Genrou,5281_1_genrou,omega,2.2408284627934353e-05

This effectively means that t = 7.09 something. Is this thing going to merge on t if I need to left join?

Thank you.

@lukelowry

Copy link
Copy Markdown
Collaborator Author

@tsybinae Thanks! Join on sample, since t repeats at events (before and after). Also, the time just has a rounding issue due to floating point precision, so joining on t is not recommended.

Let me know if you have any othr issues!

@tsybinae

Copy link
Copy Markdown
Collaborator

This functionality is not specific to the csv task, so the merge can go ahead. There may be more precision related questions within a few month.

@tsybinae tsybinae left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Builds and runs cleanly.

@superwhiskers superwhiskers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

core idea seems like the right approach. just some comments on implementation of formatting that should be addressed before this goes further.

Comment thread GridKit/Model/VariableMonitor.hpp Resolved
Comment thread GridKit/Model/VariableMonitor.hpp Resolved
Comment thread GridKit/Model/VariableMonitor.hpp Resolved
@lukelowry

Copy link
Copy Markdown
Collaborator Author

@nkoukpaizan @superwhiskers feedback greatly appreciated! the example I hope is much better. And hopfully the template parameter approach is cleaner, please LMK

@lukelowry
lukelowry force-pushed the lukel/monitor-long-dev branch from f81fbde to f9037df Compare October 22, 2026 16:59
@read-the-docs-community

read-the-docs-community Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 GridKit | 🛠️ Build #35533600 | 📁 Comparing 60a7b81 against latest (c9a6497)

  🔍 Preview build  

168 files changed · + 99 added · ± 64 modified · - 5 deleted

+ Added

± Modified

- Deleted

@lukelowry
lukelowry force-pushed the lukel/monitor-long-dev branch 3 times, most recently from 46e3661 to 0ccf09e Compare October 28, 2026 17:18
@lukelowry

Copy link
Copy Markdown
Collaborator Author

@nkoukpaizan @superwhiskers This should be ready for final approval/review!

@superwhiskers superwhiskers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if we're going to blanket reject special characters inside these, we should do it at the point of parsing them, not later on when we construct the writer.

Comment thread GridKit/Model/VariableMonitorImpl.hpp Resolved

@pelesh pelesh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good to merge provided comment by @superwhiskers is addressed. Reject malformed bus labels at the point of inputing the data.

@lukelowry
lukelowry force-pushed the lukel/monitor-long-dev branch from a10aa5f to 19f1b6e Compare October 30, 2026 20:15
@lukelowry

Copy link
Copy Markdown
Collaborator Author

Ready

@superwhiskers
superwhiskers merged commit 01d7543 into develop Oct 30, 2026
7 checks passed
@superwhiskers
superwhiskers deleted the lukel/monitor-long-dev branch October 30, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data output design for better postprocessing.

5 participants