Class: QgsProcessingModelChildAlgorithm

class qgis.core.QgsProcessingModelChildAlgorithm

Bases: QgsProcessingModelComponent

Child algorithm representing a single component of a QgsProcessingModelAlgorithm.

New in version 3.0.

QgsProcessingModelChildAlgorithm(algorithmId: str = ‘’) Constructor for QgsProcessingModelChildAlgorithm. The algorithmId parameter should be set to a QgsProcessingAlgorithm algorithm ID.

QgsProcessingModelChildAlgorithm(other: QgsProcessingModelChildAlgorithm)

Methods

addParameterSources

Adds a parameter source.

algorithm

Returns the underlying child algorithm, or None if a matching algorithm is not available.

algorithmId

Returns the underlying child algorithm's ID.

asPythonCode

Attempts to convert the child to executable Python code, and returns a list of the generated lines of code.

childId

Returns the child algorithm's unique ID string, used the identify this child algorithm within its parent model.

clone

rtype:

QgsProcessingModelChildAlgorithm

comment

rtype:

QgsProcessingModelComment

configuration

Returns the child algorithm's configuration map.

copyNonDefinitionProperties

Copies all non-specific definition properties from the other component definition.

copyNonDefinitionPropertiesFromModel

Copies all non-specific definition properties from the the matching component from a model.

dependencies

Returns the list of child algorithms from the parent model on which this algorithm is dependent.

generateChildId

Automatically generates a unique childId() for the algorithm, avoiding child IDs which are already present in model.

isActive

Returns True if the child algorithm is active.

loadVariant

Loads this child from a QVariant.

modelOutput

Returns the final model output with matching name.

modelOutputs

Returns the map of final model outputs which are generated by this child algorithm.

parameterSources

Returns a map of parameter sources.

reattach

Attempts to re-attach the child to the algorithm specified by ``algorithmId``().

removeModelOutput

Removes an existing output from the final model outputs.

restoreCommonProperties

Restores the component properties from a QVariantMap.

saveCommonProperties

Saves the component properties to a QVariantMap.

setActive

Sets whether the child algorithm is active.

setAlgorithmId

Sets the underlying child algorithm's ID.

setChildId

Sets the child algorithm's unique id string, used the identify this child algorithm within its parent model.

setComment

param comment:

setConfiguration

Sets the child algorithm's configuration map.

setDependencies

Sets the list of child algorithms from the parent model on which this algorithm is dependent.

setModelOutputs

Sets the map of final model outputs which are generated by this child algorithm.

setParameterSources

Sets the map of parameter sources.

toVariant

Saves this child to a QVariant.

addParameterSources(self, name: str, source: Iterable[QgsProcessingModelChildParameterSource])

Adds a parameter source. The name argument should match one of the child algorithm’s parameter names, and the sources argument is used to set the sources for that parameter.

Any existing parameter sources with matching name will be replaced.

Parameters:
algorithm(self) QgsProcessingAlgorithm

Returns the underlying child algorithm, or None if a matching algorithm is not available.

See also

reattach()

See also

algorithmId()

Return type:

QgsProcessingAlgorithm

algorithmId(self) str

Returns the underlying child algorithm’s ID.

See also

algorithm()

See also

setAlgorithmId()

Return type:

str

asPythonCode(self, outputType: QgsProcessing.PythonOutputType, extraParameters: Dict[str, str], currentIndent: int, indentSize: int, friendlyChildNames: Dict[str, str], friendlyOutputNames: Dict[str, str]) List[str]

Attempts to convert the child to executable Python code, and returns a list of the generated lines of code.

The outputType argument specifies the type of script to generate.

Additional parameters to be passed to the child algorithm are specified in the extraParameters argument.

The currentIndent and indentSize are used to set the base line indent and size of further indented lines respectively.

The friendlyChildNames argument gives a map of child id to a friendly algorithm name, to be used in the code to identify that algorithm instead of the raw child id.

Parameters:
  • outputType (QgsProcessing.PythonOutputType) –

  • extraParameters (Dict[str) –

  • currentIndent (int) –

  • indentSize (int) –

  • friendlyChildNames (Dict[str) –

  • friendlyOutputNames (Dict[str) –

Return type:

List[str]

childId(self) str

Returns the child algorithm’s unique ID string, used the identify this child algorithm within its parent model.

See also

setChildId()

Return type:

str

clone(self) QgsProcessingModelChildAlgorithm
Return type:

QgsProcessingModelChildAlgorithm

comment(self) QgsProcessingModelComment
Return type:

QgsProcessingModelComment

configuration(self) Dict[str, Any]

Returns the child algorithm’s configuration map.

This map specifies configuration settings which are passed to the algorithm, allowing it to dynamically adjust its initialized parameters and outputs according to this configuration. This allows child algorithms in the model to adjust their behavior at run time according to some user configuration.

Return type:

Dict[str, Any]

copyNonDefinitionProperties(self, other: QgsProcessingModelComponent)

Copies all non-specific definition properties from the other component definition.

This includes properties like the size and position of the component, but not properties like the specific algorithm or input details.

New in version 3.14.

copyNonDefinitionPropertiesFromModel(self, model: QgsProcessingModelAlgorithm)

Copies all non-specific definition properties from the the matching component from a model.

This includes properties like the size and position of the component, but not properties like the specific algorithm or input details.

New in version 3.14.

Parameters:

model (QgsProcessingModelAlgorithm) –

dependencies(self) List[QgsProcessingModelChildDependency]

Returns the list of child algorithms from the parent model on which this algorithm is dependent.

Return type:

List[QgsProcessingModelChildDependency]

generateChildId(self, model: QgsProcessingModelAlgorithm)

Automatically generates a unique childId() for the algorithm, avoiding child IDs which are already present in model.

See also

childId()

See also

setChildId()

Parameters:

model (QgsProcessingModelAlgorithm) –

isActive(self) bool

Returns True if the child algorithm is active.

See also

setActive()

Return type:

bool

loadVariant(self, child: Any) bool

Loads this child from a QVariant.

See also

toVariant()

Parameters:

child (Any) –

Return type:

bool

modelOutput(self, name: str) QgsProcessingModelOutput

Returns the final model output with matching name. If no output exists with the name, a new one will be created and returned.

If child model outputs are altered by this method, QgsProcessingModelAlgorithm.updateDestinationParameters() must be called on the parent model.

See also

modelOutputs()

Parameters:

name (str) –

Return type:

QgsProcessingModelOutput

modelOutputs(self) Dict[str, QgsProcessingModelOutput]

Returns the map of final model outputs which are generated by this child algorithm. The keys are the output names from this child algorithm. Only outputs which are part of the final outputs from the model are included in this map.

See also

modelOutput()

Return type:

Dict[str, QgsProcessingModelOutput]

parameterSources(self) object

Returns a map of parameter sources. The keys are the child algorithm parameter names, the values are the sources for that parameter.

Return type:

object

reattach(self) bool

Attempts to re-attach the child to the algorithm specified by ``algorithmId``().

This can be run to relink the child to algorithms from providers which were not originally available for the model to link to.

Returns True if the algorithm was successfully reattached.

See also

algorithm()

See also

setAlgorithmId()

Return type:

bool

removeModelOutput(self, name: str) bool

Removes an existing output from the final model outputs.

QgsProcessingModelAlgorithm.updateDestinationParameters() must be called on the parent model.

See also

modelOutputs()

New in version 3.2.

Parameters:

name (str) –

Return type:

bool

restoreCommonProperties(self, map: Dict[str, Any])

Restores the component properties from a QVariantMap.

saveCommonProperties(self, map: Dict[str, Any])

Saves the component properties to a QVariantMap.

setActive(self, active: bool)

Sets whether the child algorithm is active.

See also

isActive()

Parameters:

active (bool) –

setAlgorithmId(self, algorithmId: str) bool

Sets the underlying child algorithm’s ID. This should be set to an existing QgsProcessingAlgorithm algorithm ID.

Returns True if the algorithm was successfully set.

See also

reattach()

See also

algorithm()

See also

algorithmId()

Parameters:

algorithmId (str) –

Return type:

bool

setChildId(self, id: str)

Sets the child algorithm’s unique id string, used the identify this child algorithm within its parent model.

See also

childId()

Parameters:

id (str) –

setComment(self, comment: QgsProcessingModelComment)
Parameters:

comment (QgsProcessingModelComment) –

setConfiguration(self, configuration: Dict[str, Any])

Sets the child algorithm’s configuration map.

This map specifies configuration settings which are passed to the algorithm, allowing it to dynamically adjust its initialized parameters and outputs according to this configuration. This allows child algorithms in the model to adjust their behavior at run time according to some user configuration.

See also

configuration()

Parameters:

configuration (Dict[str) –

setDependencies(self, dependencies: Iterable[QgsProcessingModelChildDependency])

Sets the list of child algorithms from the parent model on which this algorithm is dependent.

See also

dependencies()

Parameters:

dependencies (Iterable[QgsProcessingModelChildDependency]) –

setModelOutputs(self, outputs: Dict[str, QgsProcessingModelOutput])

Sets the map of final model outputs which are generated by this child algorithm. Only outputs which are part of the final outputs from the model should be included in this map.

If child model outputs are altered by this method, QgsProcessingModelAlgorithm.updateDestinationParameters() must be called on the parent model.

See also

modelOutputs()

Parameters:

outputs (Dict[str) –

setParameterSources(self, sources: object)

Sets the map of parameter sources. The keys are the child algorithm parameter names, the values are the sources for that parameter.

Parameters:

sources (object) –

toVariant(self) Any

Saves this child to a QVariant.

See also

loadVariant()

Return type:

Any