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: YamlModel

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.

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) –

class Config[source]

Bases: object

Pydantic model configuration.

alias_generator()
allow_mutation = False
allow_population_by_field_name = True
extra = 'ignore'
validate_assignment = True
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]

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