-
Notifications
You must be signed in to change notification settings - Fork 71
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
Use bigger dtypes in routed models to expand number of supported pixels and implement docker container #1434
Merged
dcdenu4
merged 45 commits into
natcap:main
from
phargogh:bugfix/1431-sdr-and-probably-other-routed-models-have-int32-limitations
Oct 26, 2023
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
576f4c4
Adding a 2-phase docker build for testing.
phargogh 495ea32
Dockerfile syntaxerror RE:#1431
phargogh 8cac295
Installing apt packages with -y. RE:#1431
phargogh b9d38db
Allowing invest repo and build ref to be provided as build args. RE:#…
phargogh c9d72de
Trying to quote the strings instead to try to get default arg values …
phargogh 3195875
Build contexts are not shared between images. RE:#1431
phargogh 44d5b1e
Adding venv, making dirname depend on repo. RE:#1431
phargogh 55cb3d3
Updating requirements and removing wheel after build. RE:#1431
phargogh a90a795
Adding a docker container workflow building job.
phargogh efa1df2
Creating the environment file. RE:#1431
phargogh 6bfd67f
Removing the branch restriction for building the container. RE:#1431
phargogh bb64267
Sanitizing the github ref. RE:#1431
phargogh a3f951f
Using sed for substring replacement instead of bash builtings. GHA d…
phargogh 77be2d4
Not removing the wheel, not writeable. RE:#1431
phargogh beea25d
Adding requests to requirements. RE:#1431
phargogh 781789d
Adding requirements to the list of triggering files. RE:#1431
phargogh 5f5817e
Adding note about the docker container to HISTORY. RE:#1431
phargogh c181d28
Building latest pygeoprocessing and installing into container. RE:#1431
phargogh f6ea5ec
Passing invest repo and version to the build image. RE:#1431
phargogh eab9919
Sediment deposition now uses more memory, but can handle larger indexes.
phargogh 2d6cc1e
Noting change in HISTORY for SDR. RE:#1431
phargogh 0d647f3
Improving the number of pixels that can be included in the analysis.
phargogh 6acc0a7
Upping stack/heap memory usage for indexes in seasonal water yield's …
phargogh db1a05e
Using the latest pygeoprocessing commit on main.
phargogh c4b9e0f
Merge branch 'main' into bugfix/1431-sdr-and-probably-other-routed-mo…
phargogh 88d409e
Merge branch 'main' of https://github.com/natcap/invest into bugfix/1…
phargogh ef2b0bf
Merge branch 'bugfix/1431-sdr-and-probably-other-routed-models-have-i…
phargogh 274f669
Monitoring a few other paths for rebuilding docker image.
phargogh e6f850c
Replacing native pygeoprocessing builds with better yml generation.
phargogh 39ebcb3
Clearing pip cache during the build.
phargogh 65fd138
Rebuilding container if conda yml script changes. RE#1431
phargogh 4ca297d
Merge branch 'main' into bugfix/1431-sdr-and-probably-other-routed-mo…
phargogh f7119e8
Adding a compiler when we are building from source.
phargogh ce7c59d
Removing cxx-compiler and git after build completes. RE#1431
phargogh 544e647
Merge branch 'main' of https://github.com/natcap/invest into bugfix/1…
phargogh 1da2138
Merge branch 'bugfix/1431-sdr-and-probably-other-routed-models-have-i…
phargogh 4800f4a
Specifying the base prefix. RE:#1431
phargogh 8bfd8d0
Attempting to address a build warning about setuptools_scm/setuptools…
phargogh 4c82149
Allowing git lfs install to fail.
phargogh 8301c75
Restoring pygeoprocessing 2.4.0 requirement.
phargogh 76c84ba
Explicitly prohibiting uploading to the registry when part of a PR, j…
phargogh ab8400f
Removing the pip constraint on pygeoprocessing. RE:#1431
phargogh 89d840a
Adding a compiler if on linux or it's needed.
phargogh d9aeced
Fixing history message heading. RE:#1431
phargogh cd492aa
Removing failure-case handling for git lfs install. RE:#1431
phargogh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Build containers | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- 'docker/*' | ||
- '.github/workflows/build-docker.yml' | ||
- 'src/**/*' | ||
- 'requirements*.txt' | ||
- 'pyproject.toml' | ||
- 'setup.py' | ||
- 'scripts/convert-requirements-to-conda-yml.py' | ||
|
||
concurrency: | ||
# make sure only one run of this workflow for a given PR or a given branch | ||
# can happen at one time. previous queued or started runs will be cancelled. | ||
# github.workflow is the workflow name | ||
# github.ref is the ref that triggered the workflow run | ||
# on push, this is refs/heads/<branch name> | ||
# on pull request, this is refs/pull/<pull request number>/merge | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
env: | ||
# Customize this name if needed. | ||
# The repo name is a very reasonable default! | ||
CONTAINER_NAME: invest | ||
|
||
jobs: | ||
build: | ||
name: Build containers | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create environment file | ||
run: | | ||
python scripts/convert-requirements-to-conda-yml.py requirements.txt > docker/environment.yml | ||
|
||
- name: Build docker | ||
run: | | ||
# Replace / (invalid tag character) with . | ||
SANITIZED_REF="$(echo ${{github.ref_name}} | sed 's|/|.|g')" | ||
cd docker && docker build \ | ||
--build-arg="INVEST_REPO=${{ github.repository }}" \ | ||
--build-arg="INVEST_VERSION=${{ github.sha }}" \ | ||
-t ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest \ | ||
-t ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ github.sha }} \ | ||
-t ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${SANITIZED_REF} \ | ||
. | ||
|
||
- name: Test that GDAL and InVEST import | ||
run: | | ||
docker run --rm ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest python -c "from osgeo import gdal" | ||
docker run --rm ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest python -m natcap.invest --version | ||
|
||
- name: Push docker | ||
if: github.event_name != 'pull_request' | ||
run: docker image push --all-tags ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
environment.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Build the InVEST wheel in a separate container stage | ||
FROM debian:12.2 as build | ||
ARG INVEST_VERSION="main" | ||
ARG INVEST_REPO="natcap/invest" | ||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, we're updating these placeholders from the GHA workflow call. |
||
RUN apt update && apt install -y python3 python3-dev python3-pip python3-build build-essential git python3.11-venv | ||
RUN cd / && \ | ||
git clone https://github.com/${INVEST_REPO}.git && \ | ||
cd $(basename ${INVEST_REPO}) && \ | ||
git checkout ${INVEST_VERSION} && \ | ||
python3 -m build | ||
|
||
# Create the container for distribution that has runtime dependencies. | ||
FROM mambaorg/micromamba:1.5.0-bookworm-slim | ||
COPY --from=build /invest/dist/*.whl /tmp/ | ||
|
||
# The environment.yml file will be built during github actions. | ||
COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml /tmp/environment.yml | ||
RUN micromamba install -y -n base -c conda-forge -f /tmp/environment.yml && \ | ||
micromamba clean --all --yes && \ | ||
/opt/conda/bin/python -m pip install /tmp/*.whl && \ | ||
/opt/conda/bin/python -m pip cache purge && \ | ||
micromamba remove -y -n base cxx-compiler git | ||
|
||
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paths
here is a filter indicating we only run when a file in one of these paths has changed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. So the idea here was to only rebuild the container if there's something that will change the output of a model, like the source code, requirements, etc.