2

This question is related to How to share the set of models with other user?

When exporting a model that depends on the output of another model, the python script calls the function by processing.run('model:ANOTHER MODEL', ...), which will work only after the user's QGIS installation have that model in their respective folder.

My question is, consider the following code snippet:

def processAlgorithm(self, parameters, context, model_feedback):
    # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the
    # overall progress through the model
    feedback = QgsProcessingMultiStepFeedback(3, model_feedback)
    results = {}
    outputs = {}

    # Interpolated before
    alg_params = {
        'attribute2': parameters['elev'],
        'cellsize': parameters['cellsize'],
        'inputcontour': parameters['before'],
        'saga:multilevelbspline_1:Target Grid': QgsProcessing.TEMPORARY_OUTPUT
    }
    outputs['InterpolatedBefore'] = processing.run('model:ANOTHER MODEL', alg_params, context=context, feedback=feedback, is_child_algorithm=True)

    feedback.setCurrentStep(1)
    if feedback.isCanceled():
        return {}

Is it possible to change the call model:ANOTHER MODEL to a function that is contained in a single python script?

My goal is the ease of sharing exported models between people in my organization.

Any documentation or GitHub sample? I've been scrounging QGIS' official documentation to no avail.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.