craft_parts.state_manager.step_state module

The step state preserves step execution context information.

class craft_parts.state_manager.step_state.MigrationState(**data)[source]

Bases: BaseModel

State information collected when migrating steps.

The migration state contains the paths to the files and directories that have been migrated. This information is used to remove migrated files from shared areas on step cleanup.

Parameters:

data (Any)

directories: set[str]
files: set[str]
marshal()[source]

Create a dictionary containing the part state data.

Return type:

dict[str, Any]

Returns:

The newly created dictionary.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod unmarshal(data)[source]

Create and populate a new state object from dictionary data.

Parameters:

data (dict[str, Any]) – A dictionary containing the data to unmarshal.

Return type:

MigrationState

Returns:

The state object containing the migration data.

write(filepath)[source]

Write state data to disk.

Parameters:

filepath (Path) – The path to the file to write.

Return type:

None

class craft_parts.state_manager.step_state.StepState(**data)[source]

Bases: MigrationState, ABC

Contextual information collected when a step is executed.

The step state contains environmental and project-specific configuration data collected at step run time. Those properties are used to decide whether the step should run again on a new lifecycle execution.

Parameters:

data (Any)

diff_project_options_of_interest(other_project_options)[source]

Return project options that differ.

Take a dictionary of project_options and compare to our own, returning the set of project option names that are different. Both dictionaries are filtered prior to comparison, only relevant options are compared.

Parameters:

other_project_options (dict[str, Any]) – The project options to compare to the project options stored in this state.

Return type:

set[str]

diff_properties_of_interest(other_properties, also_compare=None)[source]

Return properties of interest that differ.

Take a dictionary of properties and compare to our own, returning the set of property names that are different. Both dictionaries are filtered prior to comparison, only relevant properties are compared.

Parameters:
  • other_properties (dict[str, Any]) – The properties to compare to the project options stored in this state.

  • also_compare (Optional[list[str]])

Return type:

set[str]

model_config: ClassVar[ConfigDict] = {'alias_generator': <function StepState.<lambda>>, 'extra': 'ignore', 'frozen': True, 'populate_by_name': True, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

part_properties: dict[str, Any]
project_options: dict[str, Any]
abstract project_options_of_interest(project_options)[source]

Return relevant project options concerning this step.

Parameters:

project_options (dict[str, Any])

Return type:

dict[str, Any]

abstract properties_of_interest(part_properties, *, extra_properties=None)[source]

Return relevant properties concerning this step.

Parameters:
  • part_properties (dict[str, Any])

  • extra_properties (Optional[list[str]])

Return type:

dict[str, Any]

classmethod unmarshal(data)[source]

Create and populate a new state object from dictionary data.

Parameters:

data (dict[str, Any])

Return type:

StepState

craft_parts.state_manager.step_state.validate_hex_string(value)[source]

Ensure that a pydantic model field is hexadecimal string.

Parameters:

value (str)

Return type:

str