-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from AgPipeline/develop
Merge develop into master
- Loading branch information
Showing
9 changed files
with
291 additions
and
29 deletions.
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,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Checking the results of running the docker commands | ||
|
||
# Define expected results | ||
EXPECTED_FILES=("result.json") | ||
EXPECTED_CANOPYCOVER_VALUES=(99.75714285714285 20.91874906479126) | ||
|
||
# What folder are we looking in for outputs | ||
if [[ ! "${1}" == "" ]]; then | ||
TARGET_FOLDER="${1}" | ||
else | ||
TARGET_FOLDER="./outputs" | ||
fi | ||
|
||
# What our target file to read is | ||
if [[ ! "${2}" == "" ]]; then | ||
CHECK_FILE="${2}" | ||
else | ||
CHECK_FILE="canopycover.csv" | ||
fi | ||
EXPECTED_FILES+=("${CHECK_FILE}") | ||
|
||
# Check if expected files are found | ||
for i in $(seq 0 $(( ${#EXPECTED_FILES[@]} - 1 ))) | ||
do | ||
if [[ ! -f "${TARGET_FOLDER}/${EXPECTED_FILES[$i]}" ]]; then | ||
echo "Expected file ${EXPECTED_FILES[$i]} is missing" | ||
exit 10 | ||
fi | ||
done | ||
|
||
# Check the results of the canopy cover calculation | ||
RESULT_VALUES=(`gawk ' | ||
BEGIN { | ||
FPAT = "([^,]+)|(\"[^\"]+\")" | ||
} | ||
{ | ||
if ($1 != "local_datetime") { # Skipping the header line | ||
printf("%s\n", $2) | ||
} | ||
} | ||
END { | ||
} | ||
' "${TARGET_FOLDER}/${CHECK_FILE}"`) | ||
|
||
echo "Result counts: ${#EXPECTED_CANOPYCOVER_VALUES[@]} vs ${#RESULT_VALUES[@]}" | ||
if [[ ${#EXPECTED_CANOPYCOVER_VALUES[@]} != ${#RESULT_VALUES[@]} ]]; then | ||
echo "Number of results found in file (${#RESULT_VALUES[@]}) don't match expected count (${#EXPECTED_CANOPYCOVER_VALUES[@]})" | ||
if [[ ${#RESULT_VALUES[@]} > 0 ]]; then | ||
for i in $(seq 0 $(( ${#RESULT_VALUES[@]} - 1 ))) | ||
do | ||
echo "${i}: ${RESULT_VALUES[$i]}" | ||
done | ||
fi | ||
exit 20 | ||
fi | ||
|
||
for i in $(seq 0 $(( ${#EXPECTED_CANOPYCOVER_VALUES[@]} - 1 ))) | ||
do | ||
if [[ "${EXPECTED_CANOPYCOVER_VALUES[$i]}" == "${RESULT_VALUES[$i]}" ]]; then | ||
echo "Values for index ${i} match: '${RESULT_VALUES[$i]}' '${EXPECTED_CANOPYCOVER_VALUES[$i]}'" | ||
else | ||
echo "Result value for index ${i}: '${RESULT_VALUES[$i]}' doesn't match expected: '${EXPECTED_CANOPYCOVER_VALUES[$i]}'" | ||
exit 30 | ||
fi | ||
done |
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,65 @@ | ||
name: Testing Docker image | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
branches: | ||
- master | ||
- develop | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
docker_testing: | ||
runs-on: ubuntu-latest | ||
name: Running Docker testing | ||
steps: | ||
- name: Fetch source code | ||
uses: actions/checkout@v2 | ||
- name: Create folders | ||
run: | | ||
mkdir ./inputs && chmod 777 ./inputs | ||
mkdir ./outputs && chmod 777 ./outputs | ||
- name: List folder contents | ||
run: | | ||
echo "Current folder" && ls -la | ||
echo "test_data" && ls -l ./test_data | ||
- name: Copy testing data files | ||
run: | | ||
cp "${PWD}/test_data"/* "${PWD}/inputs/" | ||
echo "inputs" && ls -l ./inputs | ||
- name: Folder contents | ||
run: | | ||
echo "Current folder" && ls -l | ||
echo "Inputs folder" && ls -l ./inputs | ||
echo "Outputs folder" && ls -l ./outputs | ||
- name: Build docker image | ||
run: docker build -t canopycover_test:latest ./ | ||
- name: Compress docker image | ||
run: docker save canopycover_test:latest | gzip -7 -c - > canopycover_test_image.tar.gz | ||
- name: Upload docker image | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: canopycover_test_image | ||
path: canopycover_test_image.tar.gz | ||
- name: Run docker test | ||
run: docker run --rm -v "${PWD}/inputs:/inputs" -v "${PWD}/outputs:/outputs" canopycover_test:latest --working_space /outputs --metadata /inputs/meta.yaml /inputs/rgb_17_7_W.tif /inputs/mask_1.tif | ||
- name: Output folder contents | ||
run: echo "Outputs folder" && ls -l ./outputs | ||
- name: Check outputs | ||
run: | | ||
cat outputs/canopycover.csv | ||
chmod +x "./.github/workflows/docker_test_check_rgb.sh" | ||
"./.github/workflows/docker_test_check_rgb.sh" | ||
artifact_cleanup: | ||
runs-on: ubuntu-latest | ||
needs: [docker_testing] | ||
name: Cleanup artifacts upon success | ||
steps: | ||
- name: Remove docker artifact | ||
uses: geekyeggo/delete-artifact@v1 | ||
with: | ||
name: canopycover_test_image |
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 |
---|---|---|
@@ -1,6 +1,53 @@ | ||
FROM agdrone/agpypeline:1.0 | ||
FROM ubuntu:18.04 | ||
LABEL maintainer="Chris Schnaufer <[email protected]>" | ||
|
||
# Add user | ||
RUN useradd -u 49044 extractor \ | ||
&& mkdir /home/extractor | ||
RUN chown -R extractor /home/extractor \ | ||
&& chgrp -R extractor /home/extractor | ||
|
||
# Install the Python version we want | ||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y --no-install-recommends \ | ||
python3.7 \ | ||
python3-pip && \ | ||
ln -sfn /usr/bin/python3.7 /usr/bin/python && \ | ||
ln -sfn /usr/bin/python3.7 /usr/bin/python3 && \ | ||
ln -sfn /usr/bin/python3.7m /usr/bin/python3m && \ | ||
apt-get autoremove -y && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Perform some upgrades | ||
RUN python3 -m pip install --upgrade --no-cache-dir pip | ||
RUN python3 -m pip install --upgrade --no-cache-dir setuptools | ||
|
||
# Install applications we need | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
python3-gdal \ | ||
gdal-bin \ | ||
libgdal-dev \ | ||
gcc \ | ||
g++ \ | ||
python3.7-dev && \ | ||
python3 -m pip install --upgrade --no-cache-dir \ | ||
wheel && \ | ||
python3 -m pip install --upgrade --no-cache-dir \ | ||
numpy && \ | ||
python3 -m pip install --upgrade --no-cache-dir \ | ||
pygdal==2.2.3.* && \ | ||
apt-get remove -y \ | ||
libgdal-dev \ | ||
gcc \ | ||
g++ \ | ||
python3-dev && \ | ||
apt-get autoremove -y && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY requirements.txt packages.txt /home/extractor/ | ||
|
||
USER root | ||
|
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
Oops, something went wrong.