Skip to content

Commit

Permalink
Merge pull request #46 from PnX-SI/develop
Browse files Browse the repository at this point in the history
Develop > Master / 1.1.0
  • Loading branch information
camillemonchicourt authored Jun 27, 2023
2 parents 027fe60 + e5090c8 commit 96f7d07
Show file tree
Hide file tree
Showing 327 changed files with 10,414 additions and 4,404 deletions.
227 changes: 105 additions & 122 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
- develop
- main

env:
GEONATURE_CONFIG_FILE: ./dependencies/GeoNature/config/test_config.toml

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -43,126 +46,106 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Clone gn_modulator repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Add postgis_raster database extension
if: ${{ matrix.postgis-version >= 3 }}
run: |
psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "postgis_raster";'
env:
PGPASSWORD: geonatpasswd
- name: Add database extensions
run: |
psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "hstore";'
psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "uuid-ossp";'
psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "pg_trgm";'
psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "unaccent";'
env:
PGPASSWORD: geonatpasswd
- name: Install GDAL
run: |
sudo apt update
sudo apt install -y libgdal-dev
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install \
-e ..[tests] \
-r requirements-dev.txt
working-directory: ./dependencies/GeoNature/backend
- name: Show database branches and dependencies
run: |
geonature db status --dependencies
env:
GEONATURE_CONFIG_FILE: ./dependencies/GeoNature/config/test_config.toml
- name: Install database
run: |
geonature db upgrade geonature@head -x local-srid=2154
geonature db autoupgrade -x local-srid=2154
geonature taxref import-v15 --skip-bdc-statuts
geonature db upgrade geonature-samples@head
geonature db upgrade nomenclatures_taxonomie_data@head
geonature db upgrade ref_geo_fr_departments@head
geonature db upgrade ref_geo_fr_municipalities@head
geonature db upgrade ref_geo_inpn_grids_5@head
geonature db upgrade ref_sensitivity_inpn@head
env:
GEONATURE_CONFIG_FILE: ./dependencies/GeoNature/config/test_config.toml
- name: Show database status
run: |
geonature db status
env:
GEONATURE_CONFIG_FILE: ./dependencies/GeoNature/config/test_config.toml

- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: NMV Node ${{ matrix.node-version }}
uses: dcodeIO/setup-node-nvm@master
with:
node-version: ${{ matrix.node-version }}

# FRONTEND
# TODO CLARIFIER CI
- name: install frontend
run: |
cp ./config/settings.ini.sample ./config/settings.ini
./install/05_install_frontend.sh
working-directory: ./dependencies/GeoNature
env:
GEONATURE_CONFIG_FILE: ./config/test_config.toml

- name: Install core modules
run: |
pip install -e ./dependencies/GeoNature/contrib/occtax
pip install -e ./dependencies/GeoNature/contrib/gn_module_occhab
pip install -e ./dependencies/GeoNature/contrib/gn_module_validation
- name: Install core modules database
run: |
geonature upgrade-modules-db
env:
GEONATURE_CONFIG_FILE: ./dependencies/GeoNature/config/test_config.toml

- name: Install GN Modules
run: |
pip install -e .
- name: Install GN Modules db
run: |
geonature upgrade-modules-db
env:
GEONATURE_CONFIG_FILE: ./dependencies/GeoNature/config/test_config.toml

- name: install m_monitoring test 1
run: geonature modulator install -f m_monitoring_test_1
env:
GEONATURE_CONFIG_FILE: ./dependencies/GeoNature/config/test_config.toml

- name: install m_monitoring test 2
run: geonature modulator install -f m_monitoring_test_2
env:
GEONATURE_CONFIG_FILE: ./dependencies/GeoNature/config/test_config.toml

- name: Pytest gn_modulator
run: pytest -v --cov --cov-report xml
env:
GEONATURE_CONFIG_FILE: ./dependencies/GeoNature/config/test_config.toml

- name: Upload coverage to Codecov
if: ${{ matrix.name == 'Debian 11' }}
uses: codecov/codecov-action@v2
with:
flags: pytest
- name: Add postgis_raster database extension
if: ${{ matrix.postgis-version >= 3 }}
run: |
psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "postgis_raster";'
env:
PGPASSWORD: geonatpasswd
- name: Add database extensions
run: |
psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "hstore";'
psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "uuid-ossp";'
psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "pg_trgm";'
psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "unaccent";'
env:
PGPASSWORD: geonatpasswd
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install GDAL
run: |
sudo apt update
sudo apt install -y libgdal-dev
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install \
-e ..[tests] \
-r requirements-dev.txt \
working-directory: ./dependencies/GeoNature/backend
- name: Show database branches and dependencies
run: |
geonature db status --dependencies
- name: Install database
run: |
geonature db upgrade geonature@head -x local-srid=2154
geonature db autoupgrade -x local-srid=2154
geonature taxref import-v15 --skip-bdc-statuts
geonature db upgrade geonature-samples@head
geonature db upgrade nomenclatures_taxonomie_data@head
geonature db upgrade ref_geo_fr_departments@head
geonature db upgrade ref_geo_fr_municipalities@head
geonature db upgrade ref_geo_inpn_grids_5@head
geonature db upgrade ref_sensitivity_inpn@head
- name: Show database status
run: |
geonature db status
- name: Install core modules
run: |
pip install -e ./dependencies/GeoNature/contrib/occtax
pip install -e ./dependencies/GeoNature/contrib/gn_module_occhab
pip install -e ./dependencies/GeoNature/contrib/gn_module_validation
- name: Install GN Modulator
run: |
pip install -e .
- name: Install modules db
run: |
geonature upgrade-modules-db
- name: check gn_modulator
run: geonature modulator check

- name: list modules
run: geonature modulator install

# - name: install m_monitoring
# run: geonature modulator install -p ./contrib/m_monitoring

# - name: install m_monitoring test 1
# run: geonature modulator install m_monitoring_test_1

# - name: install m_monitoring test 2
# run: geonature modulator install m_monitoring_test_2

- name: install m_sipaf
run: geonature modulator install -p ./contrib/m_sipaf

- name: Pytest gn_modulator
run: pytest -v --cov --cov-report xml

- name: Upload coverage to Codecov
if: ${{ matrix.name == 'Debian 11' }}
uses: codecov/codecov-action@v2
with:
flags: pytest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ frontend/app/module.config.ts

#!migrations/data/*.sql
backend/gn_modulator/migrations/versions/*
!backend/gn_modulator/migrations/versions/*_gn_modulator.py
!backend/gn_modulator/migrations/versions/*gn_modulator*.py

!.gitkeep

Expand Down
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Présentation

Ce module GeoNature est un générateur de modules, qui permet construire dynamiquement des sous-modules disposant de leur propre modèle de données,
à partir de fichiers de configuration JSON.
à partir de fichiers de configuration YAML.

Chaque sous-module dispose d'une page d'accueil avec une carte, liste et filtres des objets du sous-module :

Expand All @@ -15,18 +15,30 @@ Et une fiche détail et de saisie de chaque objet :

## Installation

Compatible avec la version 2.11.2 (et plus) de GeoNature.
Compatible avec la version 2.13.0 (et plus) de GeoNature.

Se placer dans le répertoire backend de GeoNature et activer le virtualenv
- Téléchargez le module dans ``/home/<myuser>/``, en remplacant ``X.Y.Z`` par la version souhaitée

```bash
source venv/bin/activate
cd
wget https://github.com/PnX-SI/gn_modulator/archive/X.Y.Z.zip
unzip X.Y.Z.zip
rm X.Y.Z.zip
```

Lancer la commande d'installation
- Renommez le répertoire du module

```bash
geonature install_gn_module <MON_CHEMIN_ABSOLU_VERS_LE_MODULE> MODULATOR
mv ~/gn_modulator-X.Y.Z ~/gn_modulator
```

- Lancez l'installation du module

```bash
source ~/geonature/backend/venv/bin/activate
geonature install-gn-module ~/gn_modulator MODULATOR
sudo systemctl restart geonature
deactivate
```

- [Liste des commandes du module](./doc/commandes.md)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.5
1.1.0
13 changes: 10 additions & 3 deletions backend/gn_modulator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from .schema import SchemaMethods
from .module import ModuleMethods
from gn_modulator.utils.errors import get_errors
from gn_modulator.utils.env import config_dir, config_modulator_dir
from gn_modulator.utils.files import symlink
import time


Expand All @@ -13,21 +15,26 @@ def init_gn_modulator():
Fonction d'initialisation de gn_module
"""

if not (config_dir() / "modulator").is_dir():
config_dir().mkdir(parents=True, exist_ok=True)
symlink(config_modulator_dir, config_dir() / "modulator")

verbose = True
# - definitions
start_time = time.time()
DefinitionMethods.init_definitions()
print(f"definitions : {round((time.time() - start_time)*1e3)} ms")
verbose and print(f"definitions : {round((time.time() - start_time)*1e3)} ms")
if get_errors():
return

# - schemas
start_time = time.time()
SchemaMethods.init_schemas()
print(f"schemas : {round((time.time() - start_time)*1e3)} ms")
verbose and print(f"schemas : {round((time.time() - start_time)*1e3)} ms")
if get_errors():
return

# - modules
start_time = time.time()
ModuleMethods.init_modules()
print(f"modules : {round((time.time() - start_time)*1e3)} ms")
verbose and print(f"modules : {round((time.time() - start_time)*1e3)} ms")
Loading

0 comments on commit 96f7d07

Please sign in to comment.