Skip to content

Providers: algorithms in the QGIS Processing toolbox

A provider is both an algorithm namespace and the registration that makes its algorithms visible. Add it explicitly to the application:

from qgis_sdk import QgisSdkPlugin
app = QgisSdkPlugin(id="field_tools", title="Field tools")
app.add_provider(tools) # a Provider declared in your algorithms module

In QGIS, startup registers the owned providers with Processing and unload removes them. Startup rolls back on a duplicate provider ID. Over a context without the Processing capability no provider is registered. runtime.providers and runtime.registered_providers report owned and currently registered providers. Provider registration does not add bridge-callable actions to describe(app).

Annotated markers say what an input means to the host while the wire schema keeps describing the stored value. The aliases are the usual spelling; the long form (Annotated[str, LayerParameter()], Annotated[float, MetresParameter(minimum=1.0)]) describes identically and is how you add a bound. Each kind is complete across hosts (decision-46 point 1): one marker, one widget family in qgis_sdk.ui, one Processing parameter, one x-qgis-sdk annotation on the wire. qgis_sdk.models.parameter_kinds() is the registry the describers, the form rule and the Processing adapter all read.

Spelling Stored Handler receives Processing parameter Widget family
LayerInput str a layer id, opened through Layers QgsProcessingParameterVectorLayer layer
CrsInput str an authority code QgsProcessingParameterCrs crs
Metres float metres, bounded at zero QgsProcessingParameterNumber metres
FileInput(filters=("*.gpkg",)) FileRef a file FileRef, never a path QgsProcessingParameterFile (File) file
DirectoryInput() FileRef a directory FileRef QgsProcessingParameterFile (Folder) directory
FieldInput(of="layer") str a field name of the layer input of names QgsProcessingParameterField(parentLayerParameterName=of) field
Range(0.0, 1.0, step=None) float (or int when both bounds are ints) a number inside the bounds QgsProcessingParameterNumber with min/max range
Colour(alpha=True) str #RRGGBB or #RRGGBBAA QgsProcessingParameterColor colour
Literal["fast", "safe"] str one of the choices QgsProcessingParameterEnum choice
str / int / float / bool itself itself string / number / number / boolean text / integer / number / boolean

A marker on a type it does not fit (Annotated[int, LayerParameter()]), a Literal of non-strings, a FieldInput whose of is not a layer input of the same declaration, or a bare FileRef input without FileInput/DirectoryInput is refused at declaration with the input name. A dataclass or a list input is still refused for an algorithm (a toolbox has no widget for it); an action may declare one. FileRef (qgis_sdk.models) is the branded reference of decision-20: the toolbox mints it from the dialog’s picker through the host authority for the duration of the run, a page sends the ref the host minted and the handler receives the FileRef object, and a wrong-kind ref (a file where a directory was declared) is refused before the handler runs. Resolving a ref to a path from plugin code arrives with the FileInput component of the Form helper.

The bridge builds an AlgorithmContext over the dialog’s feedback and calls the function through the same invoke an action uses, then copies the produced layer’s features into the destination the user chose. That QGIS sink is separate from Algorithms.run’s staged named destinations; the SDK does not verify that the chosen sink is distinct from every input or roll back provider side effects. FlagNoThreading is deliberate: worker-thread execution of these adapters has not been qualified, so the bridge asks QGIS to run on the thread it was qualified on rather than claim a safety it cannot demonstrate.

providers and the bridge stay inside the same rules as the rest of the layer: no QGIS import in qgis_sdk.providers, and the native bridge (qgis_sdk.adapters.qgis.NativeProcessing) is only importable where PyQGIS exists. qgis_sdk.testing.FakeProcessing is the registry double for a pure test of the lifecycle.