Re: [QGIS-Developer] How to Add Custom QGIS Model Programmatically
Hi Nyall, 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). Wow, this is more or less what I want to do also. In my case, I want to use QGIS docker image and add a python script to handle the input. I put my code in https://github.com/ismailsunni/docker-qgis3-model. It's still in exploration mode, and still not working with dynamically using a model from the user. Hopefully, it will be done soon (at least at the end of my course semester :D ). This for my school project actually, but perhaps it can be useful for other people. I use a YAML file to define the input and output since I feel it's not easy to put the long parameter after the command. After reading the QEP and another QEP about official docker image [1], so this Docker image [2] is not yet an official one? 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). The implementation seems will be easier to use in Windows. Since by using Docker, Windows user needs to install Docker first, and it's really not straight forward unless you have Win 10 Pro. Thanks for sharing Nyall. My search engine did not show the QEP or your branch to me :) Best regards [1] https://github.com/qgis/QGIS-Enhancement-Proposals/issues/142 [2] https://hub.docker.com/r/qgis/qgis/ On Fri, May 31, 2019 at 12:17 AM Nyall Dawson wrote: > On Tue, 28 May 2019 at 23:57, Ismail Sunni 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@lists.osgeo.org > > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer > -- Ismail Sunni ismailsunni.wordpress.com ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] How to Add Custom QGIS Model Programmatically
On Tue, 28 May 2019 at 23:57, Ismail Sunni 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@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] How to Add Custom QGIS Model Programmatically
HI Luigi, Thanks for the pointer, it's really helpful. Now I got my model registered :) I convert it to Python script first, then add it as you said. Next, I will check if it's working properly Best regards On Tue, May 28, 2019 at 5:52 PM Luigi Pirelli wrote: > > I'm travelling, but iIRC, you need before register model provider in > processing... There are processing tests about alg provider registry. > On Tuesday, 28 May 2019, Ismail Sunni 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. >> >> 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: >> >>1. Trying to find Python API to do it. I couldn't find it (perhaps I >>missed it) >>2. Trying to add/copy manually the model file to the model directory. >>Unfortunately, in the container doesn't even have any profile directory. >>3. I tried to find the model directory path, but I can't find it from >>QSettings (it returns empty setting with *QSettings.allKeys()*) >>4. 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 >> > > > -- > > Luigi Pirelli > > > ** > * LinkedIn: https://www.linkedin.com/in/luigipirelli > * Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli > * GitHub: https://github.com/luipir > * Mastering QGIS 2nd Edition: > * > https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition > * Hire me: http://www.qcooperative.net > > ** > > -- Ismail Sunni ismailsunni.wordpress.com ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
[QGIS-Developer] How to Add Custom QGIS Model Programmatically
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. 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: 1. Trying to find Python API to do it. I couldn't find it (perhaps I missed it) 2. Trying to add/copy manually the model file to the model directory. Unfortunately, in the container doesn't even have any profile directory. 3. I tried to find the model directory path, but I can't find it from QSettings (it returns empty setting with *QSettings.allKeys()*) 4. 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@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer