Repository navigation
Python: find state type of step declared as KernelProcessStep[State] (#14734) - #14739
Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
Conversation
…tate] get_generic_state_type returned None for a step that names its state only in the base class, because the type hint of 'state' is still the TypeVar there. Such a step then refused an initial_state, got no default state, got a raw dict when restored, and had its state left out of the saved process state. The concrete type is now read from the pydantic field annotation. Default and restored states are also created for dataclass state types.
MOHAMMED WASIM KHAN (wasim-builds)
requested a review
from a team
as a code owner
November 7, 2026 04:44
MOHAMMED WASIM KHAN (wasim-builds)
temporarily deployed
to
github-app-auth
November 7, 2026 04:44 — with
GitHub Actions
Inactive
This branch was previously deployed
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.
Motivation and Context
A process step that names its state type only in the base class, like
class Counter(KernelProcessStep[CounterState]), was treated as stateless:initial_state=CounterState(...)raisedProcessInvalidConfigurationException: ... the step does not accept a stateKernelProcessStateMetadatastayed a plain dictCaught in #14734 by PRABHU KIRAN VANDRANKI (@VANDRANKI) (thanks for the clear repro and root-cause write-up).
Fixes #14734
Description
get_generic_state_type, when the type hint is still aTypeVar(which happens when parameterized only in the base classKernelProcessStep[TState]), inspectmodel_fields["state"].annotationof the class where Pydantic has resolved the field annotation to the concrete state type. Plain/unparameterizedKernelProcessStepsteps continue to returnNone.ProcessStepBuilder.build_step, instantiate the default state witht_state()and support restoring both Pydantic models and@dataclassstate instances from metadata dictionaries (t_state(**candidate)whenhasattr(t_state, "__fields__") or is_dataclass(t_state)).tests/unit/processes/test_process_types.pycovering parameterized steps, inherited parameterized steps, and unparameterized controls.tests/unit/processes/test_process_step_generic_state.pyverifying default state creation,initial_stateacceptance, metadata restoration, and saved state persistence for both Pydantic and dataclass state types.Contribution Checklist