climate_ref.results.resources
#
Read surface for per-execution resource measurements.
ResourcesReader is reached via Reader.resources. It reads the resource columns on Execution and aggregates them into a ResourceProfile per diagnostic or per provider, which is the number a maintainer needs when sizing a worker.
Not all executions have resource data.
Confidence = Literal['good', 'thin', 'none']
module-attribute
#
How much weight a profile's recommendation can carry.
GroupBy = Literal['diagnostic', 'provider']
module-attribute
#
Axis a profile is aggregated over.
ResourceFilter
#
Declarative filter over the executions considered for a resource profile.
Every field is optional, and None means "do not constrain on this axis".
diagnostic_contains/provider_contains are case-insensitive substring matches
(OR-combined within each field),
matching the semantics used by
ExecutionGroupFilter.
Source code in packages/climate-ref/src/climate_ref/results/resources.py
diagnostic_contains = attrs.field(default=None, converter=_as_str_tuple)
class-attribute
instance-attribute
#
Case-insensitive substring matches on diagnostic slug (OR-combined).
provider_contains = attrs.field(default=None, converter=_as_str_tuple)
class-attribute
instance-attribute
#
Case-insensitive substring matches on provider slug (OR-combined).
since = None
class-attribute
instance-attribute
#
Keep only executions created at or after this naive UTC timestamp.
ResourceMeasurementCollection
#
An immutable page of resource measurements plus collection-level metadata.
Source code in packages/climate-ref/src/climate_ref/results/resources.py
items
instance-attribute
#
The measurements on this page.
limit
instance-attribute
#
Page size requested, or None when the whole result was returned.
offset
instance-attribute
#
Rows skipped before this page.
total_count
instance-attribute
#
Total measurements matching the filter before offset/limit.
to_pandas()
#
DataFrame with one row per measurement.
Columns are emitted explicitly even when the collection is empty, so callers can select columns without special-casing.
Source code in packages/climate-ref/src/climate_ref/results/resources.py
ResourceMeasurementView
#
One execution's resource measurement, detached from the ORM.
Source code in packages/climate-ref/src/climate_ref/results/resources.py
cpu_limit
instance-attribute
#
CPU cores available to the execution.
cpu_seconds
instance-attribute
#
CPU time consumed by the execution and its children, in seconds.
created_at
instance-attribute
#
Timestamp the execution was created.
diagnostic_slug
instance-attribute
#
Owning diagnostic's slug.
execution_id
instance-attribute
#
Primary key of the underlying Execution row.
memory_limit_bytes
instance-attribute
#
Memory limit in force while the execution ran, in bytes.
memory_source
instance-attribute
#
Provenance of peak_memory_bytes.
parallelism
property
#
Mean core occupancy, or None when either input is missing.
peak_memory_bytes
instance-attribute
#
Peak resident memory observed during the execution, in bytes.
provider_slug
instance-attribute
#
Owning provider's slug.
queue_seconds
instance-attribute
#
Time between submission and the start of the execution, in seconds.
resources_exclusive
instance-attribute
#
Whether this execution was the only one running on the worker.
successful
instance-attribute
#
True/False once the execution has finished, None while still running.
wall_seconds
instance-attribute
#
Wall clock time taken by the execution, in seconds.
ResourceProfile
#
Aggregated resource usage for one diagnostic, or for one provider as a roll-up.
Every percentile is computed over the usable samples only.
A usable sample is an execution that recorded a wall time, a CPU time and a peak memory figure,
whose memory source matches memory_source,
and whose peak is attributable to it alone when exclusive_only was requested,
which only rules out a cgroup reading taken from a shared container.
Executions that recorded nothing at all are absent from both counts,
because an unmeasured run is not a run that used no memory.
A run that failed is aggregated like any other, provided it recorded a measurement. A diagnostic that reached 40 GiB before dying is the row that most needs to reach a recommendation.
Source code in packages/climate-ref/src/climate_ref/results/resources.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
confidence
property
#
How much weight the recommendation can carry.
none when there are no usable samples at all,
thin below ten samples, where the p95 is indistinguishable from the maximum,
and good at or above ten.
cpu_seconds_p95
instance-attribute
#
95th percentile CPU time, in seconds.
diagnostic_slug
instance-attribute
#
Owning diagnostic's slug, or None for a provider-level roll-up.
headroom_ratio
instance-attribute
#
memory_limit_seen / peak_memory_p95, or None when no limit was recorded.
Below 1 means the diagnostic is being killed by the current container size.
memory_limit_seen
instance-attribute
#
Memory limit in force for the most recent sample that recorded one.
The most recent limit rather than the largest, because the question being answered is whether the container as it is configured now is big enough.
memory_source
instance-attribute
#
Provenance of every peak memory figure aggregated here, or None when there are no samples.
A cgroup reading and a rusage reading for the same run can differ by a factor of two,
so they are never mixed.
When a group's executions carry more than one source,
the source contributing the most samples wins and the rest land in n_excluded.
n_excluded
instance-attribute
#
Executions that were measured but not usable.
A row lands here when it carried a cgroup reading from a container it did not have to itself,
when it was incomplete,
or when it carried a memory source other than memory_source.
n_failed
instance-attribute
#
Failed executions in the same window, measured or not.
An execution killed for exceeding its memory limit records nothing,
so it never appears in n_samples.
That biases every recommendation here low on exactly the diagnostics that need more memory,
and this count is the only warning of it.
n_samples
instance-attribute
#
Executions with a usable measurement.
over_limit
property
#
Whether the p95 peak has outgrown the recorded memory limit.
parallelism_p95
instance-attribute
#
95th percentile of cpu_seconds / wall_seconds.
This is the core-count signal. A diagnostic sitting near 1.0 is serial and gains nothing from more cores.
peak_memory_max
instance-attribute
#
Largest peak resident memory observed, in bytes.
peak_memory_p50
instance-attribute
#
Median peak resident memory, in bytes.
peak_memory_p95
instance-attribute
#
95th percentile peak resident memory, in bytes.
provider_slug
instance-attribute
#
Owning provider's slug.
recommended_cpus
property
#
Mean parallelism at the 95th percentile, rounded up, never below one core.
recommended_memory_bytes
property
#
Peak memory p95 scaled by safety_factor, rounded up to a whole GiB.
safety_factor = 1.3
class-attribute
instance-attribute
#
Multiplier applied to the p95 peak when recommending a memory size.
wall_p95
instance-attribute
#
95th percentile wall clock time, in seconds.
ResourcesReader
#
Per-execution resource measurement read domain.
Constructed from a Database, which owns the session and the read-only story. All read methods return detached DTOs that outlive the session.
Source code in packages/climate-ref/src/climate_ref/results/resources.py
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | |
session
property
#
The underlying database session.
measurement(execution_id)
#
Fetch one execution's measurement by execution id.
Returns None when no execution has that id,
or when the execution neither recorded a measurement nor failed.
Source code in packages/climate-ref/src/climate_ref/results/resources.py
measurements(filters=None, *, offset=0, limit=None)
#
Query the raw per-execution measurements behind the profiles.
Pagination is applied in SQL over the deterministic created_at, id ordering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
ResourceFilter | None
|
Restricts the executions considered. |
None
|
offset
|
int
|
Rows to skip before the returned page. |
0
|
limit
|
int | None
|
Page size, or |
None
|
Returns:
| Type | Description |
|---|---|
ResourceMeasurementCollection
|
A page of measurements plus the pre-pagination total. |
Source code in packages/climate-ref/src/climate_ref/results/resources.py
profiles(*, diagnostic_contains=None, provider_contains=None, since=None, group_by='diagnostic', exclusive_only=True, safety_factor=1.3)
#
Aggregate resource measurements into a sizing answer per diagnostic or per provider.
Rows are filtered in SQL and the percentiles are computed in Python, because SQLite has no percentile function.
A cgroup peak recorded while a worker ran four executions at once measures the worker,
not the execution, so exclusive_only defaults to True.
Those rows are counted in n_excluded rather than dropped silently.
It costs nothing on the other sources,
which sweep the execution's own processes and stay attributable however busy the worker was.
Failed executions that recorded a measurement are aggregated alongside successful ones. A run that died at 40 GiB is the strongest evidence there is about what the diagnostic needs.
Peaks from different memory sources are never mixed.
Within each group the source contributing the most samples wins,
the rest are counted in n_excluded,
and the winner is reported as memory_source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diagnostic_contains
|
Sequence[str] | None
|
Case-insensitive substring matches on diagnostic slug (OR-combined). |
None
|
provider_contains
|
Sequence[str] | None
|
Case-insensitive substring matches on provider slug (OR-combined). |
None
|
since
|
datetime | None
|
Keep only executions created at or after this naive UTC timestamp. |
None
|
group_by
|
GroupBy
|
|
'diagnostic'
|
exclusive_only
|
bool
|
Drop cgroup readings taken from a container the execution did not have to itself. |
True
|
safety_factor
|
float
|
Multiplier applied to the p95 peak by |
1.3
|
Returns:
| Type | Description |
|---|---|
tuple[ResourceProfile, ...]
|
One profile per group, ordered by provider then diagnostic slug. |
Source code in packages/climate-ref/src/climate_ref/results/resources.py
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | |
select_execution_resources(filters=None)
#
Build the Select over the resource columns on Execution.
Rows are kept when they carry a measurement or when they failed. A failed execution with no measurement is what an out-of-memory kill looks like, and that count is needed to report the bias it introduces.
Ordered by created_at, id ascending so SQL pagination is deterministic across pages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
ResourceFilter | None
|
Restricts the executions considered. |
None
|
Returns:
| Type | Description |
|---|---|
Select[Any]
|
A |