Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add Docs #57

Merged
merged 26 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2afcc9d
Add sphinx requirements
CharlesGaydon Apr 28, 2022
d7c5511
Documentation backbone
CharlesGaydon Apr 28, 2022
7385da8
Workflow for github pages
CharlesGaydon Apr 28, 2022
4a8ad36
Reenable CICD
CharlesGaydon Apr 28, 2022
fff28fe
Deploy pages on push to feature branch
CharlesGaydon May 2, 2022
0d91aa4
Use conda to install deps in ghpages
CharlesGaydon May 2, 2022
c9d509b
Only run CICD workflow when ready for review
CharlesGaydon May 2, 2022
a56d15d
Activate conda env in gh pages workflow
CharlesGaydon May 2, 2022
2fe433f
Conda update
CharlesGaydon May 2, 2022
853d53a
se conda-incubator in workflow
CharlesGaydon May 2, 2022
b765742
Add conda-forge channel
CharlesGaydon May 2, 2022
6d4219b
No use of mamba
CharlesGaydon May 2, 2022
7fc4315
Change docs dir
CharlesGaydon May 2, 2022
1139a89
Change to mamba to build the doc
CharlesGaydon May 3, 2022
5a86066
Cache environment
CharlesGaydon May 3, 2022
15a1b18
Badge
CharlesGaydon May 3, 2022
9086b2b
Change date
CharlesGaydon May 3, 2022
150f94b
Bette continous deployment
CharlesGaydon May 4, 2022
dbe79ec
Better CD
CharlesGaydon May 4, 2022
cb3c5d8
Trigger the docker tagging, do not build it
CharlesGaydon May 4, 2022
30a8f1a
Trigger CICD
CharlesGaydon May 4, 2022
cf0ecea
Use ubuntu-latest instead
CharlesGaydon May 4, 2022
bfd5fdb
Use an anaconda image directly
CharlesGaydon May 4, 2022
55a1b75
Try using micromamba, now that test pass
CharlesGaydon May 4, 2022
1c7b9fb
CICD happens via pytest for large file
CharlesGaydon May 5, 2022
1020b82
Documentation
CharlesGaydon May 5, 2022
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
67 changes: 41 additions & 26 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
name: CICD

on:
# Run CICD for non-draft pull request
pull_request:
branches: [dev, main]

branches:
- dev
- main
# Also run when the pull request merges (which generates a push)
# So that we can tag the docker image appropriately.
push:
branches:
- dev
- prod
- main

jobs:
lidar_on_docker:
Expand All @@ -20,20 +29,22 @@ jobs:
- name: Check code neatness (linter)
run: docker run lidar_prod_im flake8

- name: Run tests - fast ones go first.
run: docker run lidar_prod_im python -m pytest -v -m "not slow" --ignore=actions-runner
- name: Run tests & get coverage - fast ones go first.
run: >
docker run
lidar_prod_im
python -m
pytest -rA -v -m "not slow" --ignore=actions-runner

- name: Run slow tests last.
- name: Run slow tests last (evaluation on large file)
run: >
docker run
docker run
-v /var/data/cicd/CICD_github_assets/M8.4/inputs/evaluation/:/lidar/tests/files/large/
lidar_prod_im
python -m
pytest -v -m slow
--ignore=actions-runner
--no-cov
pytest -rA -v -m "slow" --ignore=actions-runner --no-cov

- name: Full module run on LAS subset using CLI.
- name: Test run from CLI on a LAS subset.
run: >
docker run
-v /var/data/cicd/CICD_github_assets/M8.4/inputs/:/inputs/
Expand All @@ -45,22 +56,26 @@ jobs:
paths.src_las=/inputs/730000_6360000.subset.prototype_format202.las
paths.output_dir=/outputs/

# This is somewhat redundant with unit test but may serve a a doc on usage ?
- name: Evaluate decisions using optimization task (debug mode means on a single, corrected LAS) using CLI.
run: >
docker run
-v /var/data/cicd/CICD_github_assets/M8.4/inputs/evaluation/:/inputs/
-v /var/data/cicd/CICD_github_assets/M8.4/outputs/evaluation/:/outputs/ lidar_prod_im
python lidar_prod/run.py
print_config=true
+task='optimize'
+building_validation.optimization.debug=true
building_validation.optimization.todo='prepare+evaluate+update'
building_validation.optimization.paths.input_las_dir=/inputs/
building_validation.optimization.paths.results_output_dir=/outputs/
building_validation.optimization.paths.building_validation_thresholds_pickle=/inputs/optimized_thresholds.pickle

- name: clean the server for further uses
# Everything ran so we tag the valid docker image to keep it
# This happens for push events, which are in particular
# triggered when a pull request is merged.
- name: Get the branch name into an environment variable.
if: github.event_name == 'push'
uses: nelonoel/[email protected]

- name: Print the branch name
if: github.event_name == 'push'
run: echo ${BRANCH_NAME}

- name: Tag the docker image with branch name
if: github.event_name == 'push'
run: docker tag lidar_prod_im:latest lidar_prod_im:${BRANCH_NAME}

- name: Dry run image so that is it not prunned
if: github.event_name == 'push'
run: docker run lidar_prod_im:${BRANCH_NAME} bash

- name: Clean dangling docker images
if: always() # always do it, even if something failed
run: docker system prune # remove obsolete docker images (take a HUGE amount of space)

Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Workflow name
name: "Documentation Build"

# Event that must trigger the workflow
on:
push:
branches:
- main # <- only on main branch
- add-documentation # <- on this branch until documentation is merged once in main.

jobs:

build-and-deploy:
runs-on: ubuntu-latest

# Use bash instead of sh for conda activation
defaults:
run:
shell: bash -l {0}

steps:
# Checkout the repository
- name: "Checkout"
uses: actions/checkout@v2

# See https://github.com/conda-incubator/setup-miniconda#caching-environments

# Setup empty conda environment
- name: Setup a conda-incubator with an empty conda env
uses: conda-incubator/setup-miniconda@v2
with:
python-version: 3.9.12
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
# Environment to create and activate for next steps
activate-environment: lidar_prod

# Cache the env
# See https://github.com/conda-incubator/setup-miniconda#caching-environments
- name: Get Date
id: get-date
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
shell: bash

- name: Cache conda environment
uses: actions/cache@v2
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('bash/setup_environment/requirements.yml') }}-${{ env.CACHE_NUMBER }}
id: cache

- name: Update environment if there was no cached env.
run: mamba env update -n lidar_prod -f bash/setup_environment/requirements.yml
if: steps.cache.outputs.cache-hit != 'true'

# 2. Sphinx part : install tool and dependencies
- name: "Build Sphinx Doc"
working-directory: ./docs/
run: make html

# 3. Déploiement sur les Github Pages

- name: "Deploy Github Pages"
uses: JamesIves/[email protected]
with:
BRANCH: gh-pages # <- Branch where generated doc files will be commited
FOLDER: ./docs/build/html/ # <- Dir where .nojekyll is created and from which to deploy github pages.
52 changes: 22 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,41 @@
FROM nvidia/cuda:11.3.1-devel-ubuntu20.04
FROM mambaorg/micromamba:latest

# set the IGN proxy, otherwise apt-get and other applications don't work
# from within our self-hoster action runner
ENV http_proxy 'http://192.168.4.9:3128/'
ENV https_proxy 'http://192.168.4.9:3128/'

# set the timezone, otherwise it asks for it... and freezes
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# all the apt-get installs
USER root
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
software-properties-common \
wget \
git \
postgis \
libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 # package needed for anaconda

# install anaconda
RUN wget --quiet https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh -O ~/anaconda.sh
RUN /bin/bash ~/anaconda.sh -b -p /opt/conda && \
rm ~/anaconda.sh
ENV PATH /opt/conda/bin:$PATH
software-properties-common \
wget \
git \
postgis


# /lidar becomes the working directory, where the repo content is copied.
# /lidar becomes the working directory, where the repo content
# (where this Dockerfile lives) is copied.
WORKDIR /lidar
COPY . .

# install the python packages via anaconda
RUN conda env create -f bash/setup_environment/requirements.yml

# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "lidar_prod", "/bin/bash", "-c"]
# Copy requirements so that pip installs can occur smootly.
COPY bash/setup_environment/requirements.yml /tmp/env.yaml
COPY bash/setup_environment/requirements.txt /tmp/requirements.txt

# install the python packages via anaconda
RUN micromamba create --yes --file /tmp/env.yaml
# Sets the environment name since it is not "base"
# This ensure that it is activate when usign "docker run ..."
ENV ENV_NAME lidar_prod
# Make RUN commands here use the environment
ARG MAMBA_DOCKERFILE_ACTIVATE=1
# List packages and their version
RUN micromamba list
# test if pdal is installed (a tricky library!)
RUN echo "Make sure pdal is installed:"
RUN python -c "import pdal"

# the entrypoint garanties that all command will be runned in the conda environment
ENTRYPOINT ["conda", \
"run", \
"-n", \
"lidar_prod"]

# cmd for a normal run (non evaluate)
# Example command to run the application from within the image
CMD ["python", \
"lidar_prod/run.py", \
"print_config=true", \
Expand Down
Loading