<div dir="ltr">Hello Nyall,<div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 20, 2018 at 10:55 PM, 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-">On 19 March 2018 at 18:39, Rashad Kanavath <<a href="mailto:rashad.kanavath@c-s.fr">rashad.kanavath@c-s.fr</a>> wrote:<br>
> Nyall,<br>
><br>
> could we have defineCharacteristicsFromFile method in<br>
> QgsProcessingAlgorithm ?.<br>
> the diff with canExecute is more of a working draft.<br>
<br>
<br>
</span>Hi Rashad,<br>
<br>
Can you open a PR? I'm having trouble following the change as the<br>
whitespace is messed up in the email.<br></blockquote><div> </div><div>Here we go.. </div><div><a href="https://github.com/qgis/QGIS/pull/6739">https://github.com/qgis/QGIS/pull/6739</a> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks!<br>
<span class="gmail-HOEnZb"><font color="#888888">Nyall<br>
</font></span><div class="gmail-HOEnZb"><div class="gmail-h5"><br>
><br>
><br>
><br>
> On Thu, Mar 15, 2018 at 03:27:50PM +0100, Rashad Kanavath wrote:<br>
>> Hello,<br>
>><br>
>> On Wed, Mar 14, 2018 at 4:38 AM, Nyall Dawson <<a href="mailto:nyall.dawson@gmail.com">nyall.dawson@gmail.com</a>><br>
>> wrote:<br>
>><br>
>> > On 13 March 2018 at 20:56, Rashad Kanavath <<a href="mailto:rashad.kanavath@c-s.fr">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<br>
>> > 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<br>
>> > etc..).<br>
>> ><br>
>> > 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>
>> ><br>
>><br>
>> Yes. there are different cases like modeler, standard, batch, scripts.<br>
>> I tried to utilize canExecute() in otb and seems to be working.<br>
>> You already have a very flexible, strong API in qgis processing such<br>
>> trickier feature like this one has become too easy!!.<br>
>><br>
>> I had to call alg.canExecute() in two places and that's it.<br>
>> diff attached below. With this loading time will be hopefully improved for<br>
>> OTB, SAGA, GRASS GIS.<br>
>><br>
>> index f5bdc40dc5..1cca57769a 100644<br>
>> --- a/python/plugins/processing/<wbr>modeler/<wbr>ModelerParametersDialog.py<br>
>> +++ b/python/plugins/processing/<wbr>modeler/<wbr>ModelerParametersDialog.py<br>
>> @@ -70,6 +70,7 @@ class ModelerParametersDialog(<wbr>QDialog):<br>
>>          QDialog.__init__(self)<br>
>>          self.setModal(True)<br>
>>          # The algorithm to define in this dialog. It is an instance of<br>
>> QgsProcessingModelAlgorithm<br>
>> +        alg.canExecute()<br>
>>          self._alg = alg<br>
>>          # The model this algorithm is going to be added to<br>
>>          self.model = model<br>
>> @@ -80,6 +81,9 @@ class ModelerParametersDialog(<wbr>QDialog):<br>
>>          settings = QgsSettings()<br>
>>          self.restoreGeometry(settings.<wbr>value("/Processing/<br>
>> modelParametersDialogGeometry"<wbr>, QByteArray()))<br>
>><br>
>> +    def algorithm(self):<br>
>> +        return self._alg<br>
>> +<br>
>>      def closeEvent(self, event):<br>
>>          settings = QgsSettings()<br>
>>          settings.setValue("/<wbr>Processing/<wbr>modelParametersDialogGeometry"<wbr>,<br>
>> self.saveGeometry())<br>
>> @@ -242,7 +246,6 @@ class ModelerParametersDialog(<wbr>QDialog):<br>
>>              outTypes = []<br>
>>          elif not isinstance(outTypes, (tuple, list)):<br>
>>              outTypes = [outTypes]<br>
>> -<br>
>>          return self.model.<wbr>availableSourcesForChild(self.<wbr>childId,<br>
>> [p.typeName() for p in paramType if<br>
>><br>
>>  issubclass(p, QgsProcessingParameterDefiniti<wbr>on)],<br>
>>                                                     [o.typeName() for o in<br>
>> outTypes if<br>
>> diff --git a/src/core/processing/models/<wbr>qgsprocessingmodelchildalgorit<wbr>hm.cpp<br>
>> b/src/core/processing/models/<wbr>qgsprocessingmodelchildalgorit<wbr>hm.cpp<br>
>> index f5f8074c88..01906a7f62 100644<br>
>> --- a/src/core/processing/models/<wbr>qgsprocessingmodelchildalgorit<wbr>hm.cpp<br>
>> +++ b/src/core/processing/models/<wbr>qgsprocessingmodelchildalgorit<wbr>hm.cpp<br>
>> @@ -58,7 +58,7 @@ QgsProcessingModelChildAlgorit<wbr>hm &<br>
>> QgsProcessingModelChildAlgorit<wbr>hm::operator=( c<br>
>><br>
>>  const QgsProcessingAlgorithm *<wbr>QgsProcessingModelChildAlgorit<wbr>hm::algorithm()<br>
>> const<br>
>>  {<br>
>> -  return mAlgorithm.get();<br>
>> +  return mAlgorithm && mAlgorithm->canExecute() ? mAlgorithm.get():<br>
>> nullptr;<br>
>>  }<br>
>><br>
>>  void QgsProcessingModelChildAlgorit<wbr>hm::setModelOutputs( const<br>
>> QMap<QString, QgsProcessingModelOutput> &modelOutputs )<br>
>><br>
>> test code for otb provider:<br>
>> <a href="https://gitlab.orfeo-toolbox.org/orfeotoolbox/qgis-otb-plugin" rel="noreferrer" target="_blank">https://gitlab.orfeo-toolbox.<wbr>org/orfeotoolbox/qgis-otb-<wbr>plugin</a><br>
>> I can add modification to SAGA and GRASS if you are okay to move this to PR.<br>
>><br>
>><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>
>> > 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>
>> ><br>
>><br>
>> this is still loading all algorithm with parsing but things will be in<br>
>> background to not block ui for users. correct?<br>
>> In that case, you could include above diff and then add loading in<br>
>> background task. IMHO that will be best.<br>
>><br>
>><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>
>> ><br>
>> > Nyall<br>
>> > ______________________________<wbr>_________________<br>
>> > QGIS-Developer mailing list<br>
>> > <a href="mailto:QGIS-Developer@lists.osgeo.org">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/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
>> > Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
>> ><br>
>><br>
>><br>
>><br>
>> --<br>
>> Regards,<br>
>>    Rashad<br>
><br>
> --<br>
> Take care,<br>
> Rashad<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div><font face="arial, helvetica, sans-serif">Regards,<br>   Rashad</font></div></div>
</div></div>