Report per-run cost metrics in output.yml - #945
Draft
calvinp0 wants to merge 3 commits into
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feature_arc_result_export_contract #945 +/- ##
=====================================================================
Coverage ? 64.12%
=====================================================================
Files ? 115
Lines ? 39720
Branches ? 10340
=====================================================================
Hits ? 25469
Misses ? 11235
Partials ? 3016
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The Scheduler now appends a lightweight record for every job that reaches `end_job`: job name, species label, job type, adapter, server, cpu cores, run time in seconds, and final status. The records accumulate on `Scheduler.completed_job_records` and are persisted in the restart file so a restarted run keeps its cost history. Pipe-mode tasks bypass the JobAdapter path and carry no per-task timing, so they are not individually recorded; only jobs ejected back to the Scheduler are.
Adds a `cost_metrics` section to output.yml, aggregating the per-job records the Scheduler collects into wall time, total job count, total execution time, total core hours, and a per-ESS breakdown. Jobs whose run time or core count could not be determined are counted in `jobs_missing_time` / `jobs_missing_cores` rather than being silently dropped, so a consumer can tell how complete the accounting is. `_timedelta_to_seconds()` normalizes the several shapes a run time arrives in (`timedelta`, numeric seconds, `H:MM:SS`, `D days, H:MM:SS`), returning None rather than raising on an unparseable value. `write_output_yml()` gains a `completed_job_records` argument alongside the existing `t0`; both default to None, so a caller that supplies neither gets an empty `cost_metrics` block rather than a missing key.
`ARC` hands the Scheduler's records to `write_output_yml()` so the run's `cost_metrics`
are populated, and accepts them back as a constructor argument so they survive a restart.
That second half matters more than it looks. `ARC.py` restarts a project with
`ARC(**read_yaml_file('restart.yml'))`, so the restart file is also ARC's constructor
namespace - but it is `ARC.as_dict()` plus whatever `Scheduler.save_restart_dict()` adds
to it. Persisting the records without a matching constructor parameter therefore makes
every restart of a project that has accumulated any fail immediately with
`TypeError: got an unexpected keyword argument`. `as_dict()` emits the key when non-empty
so the round trip is symmetric, and a restart file written before the key existed still
constructs.
`TestRestartRoundTrip` asserts that every key written into a restart dictionary - by
`as_dict()` and by the Scheduler - is a constructor parameter. That invariant previously
had no coverage at all: `ARC(**read_yaml_file(restart.yml))` was exercised by no test, so
this class of breakage stayed invisible until somebody restarted an affected project. Any
future key added to `Scheduler.save_restart_dict()` without touching `main.py` now fails
a test instead of a run.
calvinp0
force-pushed
the
feature_cost_metrics
branch
from
August 2, 2026 20:19
76abfa2 to
90e682b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
A
cost_metricssection inoutput.yml, answering "what did this run actually cost?":Three layers, one per commit:
arc/scheduler.py— the Scheduler appends a lightweight record for every job reachingend_job(name, label, job type, adapter, server, cpu cores, run time, status). Pipe-mode tasks bypass theJobAdapterpath and carry no per-task timing, so they are deliberately not recorded; only jobs ejected back to the Scheduler are.arc/output.py—_compute_cost_metrics()aggregates them;_timedelta_to_seconds()normalizes the several shapes a run time arrives in (timedelta, numeric seconds,H:MM:SS,D days, H:MM:SS), returningNonerather than raising on an unparseable value.arc/main.py— wires the records through towrite_output_yml(), and accepts them back on restart.Incomplete accounting is counted, not hidden
Jobs with no recorded run time or core count land in
jobs_missing_time/jobs_missing_coresinstead of being silently dropped, so a consumer can tell how complete the numbers are. A run where a third of jobs lack timing produces a visibly partial total rather than a confidently wrong one.The restart half is a real bug fix, not plumbing
Persisting the records is what makes them survive a restart — and that is exactly where this bit us in practice:
ARC.pyrestarts withARC(**read_yaml_file('restart.yml')), so the restart file is ARC's constructor namespace — but it isARC.as_dict()plus whateverScheduler.save_restart_dict()adds to it. Writing the records there without a matching constructor parameter makes every restart of a project that has accumulated any fail instantly.as_dict()now emits the key when non-empty so the round trip is symmetric, and a restart file written before the key existed still constructs.TestRestartRoundTripasserts that every key written into a restart dictionary — byas_dict()and by the Scheduler — is a constructor parameter. That invariant had no coverage at all:ARC(**read_yaml_file(restart.yml))was exercised by no test, which is why this class of breakage stays invisible until somebody actually restarts. Any future key added toScheduler.save_restart_dict()without touchingmain.pynow fails a test instead of a multi-day run.Evidence
222 tests pass (
output_test,main_test,scheduler_test), including 20 new ones:_timedelta_to_secondsacross all input shapes,_compute_cost_metricsaggregation / missing-data counting / unknown-adapter bucketing, thecost_metricssection end-to-end throughwrite_output_yml, and the four restart round-trip guards.Notes for review
scheduler.py|output.py+tests+docs |main.py+tests), so the three are independently readable.write_output_yml()'s newcompleted_job_recordsdefaults toNone, alongside the existingt0; a caller supplying neither gets an emptycost_metricsblock rather than a missing key.ts_guessesexport, and that is the version kept here.