Skip to content

ternandsparrow/natcap-invest-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo is a docker wrapper around NatCap's InVEST: https://github.com/natcap/invest.

Currently the focus is on running the pollination model but it could easily be adapted to run any of the other models.

Running the image

The image is built and deployed on DockerHub so you don't need to clone this repo to run it. You only need to clone if you're going to do some development.

We use a version scheme for GitHub and DockerHub tags: {our version}_{InVEST version}, for example 1.0.0_3.4.2 means 1.0.0 is our version and we're using version 3.4.2 of InVEST. Check DockerHub for the latest tag.

The image contains all the data it needs to run the pollination model, we just want to mount a volume so we can get the results on the host.

mkdir /tmp/output
# it takes less than 2 minutes to run usually
docker run \
 --rm \
 -it \
 -v /tmp/output:/workspace \
 ternandsparrow/natcap-invest-docker:1.1.3_3.8.9

sudo chown -R `id -u` /tmp/output
# now browse to /tmp/output to see the output files

We use the -it flag so we get log output in a timely manner. You can leave it out but the log messages don't seem to be flushed until the end of the run.

Building the image locally

The build is fully automated and will download everything it needs.

tagVersion=1.1.3_3.8.9 # TODO change this to suit
cd natcap-invest-docker/
docker build -t ternandsparrow/natcap-invest-docker:$tagVersion
# see above for how to run it

Remote debugging the container

We can use ptvsd to let us connect a remote debugger (like vscode) to the Docker container. You can do it like this:

  1. clone this repo
  2. make sure your local code exactly matches the code inside the container (use git checkout <some tag> for an easy way to sync with a tagged docker container). It doesn't seem to matter if you have the dependencies installed on your host, the sources must be pulled from the docker container.
  3. open your debugger, let's assume vscode because we already have the launch.json configured in this repo. Make sure you have this repo/project/directory open in vscode
  4. launch the docker container, as you would above, but with these additional parameters -e PTVSD_ENABLE=1 -p 3000:3000. This will set the env var to enable remote debugging and open a port to connect to the debug server
  5. the container will enable remote debugging and wait for your debugger to attach. Once attached, we trigger a breakpoint so you can set your own breakpoints before execution continues

Changelog

1.1.4_3.8.9

  • move sample data from /data/pollination to /data/pollination-sample

1.1.3_3.8.9

  • update to 3.8.9 of InVEST
  • update docker base image to one with that is still supported and has 2.x GDAL

1.1.2_3.8.0

  • fix the entrypoint
  • add remote (outside container) debugging capability

1.1.1_3.8.0

  • move to version 3.8.0 of invest
  • using python 3.7 now, not that if affects the external facing API of our app

1.1.1_3.6.0

  • streamline install of python requirements

1.1.0_3.6.0

  • move to version 3.6.0 of invest (model runtimes seem to have doubled)