stratified_packager.processing.algorithm
The Stratified Packager Processing algorithm: orchestration of Phases A/B/C (SPEC §8).
All user-facing messaging inside algorithm execution goes through the
qgis.core.QgsProcessingFeedback instance supplied by the Processing
framework — never the plugin logger (whose records do not reach the algorithm’s log
panel or qgis_process output). Fatal failures raise
qgis.core.QgsProcessingException, the framework’s sanctioned failure path;
per-stratum failures are contained (best-effort policy, SPEC §17) and surface in one
final exception listing the failed strata. Helpers invoked during execution take the
feedback as an explicit parameter.
Build layout: every zip gets its own build root mirroring the zip’s internal layout
(gpkgs at their gpkg_rel paths, data/ and resources/ beside them), so
Qt’s relative-path storage produces portable ./… sources in embedded projects
(SPEC §13) and zip assembly is a plain tree walk. The Phase-A→B/C records and the
per-phase helpers live in the sibling material, dedup, virtual and reporting
modules; this module orchestrates them.
Classes
|
|
- class stratified_packager.processing.algorithm.StratifiedPackagerAlgorithm(*args, **kwargs)[source]
stratified_packager:package— one zipped GeoPackage per stratum (SPEC §1).- classmethod tr(sourceText, disambiguation=None, n=-1)[source]
Get the translation for a string using Qt translation API.
- Parameters:
sourceText (
str) – String for translation.disambiguation (
str|None) – Identifying string for when the same text is used in different roles within the context.n (
int) – Number to support plural forms. https://doc.qt.io/qt-6/i18n-source-translation.html#handle-plural-forms
- Return type:
- Returns:
Translated version of the source text.
- _apply_overwrite_mode(inputs, resolution, report_rows, feedback)[source]
Apply
OVERWRITE_MODEto the bundle map (§10, §15).- Parameters:
inputs (
_Inputs) – The resolved inputs.resolution (
StrataResolution) – The strata resolution.report_rows (
list[RunReportRow]) – Mutable run-report rows (skip rows are appended).feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
dict[str,tuple[StratumSpec,...]]- Returns:
The surviving bundles.
- Raises:
QgsProcessingException – In
errormode when any target exists.
- _build_and_zip(material, builds, warm_builds, workdir, pool, cancel, feedback)[source]
Build every stratum gpkg on this thread, zipping finished bundles in the background.
On
WARM_START_MODE=updateruns the §11 warm pass runs first: every stratum’s warm cache is written and atomically published before any deliverable is built, so an interrupted run still leaves a complete, reusable cache. The deliverables then seed from the fresh cache; a stratum whose cache write failed builds cold. OnWARM_START_MODE=useruns a member whose §11 prefetch landed seeds in place — its cache already sits at the build path.Bundles run in order and their strata in sequence (SPEC §8.4); a bundle’s zip is submitted once its members are written, so the next bundle builds while this one compresses. Cancellation propagates into the in-flight zip jobs.
- Parameters:
material (
_Material) – The run material.builds (
Mapping[str,StratumBuild]) – The stratum builds by sanitized name.warm_builds (
Sequence[StratumBuild]) – The §11 warm-pass builds (empty unlessWARM_START_MODE=update).workdir (
Path) – The run’s build directory.pool (
ThreadPoolExecutor) – The run-scoped background pool.cancel (
Event) – The run’s cancellation event.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
The final build state.
- _build_template(material, workdir, feedback)[source]
Write the §8.1.5 template gpkg once (non-warm-marked whole-export primaries).
Each covered stratum is then seeded by a plain copy of the template; only its partitioned layers (and the per-stratum styles) are written afterwards. The template also becomes the covered layers’ read source (§8.2): a warm-seeded stratum (§11) cannot take the template seed, so it writes these layers per stratum — from the local template copy, not the original source again.
- Parameters:
material (
_Material) – The run material.workdir (
Path) – The run’s build directory.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Raises:
QgsProcessingException – If the template writer fails or a written template table cannot be opened back as the read source.
- Return type:
- _clone(layer)[source]
Clone layer into a standalone read layer (its subset string rides along, §8.2).
- Parameters:
layer (
QgsVectorLayer) – The user’s layer (never mutated).- Return type:
- Returns:
An independent clone whose selection may be freely changed.
- Raises:
QgsProcessingException – If the clone is invalid.
- _collect_layer_name_expressions(layers)[source]
Snapshot and parse-validate the §4
layer_nameexpressions at run start.Consulted only when an embedded project is built. A parse error is the fail-fast; the per-stratum evaluation in
_project_plan()surfaces eval/NULL errors later.- Parameters:
layers (
Sequence[QgsMapLayer]) – Every layer that may appear in an embedded project.- Return type:
- Returns:
Layer id -> non-empty expression text.
- Raises:
QgsProcessingException – If a layer’s expression fails to parse.
- _collect_layers(parameters, context, project, feedback)[source]
Resolve
LAYERSand classify the packaged layers by handling (§4 fixed-by-type).Plugin layers are excluded with a warning — they are reported here, not returned.
- Parameters:
context (
QgsProcessingContext) – The processing context.project (
QgsProject) – The run’s project.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
tuple[list[QgsVectorLayer],list[QgsMapLayer],list[QgsMapLayer]]- Returns:
(vector, payload (local raster/mesh/point-cloud), embedded-only (remote/annotation/live virtual))layers.- Raises:
QgsProcessingException – If a layer’s
excludevariable cannot be coerced to bool while resolving an emptyLAYERS(§5 strict regime).
- _discard_workdir(material, workdir, feedback)[source]
Release the run’s workdir-backed layer handles, then remove the build directory (§10).
The preps’ read layers sit over GeoPackages inside the workdir (staging copies, the whole-export template); while those layers are alive GDAL holds the files open and Windows refuses to delete them. Dropping the references (plus a GC pass for cycles) releases the handles so the removal can succeed. Residue surviving the retries — e.g. a handle a failed run’s traceback still pins — is reported and left behind (best-effort, §17).
- Parameters:
material (
_Material) – The run material; its layer-holding fields are cleared in place.workdir (
Path) – The run’s build directory.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- _emit_run_report(parameters, context, report_rows, feedback)[source]
Write the run-level report (§9.1) into the
REPORTfeature sink.The destination is whatever
REPORTresolves to: a memory table (loaded into the project by the GUI) when no path is given, or a file otherwise. Always produced — onDRY_RUNtoo — independent ofGENERATE_REPORT, which gates only the per-zipreport.csv(§9.2). The sink’s columns are theRunReportRowfields.- Parameters:
parameters (
dict[str|None,Any]) – Raw parameter values (carry theREPORTdestination).context (
QgsProcessingContext) – The processing context.report_rows (
Sequence[RunReportRow]) – The run-report rows, in the intended order.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
The sink destination id (the memory layer id, or the written path).
- Raises:
QgsProcessingException – If QGIS cannot create the sink or accept a row.
- _excluded_fields(layer)[source]
Read the layer’s
excluded_fieldsvariable (§4).- Parameters:
layer (
QgsVectorLayer) – The packaged layer.- Return type:
- Returns:
The excluded field names.
- Raises:
QgsProcessingException – If the variable is not a JSON list of strings.
- _finalize_members(material, members, state, feedback)[source]
Build the embedded project of each successful member (§13, Phase C).
Two failure regimes (SPEC §4 vs §17): assembling the member’s plan evaluates the
layer_nameexpressions — a §4-strict eval error/NULL fails the stratum (the member leaves the succeeded set and its gpkg is discarded). Once the plan exists, an embedded-project write failure is non-fatal degraded delivery (§17): the member’s data gpkg is intact and still ships — without the embedded project — and a warning is pushed. Genuine data failures are contained upstream in the worker pool, not here.- Parameters:
material (
_Material) – The run material.members (
Sequence[StratumSpec]) – The bundle’s successful members.state (
_BuildState) – The pool state.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- _finish_dry_run(material, strata, report_rows, parameters, context, feedback)[source]
Conclude a dry run: report only, no packages (§9.1).
- Parameters:
material (
_Material) – The run material.strata (
Sequence[StratumSpec]) – The surviving strata.report_rows (
list[RunReportRow]) – Mutable run-report rows.parameters (
dict[str|None,Any]) – Raw parameter values (carry theREPORTdestination).context (
QgsProcessingContext) – The processing context.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
The §3 outputs map (no zips).
- _fold_result(state, result, feedback)[source]
Fold one stratum’s write outcome into the build state and the feedback (§9/§11).
- Parameters:
state (
_BuildState) – The build state.result (
StratumWriteResult) – The stratum write result.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- _fold_warm_result(state, result, feedback)[source]
Fold one §11 warm-pass outcome into the build state and the feedback.
Deliverable accounting (
succeeded/failed/layer_results) is untouched: the deliverable pass re-reports every layer (warm-seeded ones aswarm), and a failed cache write only costs that stratum its warm seed — it still builds and ships cold; the missing cache fails the run at the end. The matched fids do fold in: the warm-seeded deliverable reports none for those layers, so the §9.1 orphan union needs the warm pass’s.- Parameters:
state (
_BuildState) – The build state.result (
StratumWriteResult) – The warm-cache write result.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- _fold_zip(state, outcome, feedback)[source]
Fold one bundle’s zip outcome into the build state and the feedback.
- Parameters:
state (
_BuildState) – The build state.outcome (
ZipOutcome) – The zip outcome.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- _layer_write(prep, material, *, to_root='')[source]
Build one (primary) prep’s
LayerWrite.A dedup primary carries every group member’s plan — membership is their union — and every member’s style (the primary’s loads by default). to_root sets the per-stratum
resources/prefix used to rewrite the QML asset paths.- Parameters:
prep (
_LayerPrep) – The (primary) layer prep.material (
_Material) – The run material.to_root (
str) – The stratum’s relative prefix back to its zip root.
- Return type:
- Returns:
The layer write.
- _layout_zip_roots(material, workdir)[source]
Create one zip-mirror build root per bundle and map every member’s build path (§10).
Needs only the bundle layout, so it runs before Phase A — the §11 warm prefetch can then copy cache files straight to their final build paths while Phase A works.
- _make_workdir(inputs, feedback)[source]
Create the run-scoped build directory, sweeping stale leftovers first (§10).
- Parameters:
inputs (
_Inputs) – The resolved inputs.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
The build directory (under the Processing temp folder, or under the output directory when
USE_TEMP_FOLDERis off).
- _maybe_submit_zip(pool, state, material, zip_rel, members, workdir, cancel, feedback)[source]
Finalize a finished bundle (Phase C) and submit its zip to the background pool.
Embedded projects for the successful members, then the per-zip report, then the zip job. A bundle whose members all failed is recorded as a failed zip.
- Parameters:
pool (
ThreadPoolExecutor) – The background pool.state (
_BuildState) – The build state.material (
_Material) – The run material.zip_rel (
str) – The bundle’s zip path (no extension).members (
Sequence[StratumSpec]) – The bundle’s member strata.workdir (
Path) – The run’s build directory.cancel (
Event) – The run’s cancellation event.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- _metadata_payload(layer, inputs)[source]
Serialize the layer’s QMD metadata (§8.1 step 4).
- Parameters:
layer (
QgsMapLayer) – The packaged layer.inputs (
_Inputs) – The resolved inputs.
- Return type:
- Returns:
The QMD XML, or an empty string when metadata is excluded.
- _open_local(gpkg_path, table, label)[source]
Open a staged GeoPackage table as a standalone read layer (§8.2).
- Parameters:
- Return type:
- Returns:
The opened layer.
- Raises:
QgsProcessingException – If the table cannot be opened.
- _phase_a(material, strata, features_by_name, workdir, feedback)[source]
Analysis & staging: methods, staging copies, conditions, payloads, build roots.
- Parameters:
material (
_Material) – The run material being filled.strata (
Sequence[StratumSpec]) – The surviving strata.features_by_name (
Mapping[str,QgsFeature]) – Stratum features keyed by sanitized name.workdir (
Path) – The run’s build directory.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Raises:
QgsProcessingException – Per §4/§7/§8.2 validation rules.
- Return type:
- _phases_b_c(material, strata, *, warm_strata, features_by_name, workdir, report_rows, parameters, context, pool, cancel, feedback)[source]
Build the stratum gpkgs sequentially, embed projects, zip and publish per bundle.
GeoPackage writing stays on this thread (only it may touch QGIS); the background pool zips each finished bundle while the next bundle’s GeoPackages are built (SPEC §8).
- Parameters:
material (
_Material) – The run material.strata (
Sequence[StratumSpec]) – The surviving strata (deliverables;OVERWRITE_MODEapplied).warm_strata (
Sequence[StratumSpec]) – Every resolved stratum — the §11 update pass refreshes all caches, including strata whose deliverable was skip-existing filtered.features_by_name (
Mapping[str,QgsFeature]) – Stratum features keyed by sanitized name.workdir (
Path) – The run’s build directory.report_rows (
list[RunReportRow]) – Mutable run-report rows.parameters (
dict[str|None,Any]) – Raw parameter values (carry theREPORTdestination).context (
QgsProcessingContext) – The processing context.pool (
ThreadPoolExecutor) – The run-scoped background pool.cancel (
Event) – The run’s cancellation event.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
The §3 outputs map.
- Raises:
QgsProcessingException – On cancellation, or at the end when any stratum, zip, or warm-cache write failed (best-effort policy, §17).
Place each bundle’s shared
data/andresources/trees into its zip root (§13/§14).Hardlinked when the filesystem allows, copied otherwise, so embedded projects written beside the gpkgs resolve everything relatively. Runs at the end of Phase A (payloads and style assets are Phase-A products); the roots themselves are laid out earlier by
_layout_zip_roots().
- _prepare_vector_layer(layer, table, plan, inputs, feedback)[source]
Build one vector layer’s Phase-A prep over a plain clone (§8.1).
The read source starts as a clone of layer (its subset string rides along; the user’s layer is never read for data, so its selection and subset stay untouched). Staging happens later, per dedup group, in
_stage_preps()— afterapply_dedup()has merged shared-source layers — so a group shares one staging copy instead of building one per member. Conditions are not materialized here; the per-stratum write computes them lazily against the read source.- Parameters:
layer (
QgsVectorLayer) – The packaged vector layer.table (
str) – Its target table name.plan (
LayerMatchPlan) – Its matching plan.inputs (
_Inputs) – The resolved inputs.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
The prep.
- Raises:
QgsProcessingException – On a clone failure.
- _project_plan(material, member, state)[source]
Assemble one member’s embedded-project plan (§13).
- Parameters:
material (
_Material) – The run material.member (
StratumSpec) – The member stratum.state (
_BuildState) – The pool state (which tables were kept).
- Return type:
- Returns:
The plan.
- _resolve_inputs(parameters, context, project, settings, feedback)[source]
Resolve every input through explicit value > variable > setting > builtin.
- Parameters:
context (
QgsProcessingContext) – The processing context.project (
QgsProject) – The run’s project.settings (
StratifiedPackagerSettings) – The plugin settings.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
The typed inputs.
- Raises:
QgsProcessingException – On unusable stored defaults or missing requirements (§3 footnotes).
- _resolve_methods(inputs, project, ordered, feedback)[source]
Resolve every packaged layer’s matching method (§4); a full-only run is all whole-export.
- Parameters:
inputs (
_Inputs) – The resolved inputs.project (
QgsProject) – The run’s project.ordered (
Sequence[QgsVectorLayer]) – The packaged vector layers in tree order.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
One plan per layer id.
- Raises:
QgsProcessingException – Per the §4 rules, or if the relation manager is absent.
- _resolve_strat_layer(parameters, context, project, reader)[source]
Resolve
STRATIFICATION_LAYER(explicit, else the project variable’s layer id).- Parameters:
parameters (dict[str | None, Any]) – Raw parameter values.
context (QgsProcessingContext) – The processing context.
project (QgsProject) – The run’s project.
reader (params.InputReader) – The input reader.
- Return type:
QgsVectorLayer | None
- Returns:
The stratification layer, or
None.
- _resolve_strata_validated(inputs, project, feedback)[source]
Validate the stratification layer and resolve the strata (§6, §15).
- Parameters:
inputs (
_Inputs) – The resolved inputs.project (
QgsProject) – The run’s project.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
The strata resolution.
- Raises:
QgsProcessingException – Per the §6 strict rules (including the empty-selection fail-fast, raised by
resolve_strata()) and §3 footnote ¹.
- _scan_extra_dir(inputs, bundles, feedback)[source]
Reject EXTRA_DIR entries colliding with reserved zip content (§10, §15).
- Parameters:
inputs (
_Inputs) – The resolved inputs.bundles (
Mapping[str,tuple[StratumSpec,...]]) – The surviving bundles.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Raises:
QgsProcessingException – Listing every conflicting entry.
- Return type:
- _sld_text(layer)[source]
Serialize the layer’s SLD, best-effort (§8.1).
Prefer
exportSldStyleV3()(QGIS 3.44+; returns the document); below QGIS 3.44 it is absent, soexcept AttributeErrorfalls back to the deprecatedexportSldStyleV2(3.30). This guarded fallback is the sole sanctionedqgis.corebehavioral fallback (SPEC §1.1); it keeps V3 from raising the support floor.Unlike the QML (
exportNamedStyle()), the SLD is serialized in full — it is intentionally not scoped toSTYLE_CATEGORIES, because the SLD export API offers no category option and SLD represents only symbology and labeling. The category-filteredstyleQMLis the authoritative artifact (SPEC §13).- Parameters:
layer (
QgsMapLayer) – The packaged layer.- Return type:
- Returns:
The SLD XML (possibly empty or invalid; the caller guards validity).
- _stage_layer(layer, plan, stage_providers)[source]
Resolve a partitioned layer’s staging decision (§8.2), wrapping the strict failure.
- Parameters:
layer (
QgsVectorLayer) – The packaged layer.plan (
LayerMatchPlan) – Its matching plan.stage_providers (
Collection[str]) – The resolvedSTAGE_PROVIDERSprovider keys.
- Return type:
- Returns:
Whether to stage the layer into a per-layer GeoPackage.
- Raises:
QgsProcessingException – If the stage variable is neither boolean nor
auto.
- _stage_prep(prep, group, material, real_features, staging_dir, feedback)[source]
Build one staging GeoPackage and swap prep’s read source onto it (§8.2).
The staged copy must be a superset of every read taken against it: the union of every group member’s matches across all strata — or all features when
EXPORT_FULL_PACKAGEis on, since the<full>stratum reads the whole staged copy.- Parameters:
prep (
_LayerPrep) – The group primary (or ungrouped) prep; mutated to read the staged copy.group (
Sequence[_LayerPrep]) – Every prep sharing the table (just prep when ungrouped).material (
_Material) – The run material.real_features (
Sequence[QgsFeature]) – The real strata features.staging_dir (
Path) – The directory holding per-layer staging GeoPackages.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Raises:
QgsProcessingException – On a staging write or transform failure.
- Return type:
- _stage_preps(material, real_features, staging_dir, feedback, *, skip_warm_staged)[source]
Stage the read sources that resolve
stage=true— once per dedup group (§8.2).Runs after
apply_dedup(), so a group of shared-source layers stages a single copy through its primary (whose read layer already carries the merged field union and cleared subset); ungrouped layers stage individually. Whole-export preps are skipped — the §8.1.5 template is their staged form. With skip_warm_staged, a group whose every member is warm-marked is not staged either: on aWARM_START_MODE=userun whose caches all passed the §11 pre-scan, nothing ever reads such a group’s staged copy.- Parameters:
material (
_Material) – The run material (primary preps mutated in place).real_features (
Sequence[QgsFeature]) – The real strata features (a staging copy unions across them).staging_dir (
Path) – The directory holding per-layer staging GeoPackages.feedback (
QgsProcessingFeedback) – Execution feedback channel.skip_warm_staged (
bool) – Whether fully-warm groups skip staging.
- Raises:
QgsProcessingException – On a bad stage variable, a staging write failure, or cancellation.
- Return type:
- _stratum_build(stratum, material, features_by_name)[source]
Assemble one stratum’s deliverable build plan (§8.3 step-3 ordering).
Layer order: warm-marked first, the whole-export template layers, then the partitioned layers. A dedup group contributes one layer (the primary’s), carrying every member’s plan and style.
WARM_START_MODE=updatedeliverables seed from the warm cache the §11 warm pass just wrote, exactly like aWARM_START_MODE=userun.- Parameters:
stratum (
StratumSpec) – The stratum.material (
_Material) – The run material.features_by_name (
Mapping[str,QgsFeature]) – Stratum features keyed by sanitized name (<full>absent).
- Return type:
- Returns:
The build plan.
- _style_documents(layer, inputs, feedback)[source]
Serialize the layer’s style: QML for the selected categories, SLD best-effort (§8.1).
- Parameters:
layer (
QgsMapLayer) – The packaged layer.inputs (
_Inputs) – The resolved inputs.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
(qml, sld)— both empty when styles are excluded.
- _submit_warm_prefetch(material, strata, pool, cancel)[source]
Queue background copies of the §11 warm caches to their build paths (warm runs only).
Submitted before Phase A, so a (possibly remote) cache file arrives while layers are prepared and staged; the deliverable pass then seeds in place instead of copying on the critical path. Best-effort: a failed or unfinished copy falls back to the normal seed-time copy from the original cache file.
- Parameters:
material (
_Material) – The run material (bundle layout already computed).strata (
Sequence[StratumSpec]) – The surviving strata (<full>included when it is exported).pool (
ThreadPoolExecutor) – The background pool.cancel (
Event) – The run’s cancellation event.
- Return type:
- _sweep_stale_workdirs(output_dir, feedback)[source]
Best-effort removal of day-old build directories a crashed run left behind (§10).
Only siblings past
_STALE_WORKDIR_AGEare touched — a younger.stratified_build_*directory could belong to a run still executing against the same output directory.- Parameters:
output_dir (
Path) – The run’s output directory.feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- _tree_ordered(project, layers)[source]
Order vector layers by layer-tree order (§12/§15 tie-breaking).
- Parameters:
project (
QgsProject) – The run’s project.layers (
Sequence[QgsVectorLayer]) – The packaged vector layers.
- Return type:
- Returns:
The ordered layers (tree order; unlisted ones keep input order).
- _tree_ordered_any(project, layers)[source]
Order any layers by layer-tree order.
- Parameters:
project (
QgsProject) – The run’s project.layers (
Sequence[QgsMapLayer]) – The layers to order.
- Return type:
- Returns:
The ordered layers (tree order; unlisted ones keep input order).
- _validate_warm_inputs(inputs)[source]
Enforce the §11 warm-start requirements at run start.
- Parameters:
inputs (
_Inputs) – The resolved inputs.- Raises:
QgsProcessingException – On a missing directory, an uncoercible
warm_markedvalue, or an empty warm-marked layer set.- Return type:
- _warm_cache_build(stratum, material, features_by_name, build_dir, warm_dir)[source]
Assemble one stratum’s §11 warm-pass build plan (
WARM_START_MODE=update).A fresh gpkg holding only the warm-marked primaries, assembled under build_dir and snapshot into the warm cache after its last layer lands. Empty warm tables are always kept — the cache stays complete regardless of
KEEP_EMPTY_LAYERS, which the deliverable pass applies when it seeds from the cache.- Parameters:
stratum (
StratumSpec) – The stratum.material (
_Material) – The run material.features_by_name (
Mapping[str,QgsFeature]) – Stratum features keyed by sanitized name (<full>absent).build_dir (
Path) – The workdir subdirectory holding the warm-pass builds.warm_dir (
Path) – The warm-cache directory (snapshot destination).
- Return type:
- Returns:
The build plan.
- _warm_covers_all_builds(material, strata, feedback)[source]
Pre-scan the §11 warm caches to decide whether warm-covered staging is skippable.
On a
WARM_START_MODE=userun a fully-warm dedup group’s staged copy is only ever read by a per-stratum cold fallback, so staging it is pure waste unless some stratum will actually fall back. Run the seed-time completeness check (warm_rejection()) against every build’s cache file up front: all usable → staging of fully-warm groups is skipped (§8.2); any rejection → staging proceeds and the run is warned once.- Parameters:
material (
_Material) – The run material (dedup applied, warm ids resolved).strata (
Sequence[StratumSpec]) – The surviving strata (<full>included when it is exported).feedback (
QgsProcessingFeedback) – Execution feedback channel.
- Return type:
- Returns:
Whether every build’s warm cache passes the §11 completeness check.
- _with_full_package(inputs, project, resolution)[source]
Append the
<full>pseudo-stratum whenEXPORT_FULL_PACKAGEis on (§3).- Parameters:
inputs (
_Inputs) – The resolved inputs.project (
QgsProject) – The run’s project (supplies the default basename).resolution (
StrataResolution) – The strata resolution.
- Return type:
- Returns:
The resolution, possibly extended by the full package.
- Raises:
QgsProcessingException – On an invalid full-package path, or on any §6.5/§6.6 collision the re-bundling detects (case-variant zip paths, gpkg paths colliding inside a bundle the full package joins).
- _zip_job(material, zip_rel, workdir)[source]
Assemble one bundle’s zip job from its build root (§10).
- initAlgorithm(configuration=None)[source]
Declare the SPEC §3 inputs and outputs, defaults pre-resolved (SPEC §5).
- processAlgorithm(parameters, context, feedback)[source]
Run the algorithm: validation → Phase A → Phase B/C → report + outputs.
- Parameters:
parameters (dict[str | None, Any]) – Input parameter values, keyed by parameter name.
context (QgsProcessingContext) – Context in which the algorithm runs.
feedback (QgsProcessingFeedback | None) – The sole channel for user-facing messages, progress reporting, and cancellation during execution.
- Return type:
dict[str, Any]
- Returns:
Output value map, keyed by output name (SPEC §3 declared outputs).
- Raises:
qgis.core.QgsProcessingException – On a fatal error that must abort the run, and at the end of a best-effort run in which any stratum failed (listing the failed strata).
- stratified_packager.processing.algorithm._place(source, destination)[source]
Materialize source at destination (hardlink when possible, copy otherwise).
- stratified_packager.processing.algorithm._LAYER_TYPE_TOKENS: dict[Qgis.LayerType, str] = {qgis.core.Qgis.LayerType.Mesh: 'mesh', qgis.core.Qgis.LayerType.PointCloud: 'point-cloud', qgis.core.Qgis.LayerType.Raster: 'raster'}
§9.2
layer_typetokens of the payload-capable layer types.
- stratified_packager.processing.algorithm._POOL_WIDTH: Final = 2
Background pool width (SPEC §8.4).
One thread keeps zip packaging ahead of the sequential builds — a bundle’s zip is a single DEFLATE stream that finishes well within the next bundle’s build time, so jobs never queue (measured on the 94-zip field project: the pool never held more than one active zip) — and the second overlaps the §11 warm-cache prefetch with Phase A.
- stratified_packager.processing.algorithm._RESERVED_EXTRA_ROOTS: tuple[str, ...] = ('data', 'resources')
Zip-root directory names reserved for the packager’s own payloads (SPEC §10).
- stratified_packager.processing.algorithm._SQLITE_SIDECAR_SUFFIXES: tuple[str, ...] = ('-wal', '-shm', '-journal')
SQLite sidecar suffixes excluded from zips (checkpointed away beforehand, SPEC §10).
- stratified_packager.processing.algorithm._STALE_WORKDIR_AGE: Final = 86400.0
Minimum age in seconds before a leftover
.stratified_build_*directory from an earlier run is swept at run start (§10); younger siblings could belong to a live concurrent run against the same output directory.