craft_parts.state_manager.state_manager module¶
Part crafter step state management.
- class craft_parts.state_manager.state_manager.StateManager(*, project_info, part_list, ignore_outdated=None)¶
Bases:
objectKeep track of lifecycle execution state.
The State Manager tells whether a step should run based on current state information. The state database is initialized from state on disk, and after that it’s maintained only in memory.
- Parameters:
project_info (
ProjectInfo) – The project information.part_list (
list[Part]) – A list of this project’s parts.ignore_outdated (
list[str] |None) – A list of file patterns to ignore when testing for outdated files.
- check_if_dirty(part, step)¶
Verify whether a step is dirty.
A step is considered to be dirty if relevant properties or project options have changed since the step was executed. This means the step needs to be cleaned and run again. This is in contrast to an “outdated” step, which typically doesn’t need to be cleaned, just updated with files from an earlier step in the lifecycle.
- Parameters:
- Return type:
DirtyReport|None- Returns:
A class:DirtyReport if the step is outdated, None otherwise.
- check_if_outdated(part, step)¶
Verify whether a step is outdated.
A step is considered to be outdated if an earlier step in the lifecycle has been run more recently, or if the source code changed on disk. This means the step needs to be updated by taking modified files from the previous step. This is in contrast to a “dirty” step, which must be cleaned and run again.
- Parameters:
- Return type:
OutdatedReport|None- Returns:
An class:OutdatedReport if the step is outdated, None otherwise.
- clean_part(part, step)¶
Remove the state for this and later steps in the given part.
- get_outdated_dirs(part)¶
Get the list of outdated directories for this part.
- Parameters:
part (
Part) – The part being processed.- Return type:
list[str] |None- Returns:
The list of outdated directories from the part’s pull step.
- get_outdated_files(part)¶
Get the list of outdated files for this part.
- Parameters:
part (
Part) – The part being processed.- Return type:
list[str] |None- Returns:
The list of outdated files from the part’s pull step.
- get_step_state_overlay_hash(part, step)¶
Get the overlay hash from the step state.
- has_step_run(part, step)¶
Determine if a given step of a given part has already run.
- mark_step_updated(part, step)¶
Mark the given part and step as updated.
- project_vars(part, step)¶
Obtain the project variables for a given part and step.
- Parameters:
- Return type:
ProjectVarInfo|None- Returns:
The project variables from the last execution.
- set_state(part, step, *, state)¶
Set the state of the given part and step.
- should_step_run(part, step)¶
Determine if a given step of a given part should run.
- A given step should run if:
it hasn’t already run
it’s dirty
it’s outdated
either (1), (2), or (3) apply to any earlier steps in the part’s lifecycle.