[QGIS-Developer] How to Add Custom QGIS Model Programmatically

Nyall Dawson nyall.dawson at gmail.com
Thu May 30 15:17:14 PDT 2019


On Tue, 28 May 2019 at 23:57, Ismail Sunni <imajimatika at gmail.com> wrote:
>
> Dear QGIS developers,
>
> Currently, I am trying to create a Docker image based on QGIS official docker image to run a custom processing model. I am able to run the existing processing model by using a python script.

Not sure if you've seen
https://github.com/qgis/QGIS-Enhancement-Proposals/issues/140 , but
that's designed with this use case very much in mind (and supports
specifying a model file via the command line, no need for registering
it in advance anywhere).

It's mostly done at
https://github.com/nyalldawson/QGIS/commit/631460cd1b8481cb118b7df2afacc5c3df40b3ad
, but I need some funds to finalise this and get it merged (e.g. it's
missing unit tests, and needs upgrading to handle the .var style
initialisation used by QGIS windows executables, and I also suspect
there'll be some packaging changes required to allow it to be built
and installed without the QGIS gui/application libraries).

Nyall

>
> Unfortunately, for a custom model, I need to register the model first (similar to adding a new model in QGIS toolbox) before I can use it. I try some ways to do it:
>
> Trying to find Python API to do it. I couldn't find it (perhaps I missed it)
> Trying to add/copy manually the model file to the model directory. Unfortunately, in the container doesn't even have any profile directory.
> I tried to find the model directory path, but I can't find it from QSettings (it returns empty setting with QSettings.allKeys())
> I tried to manually create the directories based on my machine model directory location, but it's not working also.
>
> Any suggestions for this problem? A Python API to add/register the model would be a perfect solution.
>
> Thanks
>
> --
> Ismail Sunni
> ismailsunni.wordpress.com
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list