Environment Set Up and Installation
Dependencies:
Ubuntu
Docker
VS Code
VS Code Extension: Dev Containers
VS Code Extension: Docker
VS Code Extension: Live Server
Create project from template
Click on the green button “Use this template” on GitHub.
Open VS Code and clone the repository.
Set up your docker configuration files:
check your
Dockerfile
check your
.devcontainer.json
mount your local/network folders
define vscode extensions
Build a new docker image using the Dockerfile:
# build docker image docker build . docker build -t <image-name>:<image-tag> . # list docker images docker images # enter docker image docker run -it <image-id> # remove docker image docker rmi <image-id>
Start your docker container using VS Code
open the project folder in VS Code
open the command palette (Ctrl+Shift+P)
select “Dev Containers: Reopen in Container” –> this uses the .devcontainer.json file to start the container
Install your local package
cd src pip install -e .
Install pre-commit and linters outside your container using pipx
pipx install pre-commit pipx install black pipx install black pipx install ruff pipx install pyment
** pre-commit** checks certain actions before committing changes to your repository. The list of actions that are executed are defined in
.pre-commit-config.yaml
.Install
pre-commit
:pipx install pre-commit
Enter into your git repository and install the hooks:
pre-commit install
(optional, but recommended)de-activate pre-commit:
delete or comment out the lines in .pre-commit-config.yaml
pre-commit uninstall
pre-commit clean
Your Environment is now set up and ready to go! Next set up your project.
Create project from scratch
Setup Kedro Project using venv. Follow the instructions from Kedro’s official documentation.
Create Kedro project directory:
mkdir kedro-geospatial && cd kedro-geospatial
Create and activate a new virtual environment
python3 -m venv .venv source .venv/bin/activate
Install Kedro inside the venv
pip install kedro # check installation kedro info
Create a new Kedro project
kedro new
Install the project dependencies
cd %project_name% pip install -r src/requirements.txt
Install Docker pluging for Kedro
kedro plugin install kedro-docker
Create a Dockerfile
kedro docker init
Edit the Dockerfile to meet your project needs
replace base image from
python:3.8-slim-buster
toosgeo/gdal:ubuntu-small-latest
ARG BASE_IMAGE=osgeo/gdal:ubuntu-small-latest FROM $BASE_IMAGE as runtime-environment
remove user creation from Dockerfile
update workdir to vscode workspace
ensure that data is not copied to the docker image
Build docker image
–> creates .devcontainer.json file
kedro docker build -t name:tag
Update your .devcontainer.json file to you personal config settings
mount your local config and data folder
define vscode extensions
Example:
template.devcontainer.json
Start your docker container using VS Code
open the project folder in VS Code
open the command palette (Ctrl+Shift+P)
select “Dev Containers: Reopen in Container” –> this uses the .devcontainer.json file to start the container
Install your dependencies
install using pip (no venv is necessary as docker is isolated)
update requirements.txt
pip freeze > src/requirements.txt
Close the container
open the command palette (Ctrl+Shift+P)
select “Dev Container: Reopen Folder locally”
Set up sphinx documentation
see kedro docs
open container
backup your docs folder created by kedro
delete
/docs/source/conf.py
and/docs/source/index.rst
init sphinx (separate source/build folders)
sphinx-quickstart docs
replace
conf.py
andindex.rst
with your backuped files.init module docstring documentation
sphinx-apidoc --module-first -o source ../src/<package_name>
from docs folder run
pip install -e ../src
Make sphinx compatible with GitHub Pages
update BUILDDIR to ../docs in make.bat and Makefile
add
.nojekyll
file to docs folderbuild html:
make html
--docs |--doctrees |--html |--index.html |.. |--source |-- conf.py |-- index.rst |.. |--make.bat |--Makefile
open
docs/index.html
in browserright click on index.html and select “Open with Live Server”
Init Git Repository and Publish to Github
Publish Sphinx Documentation to GitHub Pages optional, you can also publish from main
create a new branch
gh-pages
add
docs/build/html
to.gitignore
add
docs/build/html
togh-pages
branchcommit and push changes to
gh-pages
branchgo to GitHub > settings > Pages
select
gh-pages
branch as source for GitHub Pagesselect
docs/
as folder
open
https://<username>.github.io/<project_name>/
in browser
Your Environment is now set up and ready to go! Next set up your project.