Skip to content

fix: retain session start in metrics reports - #549

Draft
TeoSlayer wants to merge 4 commits into
mlcommons:mainfrom
TeoSlayer:fix/session-start
Draft

TeoSlayer wants to merge 4 commits into
mlcommons:mainfrom
TeoSlayer:fix/session-start

Conversation

@TeoSlayer

@TeoSlayer TeoSlayer commented Oct 28, 2026 •

Copy link
Copy Markdown

Carry the monotonic session start through live snapshots, final JSON, and reports so elapsed-time reporting uses the actual session origin. Append the optional snapshot field to preserve older array-encoded messages; missing timestamps keep the existing zero fallback. Refs #463.

Tests cover live, complete, interrupted, and older snapshots. Synced with upstream dependency/watchdog fixes, with session startup synchronized in the SIGINT test. Full Linux CI passes.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

MLCommons CLA bot:
Thank you very much for your submission; we really appreciate it. Before we can accept your contribution,
we ask that you sign the MLCommons CLA (Apache 2). Please submit your GitHub ID to our onboarding form to initiate
authorization. If you are from a MLCommons member organization, we will request that you be added to the CLA.
If you are not from a member organization, we will email you a CLA to sign. For any questions, please contact
support@mlcommons.org.
1 out of 2 committers have signed the MLCommons CLA.
✅ @TeoSlayer
❌ @teovl
You can retrigger this bot by commenting recheck in this Pull Request

@github-actions github-actions Bot added the size/normal PR Review Policy: <=500 non-test lines & <=20 files label Oct 28, 2026
@codecov-commenter

codecov-commenter commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@745ac91). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #549   +/-   ##
=======================================
  Coverage        ?   82.66%           
=======================================
  Files           ?      170           
  Lines           ?    24334           
  Branches        ?        0           
=======================================
  Hits            ?    20115           
  Misses          ?     4219           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TeoSlayer

TeoSlayer commented Nov 5, 2026 •

Copy link
Copy Markdown
Author

Verified session starts survive live/final snapshots and older snapshots remain readable. All CI checks pass.

# Conflicts:
#	tests/integration/commands/test_sigint.py
loop = asyncio.get_event_loop()
with ManagedZMQContext.scoped(socket_dir=str(tmp_path)) as ctx:
agg, _, _ = make_aggregator(ctx, loop, "agg_started_ts")
agg, _, publisher = make_aggregator(ctx, loop, "agg_started_ts")

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.

After rebasing onto main, this line conflicts with #552, which added token_count_source=DEFAULT_SOURCE to the same call. The resolution keeps both:

agg, _, publisher = make_aggregator(
    ctx, loop, "agg_started_ts", token_count_source=DEFAULT_SOURCE
)

)
)
snap.update(start)
report = Report.from_snapshot(snap)

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.

After rebasing onto main, all three parametrized cases fail:

TypeError: Report.from_snapshot() missing 1 required keyword-only argument: 'token_count_source'

#552 made token_count_source required. DEFAULT_SOURCE is already imported in this file on main:

report = Report.from_snapshot(snap, token_count_source=DEFAULT_SOURCE)

Verified locally: passes with this change.

version=str(version_info.get("version", "unknown")),
git_sha=version_info.get("git_sha"),
test_started_at=0, # TODO: surface session_started_ns via snapshot
test_started_at=snap.get("session_started_ns") or 0,

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.

This changes test_started_at in result_summary.json (written by to_json) from 0 to a raw time.monotonic_ns() value: nanoseconds since boot, not since the epoch. Only the console "Test started at:" line converts it (monotime_to_datetime). Anyone reading the JSON gets a number that looks like a timestamp but isn't one, and it can't be compared across hosts or reboots.

Could we either:

  • convert to wall-clock time (epoch ns) here and have the display print it directly, or
  • keep it monotonic but document the field as such (and perhaps add a separate wall-clock field)?

@mlcommons-cla-bot

Copy link
Copy Markdown

MLCommons CLA bot: Thank you very much for your submission; we really appreciate it. Before we can accept your contribution, each committer needs to be covered by the MLCommons CLA (Apache 2):

  1. Sign in to MLCommons profile management.
  2. Link your GitHub account.
  3. Follow the CLA steps there. They show whether you need to sign it yourself or are covered by your organization.

1 out of 2 committers are covered by the MLCommons CLA.

Once you're covered, comment recheck in this pull request or click Re-run on the check.

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

Labels

size/normal PR Review Policy: <=500 non-test lines & <=20 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants