Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesfize committed Apr 29, 2024
2 parents b1ddb96 + d64e6a1 commit a8b5e79
Show file tree
Hide file tree
Showing 204 changed files with 6,468 additions and 3,108 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ b90e205c5a04e138a451d670a5d2c360c274ac19

# html style
55a16be2620387e360849a98ecee1e837740311c

# prettier hmtl and scss
7fa4afd6938aacfc0221da6872a56680a12ef45f
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/images/*.png filter=lfs diff=lfs merge=lfs -text
20 changes: 10 additions & 10 deletions .github/workflows/eval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
strategy:
fail-fast: false
matrix:
debian-version: ["11", "12"]
debian-version: ['11', '12']
include:
- debian-version: "11"
python-version: "3.9"
postgres-version: "13"
postgis-version: "3.2"
- debian-version: "12"
python-version: "3.11"
postgres-version: "15"
postgis-version: "3.3"
- debian-version: '11'
python-version: '3.9'
postgres-version: '13'
postgis-version: '3.2'
- debian-version: '12'
python-version: '3.11'
postgres-version: '15'
postgis-version: '3.3'

name: Debian ${{ matrix.debian-version }}

Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache: 'pip'
- name: Install GDAL
run: |
sudo apt update
Expand Down
137 changes: 137 additions & 0 deletions .github/workflows/eval_perf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Performance Evaluation
on:
workflow_dispatch:

jobs:
build:
runs-on: self-hosted

strategy:
fail-fast: false
matrix:
debian-version: ["11", "12"]
include:
- debian-version: "11"
python-version: "3.9"
postgres-version: "13"
postgis-version: "3.2"
- debian-version: "12"
python-version: "3.11"
postgres-version: "15"
postgis-version: "3.3"

name: Debian ${{ matrix.debian-version }}

services:
postgres:
image: postgis/postgis:${{ matrix.postgres-version }}-${{ matrix.postgis-version }}
env:
POSTGRES_DB: geonature2db
POSTGRES_PASSWORD: geonatpasswd
POSTGRES_USER: geonatadmin
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Add database extensions
run: |
psql -h localhost -U geonatadmin -d geonature2db -f install/assets/db/add_pg_extensions.sql
env:
PGPASSWORD: geonatpasswd
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install GDAL
run: |
sudo apt update
sudo apt install -y libgdal-dev
- name: Install dependencies
if: github.base_ref == 'master'
run: |
echo 'Installation des requirements de prod'
python -m pip install --upgrade pip
python -m pip install \
-e ..[tests] \
-r requirements.txt
working-directory: ./backend
- name: Install dependencies
if: github.base_ref != 'master'
run: |
echo 'Installation des requirements de dev'
python -m pip install --upgrade pip
python -m pip install \
-e ..[tests] \
-r requirements-dev.in
working-directory: ./backend
- name: Show database branches and dependencies
run: |
geonature db status --dependencies
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
# - name: Restore database
# run: |
# # wget https://www.dropbox.com/scl/fi/17gsthsftfg59mxwmbbre/export_geonature_10000.zip?rlkey=33choleag4xw60wadm802c3oh&dl=1 -O 10kDump.zip
# # unzip 10kDump.zip
# wget https://www.dropbox.com/scl/fi/jjkxyg120bxc0dp8uy8kq/300KDump.sql?rlkey=tyuk2svitcb9nyshn7r09yo7b&dl=1 -O 300KDump.sql
# ls
# psql -h localhost -U geonatadmin -d geonature2db -f 300KDump.sql
# env:
# PGPASSWORD: geonatpasswd
- name: Install database
run: |
install/03b_populate_db.sh
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
srid_local: 2154
install_bdc_statuts: true
add_sample_data: true
install_sig_layers: true
install_grid_layer_5: true
install_grid_layer_10: true
install_ref_sensitivity: true
- name: Show database status
run: |
geonature db status
env:
GEONATURE_CONFIG_FILE: config/test_config.toml

- name: Install core modules backend
run: |
pip install -e contrib/occtax
pip install -e contrib/gn_module_occhab
pip install -e contrib/gn_module_validation
- name: Show database status
run: |
geonature db status
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
- name: Install core modules database
run: |
geonature upgrade-modules-db
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
- name: Show database status
run: |
geonature db status --dependencies
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
- name: Load benchmark stable data
run: |
wget https://geonature.fr/data/benchmark_history/benchmark_stable.json -O benchmark_stable.json
- name: Compare performance to stable data
run: |
pytest --benchmark-only --benchmark-compare-fail="mean:0.1" --benchmark-compare=benchmark_stable.json
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
# https://stackoverflow.com/a/64126737 For posting results on GitHub Pull Requests
22 changes: 11 additions & 11 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ jobs:
strategy:
fail-fast: false
matrix:
debian-version: ["11", "12"]
debian-version: ['11', '12']
include:
- debian-version: "11"
python-version: "3.9"
postgres-version: "13"
postgis-version: "3.2"
- debian-version: "12"
python-version: "3.11"
postgres-version: "15"
postgis-version: "3.3"
- debian-version: '11'
python-version: '3.9'
postgres-version: '13'
postgis-version: '3.2'
- debian-version: '12'
python-version: '3.11'
postgres-version: '15'
postgis-version: '3.3'

name: Debian ${{ matrix.debian-version }}

Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache: 'pip'
- name: Install GDAL
run: |
sudo apt update
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
GEONATURE_CONFIG_FILE: config/test_config.toml
- name: Test with pytest
run: |
pytest -v --cov --cov-report xml
pytest -v --cov --cov-report xml --benchmark-skip
env:
GEONATURE_CONFIG_FILE: config/test_config.toml
- name: Upload coverage to Codecov
Expand Down
24 changes: 8 additions & 16 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
[submodule "backend/dependencies/UsersHub-authentification-module"]
path = backend/dependencies/UsersHub-authentification-module
url = https://github.com/PnX-SI/UsersHub-authentification-module
branch = develop
url = ../UsersHub-authentification-module.git
[submodule "backend/dependencies/Nomenclature-api-module"]
path = backend/dependencies/Nomenclature-api-module
url = https://github.com/PnX-SI/Nomenclature-api-module
branch = develop
url = ../Nomenclature-api-module.git
[submodule "backend/dependencies/Habref-api-module"]
path = backend/dependencies/Habref-api-module
url = https://github.com/PnX-SI/Habref-api-module
branch = develop
url = ../Habref-api-module.git
[submodule "backend/dependencies/Utils-Flask-SQLAlchemy"]
path = backend/dependencies/Utils-Flask-SQLAlchemy
url = https://github.com/PnX-SI/Utils-Flask-SQLAlchemy
branch = develop
url = ../Utils-Flask-SQLAlchemy.git
[submodule "backend/dependencies/TaxHub"]
path = backend/dependencies/TaxHub
url = https://github.com/PnX-SI/TaxHub
branch = develop
url = ../TaxHub.git
[submodule "backend/dependencies/Utils-Flask-SQLAlchemy-Geo"]
path = backend/dependencies/Utils-Flask-SQLAlchemy-Geo
url = https://github.com/PnX-SI/Utils-Flask-SQLAlchemy-Geo
branch = develop
url = ../Utils-Flask-SQLAlchemy-Geo.git
[submodule "backend/dependencies/RefGeo"]
path = backend/dependencies/RefGeo
url = https://github.com/PnX-SI/RefGeo.git
branch = develop
url = ../RefGeo.git
[submodule "backend/dependencies/UsersHub"]
path = backend/dependencies/UsersHub
url = https://github.com/PnX-SI/UsersHub
branch = develop
url = ../UsersHub.git
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.14.0
2.14.1
2 changes: 1 addition & 1 deletion backend/dependencies/RefGeo
34 changes: 17 additions & 17 deletions backend/geonature/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,28 +156,28 @@ def on_before_models_committed(sender, changes):
if change == "delete" and hasattr(obj, "__before_commit_delete__"):
obj.__before_commit_delete__()

# setting g.current_user on each request
@app.before_request
def load_current_user():
g._permissions_by_user = {}
g._permissions = {}

# FIXME : order of @app.before_request is random thus g.current_user can be empty...
# if config.get("SENTRY_DSN"):
# from sentry_sdk import set_tag, set_user

# @app.before_request
# def set_sentry_context():
# if "FLASK_REQUEST_ID" in request.environ:
# set_tag("request.id", request.environ["FLASK_REQUEST_ID"])
# if g.current_user:
# set_user(
# {
# "id": g.current_user.id_role,
# "username": g.current_user.identifiant,
# "email": g.current_user.email,
# }
# )
if config.get("SENTRY_DSN"):
from sentry_sdk import set_tag, set_user

@app.before_request
def set_sentry_context():
from flask_login import current_user

if "FLASK_REQUEST_ID" in request.environ:
set_tag("request.id", request.environ["FLASK_REQUEST_ID"])
if current_user.is_authenticated:
set_user(
{
"id": current_user.id_role,
"username": current_user.identifiant,
"email": current_user.email,
}
)

admin.init_app(app)

Expand Down
Loading

0 comments on commit a8b5e79

Please sign in to comment.