Xiangyi Li commited on
Commit
e1810dc
·
1 Parent(s): 81eeaee

Run records: a public run whose updated_at leaves under a second per logged step has no known end, so no 1-second duration (Search-R1's record was updated a second after it started).

Browse files
Files changed (2) hide show
  1. results_api.py +6 -2
  2. test_public_runs.py +10 -0
results_api.py CHANGED
@@ -242,10 +242,14 @@ def metric_score(r):
242
 
243
  def run_end(r):
244
  """When a run ended: its last attempt's end; with no attempt times, the record's updated_at, except for a public run
245
- with attempts, whose updated_at may be when it was imported (its end is then not known)."""
 
246
  every_ = attempts_of(r, False); ends = [e for e in (when(a.get('finished_at')) for a in every_) if e]
247
  if r.get('state') == 'running': return None
248
- return max(ends) if ends else None if public(r) and every_ else when(r.get('updated_at'))
 
 
 
249
 
250
 
251
  def launch_of(name, snap):
 
242
 
243
  def run_end(r):
244
  """When a run ended: its last attempt's end; with no attempt times, the record's updated_at, except for a public run
245
+ with attempts, whose updated_at may be when it was imported (its end is then not known), and a public run whose
246
+ updated_at leaves under a second per logged step (it is not when that run ended)."""
247
  every_ = attempts_of(r, False); ends = [e for e in (when(a.get('finished_at')) for a in every_) if e]
248
  if r.get('state') == 'running': return None
249
+ end = max(ends) if ends else None if public(r) and every_ else when(r.get('updated_at'))
250
+ start = when(r.get('started_at'))
251
+ if public(r) and not ends and end and start and (end - start).total_seconds() < logged_steps(r): return None
252
+ return end
253
 
254
 
255
  def launch_of(name, snap):
test_public_runs.py CHANGED
@@ -147,6 +147,16 @@ def test_projects_group_public_runs_by_their_project_and_org(roots):
147
  assert d['runs']['fixture-eval-scores']['section'] == 'evals'
148
 
149
 
 
 
 
 
 
 
 
 
 
 
150
  def test_an_organization_counts_the_runs_it_ran_even_in_another_organizations_project(roots):
151
  """A project may hold runs of several organizations (a platform's shared runs): each organization counts its own runs,
152
  and the project lists every organization with a run in it."""
 
147
  assert d['runs']['fixture-eval-scores']['section'] == 'evals'
148
 
149
 
150
+ def test_a_public_run_whose_updated_at_is_not_its_end_has_no_duration(roots, client):
151
+ """A record updated a second after it started cannot be when a 120-step run ended: the duration is not known."""
152
+ fw, pub = roots
153
+ write(pub, 'fixture-quick-stamp', run_json('fixture-quick-stamp', started_at='2026-09-20T10:00:00Z', updated_at='2026-09-20T10:00:01Z'), metrics_rows(120))
154
+ fwruns._cache.clear(); R._cache.clear()
155
+ row = {r['id']: r for r in get(client, 'training').json()['runs']}['fixture-quick-stamp']
156
+ assert row['duration_s'] is None and row['ended_at'] is None
157
+ assert get(client, 'fwruns/fixture-quick-stamp').json()['duration_s'] is None
158
+ assert {r['id']: r for r in get(client, 'training').json()['runs']}['fixture-grpo-metrics']['duration_s'] == 6 * 3600 # a plausible end stays
159
+
160
  def test_an_organization_counts_the_runs_it_ran_even_in_another_organizations_project(roots):
161
  """A project may hold runs of several organizations (a platform's shared runs): each organization counts its own runs,
162
  and the project lists every organization with a run in it."""