Repository navigation
feat(planning): granular step-level execution planning for Stage.META - #692
Conversation
- Route outstanding checks per episode directly to SelectedRegisteredSteps - Treat episodes quarantined by settled critical checks as owing nothing in Stage.META - Group episodes by owed steps in batch and direct stage execution - Add tests for check addition, critical retuning, and batch grouping Closes Hebbian-Robotics#690
|
| if missing: | ||
| outstanding_stages.add(stage) | ||
| outstanding_steps.extend(missing) | ||
| if not quarantined_by_settled_gate: |
There was a problem hiding this comment.
Quarantine blocks diagnostic checks
When a settled critical check has quarantined an episode, this gate removes every check that still owes work. That includes default diagnostic checks, which the runner allows to run after quarantine. A default check that failed or was added later never records its evidence. Keep those checks in the plan.
Knowledge Base Used: Stage planning and execution
| for steps, group_uris in uris_by_steps.items(): | ||
| group_item_sizes = {u: item_sizes[u] for u in group_uris} | ||
| group_batch_count = ( | ||
| int(batch_count) | ||
| if batch_count is not None | ||
| else min(DEFAULT_BATCH_COUNT_LIMIT, len(group_item_sizes)) | ||
| ) | ||
| planned = plan_batches( | ||
| group_item_sizes, | ||
| batch_count=group_batch_count, | ||
| stagger_interval_s=DEFAULT_STAGGER_INTERVAL_S, |
There was a problem hiding this comment.
batch_count now applies to each owed-step group rather than the whole stage. With batch_count=1, three step groups create three worker tasks; the default limit of four can also be exceeded. This adds workers and stagger delay beyond what the caller requested. Divide the stage-wide batch allowance among the groups.
Knowledge Base Used: Stage planning and execution
kstonekuan
left a comment
There was a problem hiding this comment.
Thanks, the approach matches the spec and the quarantine rule is right. Three structural changes before I merge:
- Template:
step_names_by_uri=locals().get("stage_steps_by_uri")depends on whether the filter snippet was spliced in. Setstage_steps_by_uri = Noneat the top ofplan()and pass it directly. plan_stage_batches: the new branch copies the file-size lookup and bin-packing block. Size the URIs once in the existing path, then bin-pack each step group with the same code, so there is one sizing path and one stagger rule.- One owner for the per-stage step filter:
run_stages_directlyandoutstanding_stage_urisboth derive "outstanding steps for this stage" fromplan.outstanding_stepsand_registered_step_stages(). Put that in one helper instage_planning.pyand call it from both.
…ching - Set stage_steps_by_uri = None at top of plan() template and pass directly - Unify sizing and bin-packing in plan_stage_batches into single path and stagger rule - Extract outstanding_steps_for_stage helper in stage_planning.py called by both planning and execution
|
Thanks for the review @kstonekuan,Addressed all three structural points:
|
kstonekuan
left a comment
There was a problem hiding this comment.
LGTM, thanks for the quick rework. Full suite passes merged onto main. Merging.
|
Thank you very much @kstonekuan for review and merging this pr , now I can solve one more bug |
Resolves #690
Summary
When new checks are registered or check versions/parameters are retuned, planning for
Stage.METApreviously operated at a binary stage level: any unsettled check causedStage.METAto execute every check on every episode. Additionally, checks skipped downstream of a critical check quarantine never become settled in catalog history, which caused quarantined episodes to be continuously re-planned forStage.META.Per maintainer guidance in #690:
OutstandingStages.outstanding_stepsinto the existing step-selection machinery (SelectedRegisteredSteps), with no second filter inside_process_steps.Stage.METAunless that critical check itself changes identity (retuning).step_names_by_uri), carryingstep_namesintoprocess_stage_batch.Changes
src/hflow/stage_planning.py:plan_outstanding_stages, inspectepisodes_latestfor quarantine status (quarantined,quarantine_tags_json) and critical check identities.Stage.META.outstanding_steps.outstanding_stage_uris, support_stage_steps_by_urito track steps owed per URI for the requested stage.src/hflow/stage_execution.py:PlannedStageBatch, addstep_names: NotRequired[list[str] | None].plan_stage_batches, acceptstep_names_by_urito partition URIs by identical required step subsets before batching.run_stages_directly, partition URIs by owed step names and pass_registered_step_selection=SelectedRegisteredSteps(frozenset(steps)).src/hflow/runtime/_templates.py:OUTSTANDING_PLAN_FILTER_TEMPLATE, collectstage_steps_by_uriand supply it toplan_stage_batches.process_batch, passbatch.get("step_names")toprocess_stage_batch(..., step_names=stage_step_names).tests/test_stage_planning.py: AddedTestGranularStepPlanningForMetatesting that adding a check only reruns that check on already-settled episodes and skips quarantined episodes, and that retuning a critical check re-evaluates the quarantined episode.tests/test_stage_execution.py: Addedtest_batch_lane_groups_by_step_namesto verify batch planning partitions items by owed step subsets.Verification
uv run ruff check&uv run ruff format --checkpassed cleanly (323 files formatted).test_runtime_deploy.py,test_stage_execution.py,test_stage_planning.py) passed.