Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/cicd_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

name: cicd_deploy

on:
# Also run when the pull request merges (which generates a push)
# So that we can tag the docker image appropriately.
push:
tags: [ 'v*.*.*' ]

env:
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io
TEST_TAG: ${{ github.repository }}:test

jobs:
deploy_docker:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout branch
uses: actions/checkout@v4

- name: Build the Docker image
id: build
uses: docker/build-push-action@v6
with:
load: true
tags: ${{ env.TEST_TAG }}

# run the test on the docker image
- name: Run tests in docker image
run: >
docker run
${{ env.TEST_TAG }}
python -m pytest -s
--log-cli-level=DEBUG
--log-format="%(asctime)s %(levelname)s %(message)s"
--log-date-format="%Y-%m-%d %H:%M:%S"
-m "not functional_test"

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3.4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
if: github.event_name != 'pull_request'
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build a Docker image with Buildx (don't on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
if: github.event_name != 'pull_request'
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
69 changes: 69 additions & 0 deletions .github/workflows/cicd_full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

name: cicd_full

on:
# Run tests for pull-requests on master
pull_request:
branches:
- main
# Also run when the pull request merges (which generates a push)
# So that we can tag the docker image appropriately.
push:
branches:
- dev

env:
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io
TEST_TAG: ${{ github.repository }}:test

jobs:
deploy_docker:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout branch
uses: actions/checkout@v4

- name: Build the Docker image
id: build
uses: docker/build-push-action@v6
with:
load: true
tags: ${{ env.TEST_TAG }}

# run the test on the docker image
- name: Run tests in docker image
run: >
docker run
${{ env.TEST_TAG }}
python -m pytest -s
--log-cli-level=DEBUG

test_local:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout branch
uses: actions/checkout@v4

# See https://github.com/marketplace/actions/setup-micromamba
- name: setup-micromamba
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
environment-name: ctview # activate the environment
cache-environment: true
cache-downloads: true
generate-run-shell: true

- name: Run tests with pytest
shell: micromamba-shell {0}
run: python -m pytest -s --log-cli-level=DEBUG
36 changes: 36 additions & 0 deletions .github/workflows/cicd_light.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: cicd_light

on:
# Run tests for non-draft pull request on dev
pull_request:
branches:
- dev


jobs:
test_light:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout branch
uses: actions/checkout@v4

# See https://github.com/marketplace/actions/setup-micromamba
- name: setup-micromamba
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
environment-name: ctview # activate the environment
cache-environment: true
cache-downloads: true
generate-run-shell: true

- name: Run tests with pytest
shell: micromamba-shell {0}
run: python -m pytest -s --log-cli-level=DEBUG



26 changes: 16 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Makefile to manage main tasks
# cf. https://blog.ianpreston.ca/conda/python/bash/2020/05/13/conda_envs.html#makefile

# Oneshell means I can run multiple lines in a recipe in the same shell, so I don't have to
# chain commands together with semicolon
.ONESHELL:

install:
mamba env update -n ctview -f environment.yml
Expand All @@ -6,27 +12,27 @@ install-precommit:
pre-commit install

testing:
./ci/test.sh
python -m pytest -s ./test -v

##############################
# Docker
##############################

PROJECT_NAME=lidar_hd/ct_view
REGISTRY=ghcr.io
NAMESPACE=ignf
IMAGE_NAME=ctview
VERSION=`python -m ctview._version`
REGISTRY=docker-registry.ign.fr
FULL_IMAGE_NAME=${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:${VERSION}

docker-build:
docker build -t ${PROJECT_NAME}:${VERSION} -f Dockerfile .
docker build -t ${IMAGE_NAME}:${VERSION} -f Dockerfile .

docker-test:
docker run --rm -it ${PROJECT_NAME}:${VERSION} python -m pytest -s
docker run --rm ${IMAGE_NAME}:${VERSION} python -m pytest -s -m "not functional_test"

docker-remove:
docker rmi -f `docker images | grep ${PROJECT_NAME} | tr -s ' ' | cut -d ' ' -f 3`
docker rmi -f `docker images -f "dangling=true" -q`
docker rmi -f `docker images | grep ${IMAGE_NAME}:${VERSION} | tr -s ' ' | cut -d ' ' -f 3`

docker-deploy:
docker login docker-registry.ign.fr -u svc_lidarhd
docker tag ${PROJECT_NAME}:${VERSION} ${REGISTRY}/${PROJECT_NAME}:${VERSION}
docker push ${REGISTRY}/${PROJECT_NAME}:${VERSION}
docker tag ${IMAGE_NAME}:${VERSION} ${FULL_IMAGE_NAME}
docker push ${FULL_IMAGE_NAME}
14 changes: 0 additions & 14 deletions TODO.md

This file was deleted.

1 change: 0 additions & 1 deletion ci/test.sh

This file was deleted.

2 changes: 1 addition & 1 deletion configs/config_control.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class_map:
- {value: 202, description: "Candidats Batiment", color: [255, 128, 128]}
dxm_filter: # Paramètres pour le calcul du MNS (utilisé pour l'ombrage), dimension à filtrer et
# valeur à garder, par défaut on utilise la dimension créée dans la phase de preprocessing
# des produits dérivés
# de las_digital_models
dimension: dsm_marker
keep_values: [1]
post_processing: # Traitements à appliquer à la carte de classe
Expand Down
2 changes: 1 addition & 1 deletion configs/config_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class_map:
- {value: 162, description: "VirtPont", color: [85, 97, 137]}
dxm_filter: # Paramètres pour le calcul du MNS (utilisé pour l'ombrage), dimension à filtrer et
# valeur à garder, par défaut on utilise la dimension créée dans la phase de preprocessing
# des produits dérivés
# de las_digital_models
dimension: dsm_marker
keep_values: [1]
post_processing: # Traitements à appliquer à la carte de classe
Expand Down
14 changes: 7 additions & 7 deletions ctview/map_DXM.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tempfile
from typing import List

import produits_derives_lidar.ip_one_tile
import las_digital_models.ip_one_tile
from omegaconf import DictConfig
from osgeo_utils import gdal_calc

Expand All @@ -19,10 +19,10 @@ def create_raw_dxm(
config_io: DictConfig,
):
"""Create a Digital Model (DSM or DTM) using the filter defined with
dxm_filter_dimension/dxm_filter_keep_values using the produits_derives_lidar
dxm_filter_dimension/dxm_filter_keep_values using the las_digital_models
library

WARNING: the dtm bounds are inferred from the filename inside the produits_derives_lidar library
WARNING: the dtm bounds are inferred from the filename inside the las_digital_models library
(dtm is not computed on the potential additional buffer)

Args:
Expand All @@ -42,10 +42,10 @@ def create_raw_dxm(
}
cf. configs/config_control.yaml for an example.
The config will be completed with pixel_size, dxm_filter_dimension and dxm_filter_keep_values
to match produits_derive_lidar configuration expectations
to match las_digital_models configuration expectations
"""

# Generate config that suits for produits_derive_lidar interpolation
# Generate config that suits for las_digital_models interpolation
pdl_config = {}
spatial_ref = (
f"EPSG:{config_io.spatial_reference}"
Expand All @@ -60,7 +60,7 @@ def create_raw_dxm(
log.debug("Config for dxm generation")
log.debug(pdl_config)

produits_derives_lidar.ip_one_tile.interpolate_from_config(
las_digital_models.ip_one_tile.interpolate_from_config(
input_file=input_file, output_raster=output_dxm, config=pdl_config
)

Expand Down Expand Up @@ -104,7 +104,7 @@ def add_dxm_hillshade_to_raster(
}
cf. configs/config_control.yaml for an example ("io" subdivision)
The config will be completed with pixel_size, dxm_filter_dimension and dxm_filter_keep_values
to match produits_derive_lidar configuration expectations
to match las_digital_models configuration expectations
"""
os.makedirs(os.path.dirname(output_dxm_raw), exist_ok=True)
os.makedirs(os.path.dirname(output_dxm_hillshade), exist_ok=True)
Expand Down
Loading