Skip to content

refactor(evaluation): shared groundwork for time-series metrics - #785

Merged
seayang-nv merged 6 commits into
mainfrom
seayang/ts-metric-groundwork
Oct 30, 2026
Merged

seayang-nv merged 6 commits into
mainfrom
seayang/ts-metric-groundwork

Conversation

@seayang-nv

@seayang-nv seayang-nv commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Moves the code every time-series metric needs into shared modules, so #780, #782 and #783 can each target main instead of stacking.

  • time_series_common.py: grouping and column helpers, previously copied into every metric.
  • TimeSeriesComponent: base class carrying each metric's card attributes; the report runs and renders the components listed in TIME_SERIES_COMPONENTS.
  • time_series_charts.j2: shared card macros, with generic CSS and JS names.
  • TimeSeriesValueColumnCheck: now checks every metric's value_columns, and rejects the timestamp and grouping columns.
  • Autocorrelation's score is now saved in evaluation_metrics.json and W&B.
  • Fix: a synthetic column that collapses to a few values is now scored, not silently dropped.

Human review

  • ⚪ No human review; automated review only
  • 🟡 Partially reviewed or spot-checked by a human
  • 🔵 Complete diff reviewed by a human
  • 🟢 Complete diff reviewed and verified by a human

Pre-Review Checklist

  • mise run format leaves only intended formatting changes.
  • mise run check ::: test passes locally. Fails only on vllm imports, which aren't installed on macOS; main fails the same way.
  • mise run test:e2e passes locally
  • mise run test:ci-container passes locally (recommended)
  • GPU CI status check passes -- comment /sync on this PR to trigger a run (auto-triggers on ready-for-review)

Pre-Merge Checklist

  • New or updated tests for any fix or new behavior
  • Updated documentation for new features and behaviors, including docstrings for API docs.

Other Notes

  • Not checked yet: the column selector and chart colors in a browser.

Summary by CodeRabbit

  • New Features
    • Added configurable time-series metric cards to multimodal evaluation reports, including autocorrelation similarity.
    • Added an autocorrelation similarity score to evaluation summaries and reporting.
    • Added options to select value columns for time-series metrics and choose columns in multi-column charts.
  • Bug Fixes
    • Improved handling of non-numeric and constant-valued columns, with clearer notes when columns are excluded or scores are unavailable.
    • Made group sampling and time-series comparisons more consistent and reproducible.
    • Added validation for configured time-series value columns, including checks for reserved, missing, or non-numeric columns.
  • Documentation
    • Updated time-series evaluation documentation to describe scoring, report options, and metric configuration.

Move the grouping, column-selection, group-sampling and summary helpers
out of Autocorrelation Similarity into time_series_common, and register
time-series metrics in one TIME_SERIES_CARDS list that the multi-modal
report uses to run each component, build its figures and render its card.

- Report template loops over registered cards; card bodies use shared
  comparison_notes and chart_grid macros with generic CSS and JS names.
- TimeSeriesValueColumnCheck validates value_columns for every
  TimeSeriesMetricParameters field, so new metrics need no preflight code.
- Export autocorrelation_similarity_score to SafeSynthesizerSummary,
  evaluation_metrics.json and W&B.
- Fix: automatic column selection follows training field types, so a
  synthetic column that collapsed to a constant or a few integers is
  scored instead of silently dropped. Columns synthetic data lacks or
  stores as text are listed in the notes and details.

Signed-off-by: Sean Yang <seayang@nvidia.com>
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.74490% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...valuation/components/autocorrelation_similarity.py 97.50% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d8e2de2 and d0a3e58.

Files selected for processing: 2
  • src/nemo_safe_synthesizer/TIMESERIES_README.md
  • tests/preflight/test_preflight.py
Files skipped from review as they are similar to previous changes: 2
  • tests/preflight/test_preflight.py
  • src/nemo_safe_synthesizer/TIMESERIES_README.md

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

Recent review details
Context from checks skipped due to timeout: 6
  • GitHub Check: CodeRabbit
  • GitHub Check: Unit Tests (3.12)
  • GitHub Check: Unit Tests (3.13)
  • GitHub Check: Unit Tests (3.11)
  • GitHub Check: Unit Tests (3.14)
  • GitHub Check: End-user Wheel Install

Walkthrough

This change adds shared configuration and evaluation helpers for time-series metrics. Autocorrelation Similarity uses the shared helpers and supplies report-card context. The multimodal report renders registered time-series cards, and the autocorrelation similarity score is included in summary and W&B output.

Changes

Time-Series Evaluation

Layer / File(s) Summary
Metric configuration and shared evaluation helpers
src/nemo_safe_synthesizer/config/evaluate.py, src/nemo_safe_synthesizer/evaluation/components/time_series_common.py, src/nemo_safe_synthesizer/preflight/checks/dataframe.py, tests/evaluation/components/test_time_series_common.py, tests/preflight/test_preflight.py
Adds a shared time-series metric configuration and helpers for selecting columns and groups, ordering sequences, and summarizing profiles. Preflight checks and tests cover configured value columns across metrics.
Autocorrelation evaluation and figures
src/nemo_safe_synthesizer/evaluation/components/autocorrelation_similarity.py, src/nemo_safe_synthesizer/evaluation/components/autocorrelation_similarity_figures.py, tests/evaluation/components/test_autocorrelation_similarity.py
Autocorrelation Similarity delegates column and group handling and summary aggregation to shared helpers. It records excluded columns and supplies figure metadata for rendering. Tests cover collapsed values and columns excluded from comparison.
Registered time-series report cards and chart rendering
src/nemo_safe_synthesizer/evaluation/reports/multimodal/multimodal_report.py, src/nemo_safe_synthesizer/evaluation/assets/jinja/components/*, src/nemo_safe_synthesizer/evaluation/assets/jinja/reports/multi_modal_report.j2, src/nemo_safe_synthesizer/evaluation/assets/css/multi_modal_report.css, src/nemo_safe_synthesizer/evaluation/assets/js/multi_modal_toggle.js, tests/evaluation/reports/test_multimodal_report.py, tests/evaluation/test_render_assets.py
The report creates components from TIME_SERIES_COMPONENTS and renders cards from their contexts. Shared templates and time-series selectors handle chart content and display.
Score export and metric documentation
src/nemo_safe_synthesizer/config/external_results.py, src/nemo_safe_synthesizer/results.py, tests/test_results.py, src/nemo_safe_synthesizer/TIMESERIES_README.md
Adds the autocorrelation similarity score to summary extraction and W&B output. The README describes metric behavior, report integration, and steps for adding a time-series metric.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Possibly related PRs

Suggested labels: bug, feature, refactor

Suggested reviewers: binaryaaron

Merge Risk: Minimal · up to d0a3e

No identified issue blocks merging after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: shared evaluation infrastructure for time-series metrics.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@seayang-nv seayang-nv changed the title refactor(evaluation): shared plumbing for time-series metrics refactor(evaluation): shared groundwork for time-series metrics Oct 21, 2026
Signed-off-by: Sean Yang <seayang@nvidia.com>
@seayang-nv
seayang-nv marked this pull request as ready for review October 21, 2026 16:52
@seayang-nv
seayang-nv requested a review from a team as a code owner October 21, 2026 16:52
@coderabbitai coderabbitai Bot added bug Defects in shipped behavior feature New feature or request labels Oct 21, 2026
@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

This PR moves shared time-series helpers, report cards, and chart templates into reusable code.

  • Time-series metrics share column selection and sequence handling.
  • The report builds time-series cards from one shared layout.
  • Preflight checks value columns for every time-series metric.
  • Autocorrelation scores appear in saved summaries and W&B.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    Registry["TIME_SERIES_COMPONENTS"] --> Components["TimeSeriesComponent subclasses"]
    Helpers["Shared grouping and column helpers"] --> Components
    Components --> Cards["Time-series report cards"]
    Components --> Scores["Saved metrics and W&B"]
Loading

Reviews (4) · Last reviewed commit: "test(preflight): check reserved-column i..." · Reviewed by Greptile

@kendrickb-nvidia kendrickb-nvidia 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.

Shared methods and config parameters makes sense. But the time_series_cards.py feels like a weird extra abstraction layer. Is this a pattern we're thinking of using more and porting to the existing metrics? Could it be incorporated into the existing components classes instead of making a new setup? Though I get one is about computation and one is about rendering (sort of).

(In the future we'll probably relax the numeric only requirement on columns for some of these metrics, at a minimum autocorrelation I hope, but can handle that exception when/if it happens.)

Comment thread src/nemo_safe_synthesizer/results.py Resolved
Replace the TIME_SERIES_CARDS registry with a TimeSeriesComponent base
class. Each time-series component now carries its card attributes as
class variables and builds its figures in jinja_context, like the other
evaluation components, and the report runs a plain TIME_SERIES_COMPONENTS
tuple.

- Name left-out columns in the notes and details when no usable column or
  group remains, not only on scored results.
- Drop function and class listings from module docstrings.
- Cover the remaining time_series_common guards.

Signed-off-by: Sean Yang <seayang@nvidia.com>
@coderabbitai coderabbitai Bot added the refactor Internal restructuring with no behavior change label Oct 26, 2026
…value columns

Align TimeSeriesValueColumnCheck with the runtime reserved-column validation, and replace the outdated evaluation parameters section of TIMESERIES_README.md with the current nested configuration, marking time-series evaluation as in progress.

Signed-off-by: Sean Yang <seayang@nvidia.com>
@seayang-nv
seayang-nv requested a review from memadi-nv October 29, 2026 16:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 899d7f7 and d8e2de2.

Files selected for processing: 3
  • src/nemo_safe_synthesizer/TIMESERIES_README.md
  • src/nemo_safe_synthesizer/preflight/checks/dataframe.py
  • tests/preflight/test_preflight.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Review details
Context from checks skipped due to timeout: 8
  • GitHub Check: Unit Tests (3.14)
  • GitHub Check: Unit Tests (3.12)
  • GitHub Check: Unit Tests (3.11)
  • GitHub Check: Unit Tests (3.13)
  • GitHub Check: Smoke Tests
  • GitHub Check: End-user Wheel Install
  • GitHub Check: CodeRabbit
  • GitHub Check: Greptile Review
Additional context used
Code guidelines: 6
CONTRIBUTING.md — configured
STYLE_GUIDE.md — configured
tests/TESTING.md — configured
.cursor/rules/repo-navigation.mdc — configured
AGENTS.md — configured
.cursor/rules/agent-markdown-style.mdc — configured
Path-based instructions: 11
Review tests against tests/TESTING.md.

CodeRabbit configuration file

Files:

  • tests/preflight/test_preflight.py
Review library code against STYLE_GUIDE.md.

CodeRabbit configuration file

Files:

  • src/nemo_safe_synthesizer/preflight/checks/dataframe.py
Review as a senior maintainer for NeMo Safe Synthesizer.

CodeRabbit configuration file

Files:

  • tests/preflight/test_preflight.py
  • src/nemo_safe_synthesizer/preflight/checks/dataframe.py
  • src/nemo_safe_synthesizer/TIMESERIES_README.md
Source excerpt: All source files (`.py`, `.sh`, `.yaml`, `.yml`, `.md`) require SPDX copyright headers.

CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • tests/preflight/test_preflight.py
  • src/nemo_safe_synthesizer/preflight/checks/dataframe.py
  • src/nemo_safe_synthesizer/TIMESERIES_README.md
Applicability reference: AGENTS.md: # AGENTS.md See [STYLE_GUIDE.md](STYLE_GUIDE.md) for detailed code style conventions (Python, markdown, Dockerfiles, shell scripts, testing, config files, docstrings).

CodeRabbit inference engine (STYLE_GUIDE.md)

Files:

  • tests/preflight/test_preflight.py
  • src/nemo_safe_synthesizer/preflight/checks/dataframe.py
  • src/nemo_safe_synthesizer/TIMESERIES_README.md
Source excerpt: API reference pages are auto-generated from Python docstrings.

CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • src/nemo_safe_synthesizer/preflight/checks/dataframe.py
  • src/nemo_safe_synthesizer/TIMESERIES_README.md
Applicability reference: AGENTS.md: # AGENTS.md Durable implementation guidance belongs with the code it describes: function and class docstrings for public contracts and source comments for local invariants.

CodeRabbit inference engine (tests/TESTING.md)

Files:

  • tests/preflight/test_preflight.py
Applicability reference: AGENTS.md: # AGENTS.md See [STYLE_GUIDE.md](STYLE_GUIDE.md) for detailed code style conventions (Python, markdown, Dockerfiles, shell scripts, testing, config files, docstrings).

CodeRabbit inference engine (STYLE_GUIDE.md)

Files:

  • tests/preflight/test_preflight.py
  • src/nemo_safe_synthesizer/preflight/checks/dataframe.py
  • src/nemo_safe_synthesizer/TIMESERIES_README.md
Source excerpt: `tests/` -- mirrors `src/` structure

CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)

Files:

  • tests/preflight/test_preflight.py
Source excerpt: Use `uv` for everything -- never `pip` or raw `python`.

CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/preflight/test_preflight.py
  • src/nemo_safe_synthesizer/preflight/checks/dataframe.py
Do not use `**bold**` in list items, body text, or docstrings.

CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)

Files:

  • src/nemo_safe_synthesizer/TIMESERIES_README.md
Learnings: 1
Common learnings
Learnt from: CR
Repo: NVIDIA-NeMo/Safe-Synthesizer

Timestamp: 2026-10-29T16:56:53.624Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md
## Repo Conventions
See [STYLE_GUIDE.md](STYLE_GUIDE.md) for detailed code style conventions (Python, markdown, Dockerfiles, shell scripts, testing, config files, docstrings).

Source excerpt:
# Style Guide

## General conventions

### Copyright headers

Every source file requires an SPDX copyright header and `mise run format` handles this automatically. See [tools/codestyle/copyright_fixer.py](tools/codestyle/copyright_fixer.py).
Additional comments: 1
src/nemo_safe_synthesizer/TIMESERIES_README.md: 1

17-17: LGTM!

Also applies to: 40-40, 120-134, 137-138, 465-495, 660-660

Comment thread tests/preflight/test_preflight.py Resolved
…mn assertion

Signed-off-by: Sean Yang <seayang@nvidia.com>
…instead of full wording

Signed-off-by: Sean Yang <seayang@nvidia.com>
@seayang-nv
seayang-nv added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit d26e370 Oct 30, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:config area:data-processing area:docs area:evaluation area:tests bug Defects in shipped behavior feature New feature or request refactor Internal restructuring with no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants