National Infrastructure Resilience Demonstrator (NIRD)
Clone this repository:
git clone git@github.com:nismod/DAFNI-NIRD.git
(Or, if you prefer to use HTTPS authentication, git clone https://github.com/nismod/DAFNI-NIRD.git)
Move into the cloned folder:
cd DAFNI-NIRD
Create a conda environment using
micromamba
to install packages specified in the environment.yaml
file:
micromamba env create -f environment.yaml
(In case micromamba fails to install pip packages, you can install them manually
by running micromamba activate nerd then pip install --editable .[dev])
Activate it:
micromamba activate nird
Configure the pre-commit checks:
pre-commit install
There are several tools and helpers set up to run automatically, on git commit
and in GitHub Actions continuous
integration steps. Each of these can be run locally too.
Run the tests using pytest:
python -m pytest
Run formatting using black:
black .
Run linting using ruff:
ruff check .
Run type-checking using mypy:
mypy --strict .
To install new packages, add them to environment.yaml then run:
micromamba install -f environment.yaml
To add new pre-commit hooks, configure them in .pre-commit-config.yaml then run:
pre-commit run --all-files
The documentation site is developed in the ./docs directory using Sphinx.
To build the docs:
cd docs
# generate the API docs (this pulls information from the code and docstrings)
sphinx-apidoc -M -o source/api ../src/nird/ --force
# build the documentation site
make htmlTo preview the site:
cd build/html
python -m http.server
Then open a browser at the address shown (e.g. http://0.0.0.0:8000).
This repository builds two images: nismod/nird_road-recovery and
nismod/nird_road-damages. The Dockerfiles, wrapper shell scripts and DAFNI
metadata model definitions are found in this repository at
containers/nird_road.
# Build the image - run this from the root of the repository
docker build -f ./containers/nird_road/Dockerfile-recovery -t nismod/nird_road-recovery:latest .# Run image using test data - run this from the data directory
docker run --rm -v ${PWD}/test_inputs:/data/inputs -v ${PWD}/test_outputs:/data/outputs --env NUMBER_CPUS=1 --env DEPTH_THRESHOLD=30 nismod/nird_road-recovery# Save image to file
docker save -o nird_road-recovery.tar nismod/nird_road-recovery:latestThen upload the saved image and corresponding model definition .yml to DAFNI.
This project was developed as part of a UKRI-funded research grant, reference ST/Y003780/1, supported by STFC and DAFNI, within the "Building a Secure and Resilient World" theme.