Skip to content

Pipeline

Core classes for executing the scene generation pipeline.

s2gos_generator.core.pipeline.SceneGenerationPipeline

SceneGenerationPipeline(config: SceneGenConfig)

Scene generation pipeline with automatic dependency resolution.

This pipeline automatically manages dependencies between scene generation steps, ensuring resources are processed in the correct order.

Initialize the scene generation pipeline.

Parameters:

Name Type Description Default
config SceneGenConfig

Scene generation configuration

required

Attributes

scene_name property

scene_name: str

Get scene name from configuration.

Functions

clear_cache

clear_cache() -> None

Remove the on-disk cache for this scene.

The next call to :meth:run will regenerate all cacheable resources from scratch.

get_resource_dependencies

get_resource_dependencies() -> Dict[str, List[str]]

Get the current resource dependency graph.

Returns:

Type Description
Dict[str, List[str]]

Dictionary mapping resource IDs to their dependencies

initialize

initialize()

Initialize the pipeline - call this before using the pipeline.

run

run(use_cache: bool = True) -> SceneDescription

Execute the complete scene generation pipeline.

Runs all resources registered from the SceneGenConfig and returns the resulting SceneDescription.

Parameters:

Name Type Description Default
use_cache bool

When True (default), skip resources whose config hash and output files match the stored manifest. Set to False to force a full rebuild.

True

Returns:

Type Description
SceneDescription
SceneDescription

instance with complete scene configuration.

visualize_dag

visualize_dag(
    output_path: Optional[Path] = None, format: str = "png"
) -> Optional[Path]

Render the pipeline dependency graph to an image file using Graphviz.

Nodes are colour-coded by resource category (AOI, DEM, landcover, mesh, texture, etc.) and shaped by type (ellipse for AOIs, diamond for meshes, double-octagon for the final scene description). The output file is written next to the scene output directory when output_path is not supplied.

Parameters:

Name Type Description Default
output_path Optional[Path]

Destination path for the rendered image (without extension). Defaults to <scene_output_dir>/<scene_name>_dag.

None
format str

Graphviz output format (e.g. "png", "svg").

'png'

Returns:

Type Description
Optional[Path]

Path to the rendered file, or None if Graphviz is not

Optional[Path]

installed or rendering fails.

s2gos_generator.core.context.SceneResourceContext

SceneResourceContext(
    config: SceneGenConfig,
    combined_user_assets: List = None,
    additional_material_libraries: List = None,
    **kwargs,
)

Resource context for scene generation pipeline execution.

Initialize scene resource context.

Parameters:

Name Type Description Default
config SceneGenConfig

Scene generation configuration

required
combined_user_assets List

List combining config + XML assets

None
additional_material_libraries List

Extra material libraries from XML

None

Attributes

background_aoi_polygon property

background_aoi_polygon

Lazy AOI polygon for the background area, or None if unconfigured.

buffer_aoi_polygon property

buffer_aoi_polygon

Lazy AOI polygon for the buffer area, or None if unconfigured.

coordinate_system property

coordinate_system: CoordinateSystem

Get cached coordinate system for this scene.

Returns:

Type Description
CoordinateSystem

CoordinateSystem instance for this scene's center location

exclusion_zone_geometries property

exclusion_zone_geometries: list

Exclusion zone geometries in scene coordinates, derived from config.

has_background property

has_background: bool

Check if background processing is enabled.

has_buffer property

has_buffer: bool

Check if buffer processing is enabled.

has_hamster property

has_hamster: bool

Check if HAMSTER data integration is enabled.

matched_materials property

matched_materials: dict

Spectral-matching result, lazily loaded.

road_polygons_by_material property

road_polygons_by_material: dict

Merged road footprints per material, derived from the roads list.

Computed once and cached. Each value is the unary_union of all buffered centerlines for that material — the geometry the texture painter needs, without storing it redundantly in the sidecar.

roads property

roads: list

All road segments, lazily loaded from the roads sidecar.

target_aoi_polygon property

target_aoi_polygon

Lazy AOI polygon for the target area.

target_scene_bounds property

target_scene_bounds

Lazy axis-aligned scene-coord clip bounds for the target AOI.

user_assets property

user_assets

Get combined user assets (config + XML assets).

Functions

s2gos_generator.core.assets.SceneAssets dataclass

SceneAssets(
    dem_file: Optional[UPath] = None,
    landcover_file: Optional[UPath] = None,
    mesh_file: Optional[UPath] = None,
    selection_texture_file: Optional[UPath] = None,
    preview_texture_file: Optional[UPath] = None,
    config_file: Optional[UPath] = None,
    scene_description_file: Optional[UPath] = None,
    buffer_dem_file: Optional[UPath] = None,
    buffer_landcover_file: Optional[UPath] = None,
    buffer_mesh_file: Optional[UPath] = None,
    buffer_selection_texture_file: Optional[UPath] = None,
    buffer_preview_texture_file: Optional[UPath] = None,
    background_landcover_file: Optional[UPath] = None,
    background_selection_texture_file: Optional[
        UPath
    ] = None,
    background_preview_texture_file: Optional[UPath] = None,
    vegetation_objects_file: Optional[UPath] = None,
    user_assets_file: Optional[UPath] = None,
    hamster_paths_file: Optional[UPath] = None,
    roads_file: Optional[UPath] = None,
    buildings_objects_file: Optional[UPath] = None,
    sentinel2_file: Optional[UPath] = None,
    matched_materials_file: Optional[UPath] = None,
)

Container for generated scene assets.

Functions

to_dict

to_dict() -> Dict

Convert assets to dictionary.

s2gos_generator.core.resource_registry.ResourceRegistry

ResourceRegistry()

Registry for managing resource definitions.

Functions

get_execution_order

get_execution_order() -> List[str]

Get resources in dependency order using topological sort with cycle detection.

get_resource

get_resource(id: str) -> Resource

Get a resource by ID.

get_resource_list

get_resource_list() -> List[Resource]

Get all registered resources.

register

register(
    id: str,
    dependencies: List[str],
    func: Callable,
    *,
    optional: Optional[List[str]] = None,
)

Register a resource explicitly.

Parameters:

Name Type Description Default
id str

Unique resource identifier.

required
dependencies List[str]

Required dependencies that must run before this resource.

required
func Callable

Resource function to execute.

required
optional Optional[List[str]]

Optional dependencies — added to the required list only if they are already registered when update_scene_dependencies runs.

None

update_scene_dependencies

update_scene_dependencies()

Resolve optional deps and update scene_description dependencies.

s2gos_generator.core.resource_registry.DAGExecutor

DAGExecutor(registry: ResourceRegistry)

Executes resources in dependency order.

Functions

execute

execute(context: SceneResourceContext) -> Dict[str, Any]

Execute all resources in dependency order.