Class: QgsProcessingModelAlgorithm¶
-
class
qgis.core.
QgsProcessingModelAlgorithm
(name: str = '', group: str = '', groupId: str = '')¶ Bases:
QgsProcessingAlgorithm
Constructor for QgsProcessingModelAlgorithm.
Model based algorithm with processing.
New in version 3.0.
- Parameters
name (str = '') –
group (str = '') –
groupId –
-
class
VariableDefinition
(value: Any = None, source: QgsProcessingModelChildParameterSource = QgsProcessingModelChildParameterSource.fromStaticValue(QVariant()), description: str = '')¶ Bases:
sip.wrapper
Constructor for a new VariableDefinition with the specified
value
and original parametersource
, anddescription
.QgsProcessingModelAlgorithm.VariableDefinition(QgsProcessingModelAlgorithm.VariableDefinition)
Definition of a expression context variable available during model execution.
New in version 3.0.
- Parameters
value (Any = None) –
source (
QgsProcessingModelChildParameterSource
= QgsProcessingModelChildParameterSource.fromStaticValue(QVariant())) –description (str = '') –
-
description
¶
-
source
¶
-
value
¶
-
activateChildAlgorithm
(self, id: str) → bool¶ Attempts to activate the child algorithm with matching
id
. If any child algorithms on which the child depends are not active, then the child will not be activated and false will be returned.See also
- Parameters
id (str) –
- Return type
bool
-
addChildAlgorithm
(self, algorithm: QgsProcessingModelChildAlgorithm) → str¶ Adds a new child
algorithm
to the model. If a child algorithm already exists in the model with the same child ID thenalgorithm
will be assigned a new autogenerated unique ID. The assigned child ID will be returned.See also
See also
See also
See also
- Parameters
algorithm (QgsProcessingModelChildAlgorithm) –
- Return type
str
-
addModelParameter
(self, definition: QgsProcessingParameterDefinition, component: QgsProcessingModelParameter)¶ Adds a new parameter to the model, with the specified
definition
and graphicalcomponent
. Ownership ofdefinition
is transferred to the model.See also
See also
- Parameters
definition (QgsProcessingParameterDefinition) –
component (QgsProcessingModelParameter) –
-
addOutput
()¶
-
addParameter
()¶
-
asPythonCode
(self) → str¶ Attempts to convert the model to executable Python code.
- Return type
str
-
asPythonCommand
(self, parameters: Dict[str, Any], context: QgsProcessingContext) → str¶ - Parameters
parameters (Dict[str) –
context (QgsProcessingContext) –
- Return type
str
-
availableSourcesForChild
(self, childId: str, parameterTypes: Iterable[str] = [], outputTypes: Iterable[str] = [], dataTypes: Iterable[int] = []) → object¶ Returns a list of possible sources which can be used for the parameters for a child algorithm in the model. Returned sources are those which match either one of the specified
parameterTypes
(see QgsProcessingParameterDefinition.type() ) or one of the specifiedoutputTypes
(see QgsProcessingOutputDefinition.type() ). If specified, an optional list ofdataTypes
can be used to filter the returned sources to those with compatible data types for the parameter/outputs.- Parameters
childId (str) –
parameterTypes (Iterable[str] = []) –
outputTypes (Iterable[str] = []) –
dataTypes (Iterable[int] = []) –
- Return type
object
-
canExecute
(self) → Tuple[bool, str]¶ - Return type
Tuple[bool, str]
-
childAlgorithm
(self, id: str) → QgsProcessingModelChildAlgorithm¶ Returns the child algorithm with matching
id
. If no child algorithm exists with this ID a new algorithm will be added to the model and returned.See also
See also
- Parameters
id (str) –
- Return type
-
childAlgorithms
(self) → object¶ Returns the map of child algorithms contained in the model. The keys are the child algorithm ids (see QgsProcessingModelAlgorithm.ChildAlgorithm.childId()).
See also
See also
See also
- Return type
object
-
childAlgorithmsDependOnParameter
(self, name: str) → bool¶ Returns true if any child algorithms depend on the model parameter with the specified
name
.See also
- Parameters
name (str) –
- Return type
bool
-
createExpressionContextScopeForChildAlgorithm
(self, childId: str, context: QgsProcessingContext, modelParameters: Dict[str, Any] = {}, results: Dict[str, Any] = {}) → QgsExpressionContextScope¶ Creates a new expression context scope for a child algorithm within the model.
See also
- Parameters
childId (str) –
context (QgsProcessingContext) –
modelParameters (Dict[str) –
results (Dict[str) –
- Return type
-
createInstance
(self) → QgsProcessingAlgorithm¶ - Return type
-
deactivateChildAlgorithm
(self, id: str)¶ Deactivates the child algorithm with matching
id
. All other child algorithms which depend on the child algorithm will also be deactivated.See also
See also
- Parameters
id (str) –
-
dependentChildAlgorithms
(self, childId: str) → Set[str]¶ Returns a list of the child algorithm IDs depending on the child algorithm with the specified
childId
.See also
- Parameters
childId (str) –
- Return type
Set[str]
-
dependsOnChildAlgorithms
(self, childId: str) → Set[str]¶ Returns a list of the child algorithm IDs on which the child algorithm with the specified
childId
depends upon.See also
- Parameters
childId (str) –
- Return type
Set[str]
-
displayName
(self) → str¶ - Return type
str
-
flags
(self) → QgsProcessingAlgorithm.Flags¶ - Return type
-
fromFile
(self, path: str) → bool¶ Reads the model from a file, at the specified
path
.See also
- Parameters
path (str) –
- Return type
bool
-
group
(self) → str¶ - Return type
str
-
groupId
(self) → str¶ - Return type
str
-
helpContent
(self) → Dict[str, Any]¶ Returns the model’s help contents (a free-form map of values describing the algorithm’s use and metadata).
See also
- Return type
Dict[str, Any]
-
helpUrl
(self) → str¶ - Return type
str
-
icon
(self) → QIcon¶ - Return type
QIcon
-
initAlgorithm
(self, configuration: Dict[str, Any] = {})¶ - Parameters
configuration (Dict[str) –
-
invalidRasterError
()¶
-
invalidSinkError
()¶
-
invalidSourceError
()¶
-
loadVariant
(self, variant: Any) → bool¶ Loads this model from a QVariantMap, wrapped in a QVariant
variant
. You can use QgsXmlUtils.readVariant to load it from an XML document.See also
New in version 3.4.
- Parameters
variant (Any) –
- Return type
bool
-
name
(self) → str¶ - Return type
str
-
otherParametersDependOnParameter
(self, name: str) → bool¶ Returns true if any other model parameters depend on the parameter with the specified
name
(e.g. field parameters wherename
is the parent layer parameter).See also
- Parameters
name (str) –
- Return type
bool
-
parameterAsBool
()¶
-
parameterAsCompatibleSourceLayerPath
()¶
-
parameterAsCrs
()¶
-
parameterAsDouble
()¶
-
parameterAsEnum
()¶
-
parameterAsEnums
()¶
-
parameterAsExpression
()¶
-
parameterAsExtent
()¶
-
parameterAsExtentCrs
()¶
-
parameterAsExtentGeometry
()¶
-
parameterAsFields
()¶
-
parameterAsFile
()¶
-
parameterAsFileOutput
()¶
-
parameterAsInt
()¶
-
parameterAsInts
()¶
-
parameterAsLayer
()¶
-
parameterAsLayerList
()¶
-
parameterAsMatrix
()¶
-
parameterAsOutputLayer
()¶
-
parameterAsPoint
()¶
-
parameterAsPointCrs
()¶
-
parameterAsRange
()¶
-
parameterAsRasterLayer
()¶
-
parameterAsSink
()¶
-
parameterAsSource
()¶
-
parameterAsString
()¶
-
parameterAsVectorLayer
()¶
-
parameterComponent
(self, name: str) → QgsProcessingModelParameter¶ Returns the parameter component with matching
name
. If no parameter component exists with this name a new component will be added to the model and returned.See also
See also
See also
- Parameters
name (str) –
- Return type
-
parameterComponents
(self) → object¶ Returns the map of parameter components used by the model. The keys should match the algorithm’s parameter names (see parameterDefinitions() ).
See also
See also
- Return type
object
-
postProcessAlgorithm
()¶
-
prepareAlgorithm
()¶
-
processAlgorithm
(self, parameters: Dict[str, Any], context: QgsProcessingContext, feedback: QgsProcessingFeedback) → Dict[str, Any]¶ - Parameters
parameters (Dict[str) –
context (QgsProcessingContext) –
feedback (QgsProcessingFeedback) –
- Return type
Dict[str, Any]
-
removeChildAlgorithm
(self, id: str) → bool¶ Attempts to remove the child algorithm with matching
id
. Returns true if the algorithm could be removed, or false if the algorithm could not be removed (e.g. due to other child algorithms depending on it).See also
- Parameters
id (str) –
- Return type
bool
-
removeModelParameter
(self, name: str)¶ Removes an existing model parameter by
name
. The definition of the matching parameter is deleted.See also
See also
- Parameters
name (str) –
-
removeParameter
()¶
-
setChildAlgorithm
(self, algorithm: QgsProcessingModelChildAlgorithm)¶ Sets the child
algorithm
within the model. If a child algorithm already exists in the model with the same child ID then that algorithm will be replaced.See also
See also
- Parameters
algorithm (QgsProcessingModelChildAlgorithm) –
-
setChildAlgorithms
(self, childAlgorithms: Dict[str, QgsProcessingModelChildAlgorithm])¶ Sets the map of child algorithms contained in the model. The keys are the child algorithm ids (see QgsProcessingModelAlgorithm.ChildAlgorithm.childId()). All existing child algorithms will be replaced.
See also
See also
See also
See also
- Parameters
childAlgorithms (Dict[str) –
-
setHelpContent
(self, contents: Dict[str, Any])¶ Sets the model’s help
contents
(a free-form map of values describing the algorithm’s use and metadata).See also
- Parameters
contents (Dict[str) –
-
setParameterComponent
(self, component: QgsProcessingModelParameter)¶ Sets a parameter
component
for the model. If a parameter component already exists in the model with the same parameter name then that component will be replaced.See also
See also
See also
- Parameters
component (QgsProcessingModelParameter) –
-
setParameterComponents
(self, parameterComponents: Dict[str, QgsProcessingModelParameter])¶ Sets the map of parameter components used by the model. The keys should match the algorithm’s parameter names (see parameterDefinitions() ). All existing parameter components will be replaced.
See also
See also
See also
- Parameters
parameterComponents (Dict[str) –
-
setSourceFilePath
(self, path: str)¶ Sets the source file
path
for the model, if available.See also
- Parameters
path (str) –
-
shortDescription
(self) → str¶ - Return type
str
-
shortHelpString
(self) → str¶ - Return type
str
-
sourceFilePath
(self) → str¶ Returns the source file path for the model, if available.
See also
- Return type
str
-
supportInPlaceEdit
()¶
-
svgIconPath
(self) → str¶ - Return type
str
-
toFile
(self, path: str) → bool¶ Writes the model to a file, at the specified
path
.See also
- Parameters
path (str) –
- Return type
bool
-
toVariant
(self) → Any¶ Saves this model to a QVariantMap, wrapped in a QVariant. You can use QgsXmlUtils.writeVariant to save it to an XML document.
See also
New in version 3.4.
- Return type
Any
-
updateDestinationParameters
(self)¶ Updates the model’s parameter definitions to include all relevant destination parameters as required by child algorithm ModelOutputs. Must be called whenever child algorithm ModelOutputs are altered.
-
updateModelParameter
(self, definition: QgsProcessingParameterDefinition)¶ Replaces the definition of an existing parameter (by parameter name) with a new
definition
. Ownership ofdefinition
is transferred to the model, and any existing parameter is deleted.See also
See also
- Parameters
definition (QgsProcessingParameterDefinition) –
-
variablesForChildAlgorithm
(self, childId: str, context: QgsProcessingContext, modelParameters: Dict[str, Any] = {}, results: Dict[str, Any] = {}) → object¶ Returns a map of variable name to variable definition for expression context variables which are available for use by child algorithm during model execution.
The child algorithm
childId
and processingcontext
are manadatory. IfmodelParameters
andresults
are not specified, then only the variable names and sources will be returned, but all variable values will be null. This can be used to determine in advance which variables will be available for a specific child algorithm, e.g. for use in expression builder widgets.In order to calculate the actual variable value, the input model
modelParameters
and already executed child algorithmresults
must be passed.- Parameters
childId (str) –
context (QgsProcessingContext) –
modelParameters (Dict[str) –
results (Dict[str) –
- Return type
object