<div dir="ltr">Hello,<br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 14, 2018 at 4:38 AM, Nyall Dawson <span dir="ltr"><<a href="mailto:nyall.dawson@gmail.com" target="_blank">nyall.dawson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-m_-8470674260290210549gmail-">On 13 March 2018 at 20:56, Rashad Kanavath <<a href="mailto:rashad.kanavath@c-s.fr" target="_blank">rashad.kanavath@c-s.fr</a>> wrote:<br>
> if a provier is enabled then qgis reads all algorithm's during<br>
> startup. This involves reading descriptor files and doing all parsing<br>
> required to make gui when user actually open algorithm (click on<br>
> treeitem).<br>
> So If I have like three provider enabled it takes more time to start qgis than<br>
> usual. Even though, I might open one or two later at some point.<br>
><br>
> It is not necessary here to parse "all" data during startup.  name and<br>
> group name is only needed to fill provider-algorithm tree. This is<br>
> true for any provider which uses descriptor files (OTB, GRASS, SAGA etc..).<br>
<br>
</span>Actually it's a bit trickier here -- models make things more complex<br>
as they self-validate on creation, and need full knowledge of the<br>
dependent algorithm's parameters and outputs.<br></blockquote><div><br></div><div>Yes. there are different cases like modeler, standard, batch, scripts.</div><div>I tried to utilize canExecute() in otb and seems to be working.</div><div>You already have a very flexible, strong API in qgis processing such trickier feature like this one has become too easy!!.</div><div><br></div><div>I had to call alg.canExecute() in two places and that's it. <br></div><div>diff attached below. With this loading time will be hopefully improved for OTB, SAGA, GRASS GIS.<br></div><div><br></div><div><div>index f5bdc40dc5..1cca57769a 100644</div><div>--- a/python/plugins/processing/<wbr>modeler/<wbr>ModelerParametersDialog.py</div><div>+++ b/python/plugins/processing/<wbr>modeler/<wbr>ModelerParametersDialog.py</div><div>@@ -70,6 +70,7 @@ class ModelerParametersDialog(<wbr>QDialog):</div><div>         QDialog.__init__(self)</div><div>         self.setModal(True)</div><div>         # The algorithm to define in this dialog. It is an instance of QgsProcessingModelAlgorithm</div><div>+        alg.canExecute()</div><div>         self._alg = alg</div><div>         # The model this algorithm is going to be added to</div><div>         self.model = model</div><div>@@ -80,6 +81,9 @@ class ModelerParametersDialog(<wbr>QDialog):</div><div>         settings = QgsSettings()</div><div>         self.restoreGeometry(<wbr>settings.value("/Processing/<wbr>modelParametersDialogGeometry"<wbr>, QByteArray()))</div><div><br></div><div>+    def algorithm(self):</div><div>+        return self._alg</div><div>+</div><div>     def closeEvent(self, event):</div><div>         settings = QgsSettings()</div><div>         settings.setValue("/<wbr>Processing/<wbr>modelParametersDialogGeometry"<wbr>, self.saveGeometry())</div><div>@@ -242,7 +246,6 @@ class ModelerParametersDialog(<wbr>QDialog):</div><div>             outTypes = []</div><div>         elif not isinstance(outTypes, (tuple, list)):</div><div>             outTypes = [outTypes]</div><div>-</div><div>         return self.model.<wbr>availableSourcesForChild(self.<wbr>childId, [p.typeName() for p in paramType if</div><div>                                                                   issubclass(p, QgsProcessingParameterDefiniti<wbr>on)],</div><div>                                                    [o.typeName() for o in outTypes if</div><div>diff --git a/src/core/processing/models/<wbr>qgsprocessingmodelchildalgorit<wbr>hm.cpp b/src/core/processing/models/<wbr>qgsprocessingmodelchildalgorit<wbr>hm.cpp</div><div>index f5f8074c88..01906a7f62 100644</div><div>--- a/src/core/processing/models/<wbr>qgsprocessingmodelchildalgorit<wbr>hm.cpp</div><div>+++ b/src/core/processing/models/<wbr>qgsprocessingmodelchildalgorit<wbr>hm.cpp</div><div>@@ -58,7 +58,7 @@ QgsProcessingModelChildAlgorit<wbr>hm &<wbr>QgsProcessingModelChildAlgorit<wbr>hm::operator=( c</div><div><br></div><div> const QgsProcessingAlgorithm *<wbr>QgsProcessingModelChildAlgorit<wbr>hm::algorithm() const</div><div> {</div><div>-  return mAlgorithm.get();</div><div>+  return mAlgorithm && mAlgorithm->canExecute() ? mAlgorithm.get(): nullptr;</div><div> }</div><div><br></div><div> void QgsProcessingModelChildAlgorit<wbr>hm::setModelOutputs( const QMap<QString, QgsProcessingModelOutput> &modelOutputs )</div></div><div><br></div><div>test code for otb provider: <a href="https://gitlab.orfeo-toolbox.org/orfeotoolbox/qgis-otb-plugin">https://gitlab.orfeo-toolbox.org/orfeotoolbox/qgis-otb-plugin</a><br></div><div>I can add modification to SAGA and GRASS if you are okay to move this to PR.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="gmail-m_-8470674260290210549gmail-"><br>
> Issue is more about calling defineDescriptorFile() in Algorithm's<br>
> __init__ method. And ofcourse, one cannot avoid init when adding<br>
> algorithm and tree need to add an instance of algorithm. what can be<br>
> done?<br>
<br>
</span>What I've been thinking/planning is to take advantage of task manager<br>
here. So basically:<br>
<br>
- on processing startup, there's no providers added<br>
- when the qgis interface is fully loaded then we fire up a background<br>
task which loads the providers, allowing them to fully build their<br>
available algorithms and parameters without blocking the startup<br>
- after the task completes, the tree is populated<br></blockquote><div><br></div><div>this is still loading all algorithm with parsing but things will be in background to not block ui for users. correct?</div><div>In that case, you could include above diff and then add loading in background task. IMHO that will be best.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I'd like to see more plugins take this approach, so that qgis can load<br>
nice and quick and the slow stuff happens without annoying users...<br>
<span class="gmail-m_-8470674260290210549gmail-HOEnZb"><font color="#888888"><br>
Nyall<br>
</font></span><div class="gmail-m_-8470674260290210549gmail-HOEnZb"><div class="gmail-m_-8470674260290210549gmail-h5">______________________________<wbr>_________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-developer</a></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-8470674260290210549gmail_signature"><div><font face="arial, helvetica, sans-serif">Regards,<br>   Rashad</font></div></div>
</div></div>