Skip to content
Snippets Groups Projects
Arnaud MORVAN's avatar
Arnaud MORVAN authored
Release version 2.1-alpha7

See merge request !45
526e8f8f
History

PreCourlis QGIS plugin

QGIS 3 plugin that is meant to model the bed of rivers and export data for the Courlis module of Telemac-Mascaret.

License: GPL v3 Continuous integration

Development / testing

Plugin source code is in folder PreCourlis.

Recommended development environment is Linux. You can also use Windows but you'll not have the help of make targets.

Automated tests suite can be runned with Docker on any Linux operating system.

Build development docker image

make build

This will build the docker image named camptocamp/edf-precourlis-builder and build or retrieve some runtime files:

This image will be later used to run a QGIS desktop application in a adapted environment or to run automated tests suite.

Run automated tests suite

make test

This will run the automated tests suite in a docker container.

Note that this plugin contains tools that take some datasets as input and produce other datasets as outputs. Some tests compare those outputs to expected ones. There is an option to overwrite the expected result datasets:

make test-overwrite-outputs

This will run the tests and overwrite the expected resultsets. After that you can check the expected results sets feet your needs and commit them.

Test the plugin with QGIS desktop in a docker environment

make qgis

This will run a docker container with QGIS desktop application.

Source code in mounted though a volume in folder /app.

This /app folder is also declared in QGIS_PLUGINPATH so the plugin can be directly activated in "QGIS Extensions manager".

You can also access the tests input and expected results datasets in folder /app/tests/data.

Note that QGIS setting are also stored in a named volume, so they will persist when QGIS container is deleted and recreated.

Test the plugin with QGIS desktop

Linux

make link

This will create a symbolic link to the plugin source code folder in your home QGIS Python plugins folder.

Windows

In QGIS settings, in tab System add an environment variable named QGIS_PLUGINPATH with as value the path to this folder (git repository root folder).

All operating systems

In QGIS desktop extensions manager:

  • load plugin PreCourlis;
  • install QGIS Plugin Plugin Reloader.

Now you can easily make changes in source code, reload plugin PreCourlis and see changes in QGIS desktop.

Packaging

make package

This will create an archive of the plugin in dist/PreCourlis.zip

Test the package archive

make deploy

This will update the Zip archive (package) and extract files in your home QGIS Python plugins folder. With this you can test the packaged Zip archive contains all required files.

List all available make targets

make help

debugging with VS Code

When QGIS desktop is started with Docker (make qgis), or when debugpy is available from QGIS Python process, PreCourlis plugin automatically create a menu action to make debugpy listen on port 5679 and wait for client.

When tests are run with target test-debug, the tests session first make debugpy listen on host port 5680 and wait for client before running any test. You will have to connect to running debugpy server from VS Code before any test start.

make test-debug

Then in VS Code configure your launch.json file with something like:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: QGIS",
            "type": "python",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5679
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/app"
                }
            ],
            "justMyCode": true
        },
        {
            "name": "Python: Tests",
            "type": "python",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5680
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/app"
                }
            ],
            "justMyCode": true
        }
    ]
}

And now you can easily connect to the Python process from VS Code for debugging.