Skip to content

Commit

Permalink
prevent ties returning two tracts for one point (#14)
Browse files Browse the repository at this point in the history
* prevent ties returning two tracts for one point

* update renv

* add gha build

* gha syntax

* try again

* add year argument to gha test

* update v

Co-authored-by: Erika <erika.rasnick@gmail.com>
  • Loading branch information
cole-brokamp and erikarasnick authored Dec 15, 2021
1 parent c85514a commit 739d512
Show file tree
Hide file tree
Showing 7 changed files with 401 additions and 80 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/build-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Build & Deploy Docker Containers
on:
# We'll trigger this workflow when a PR is submitted to make sure
# your application still builds successfully with the new commits.
pull_request: []
# We'll also trigger this workflow when you want to deploy your container.
# This means any push to main. You might want to do a release trigger.
push:
branches:
- main
- master
# Let's also trigger a build and publish of your container when
# you release a new version. You can use "created" here instead of published.
release:
types: [published]

jobs:
deploy-images:
runs-on: ubuntu-latest

# Define your registry and repository here.
# These are for the GitHub Container registry, you can also use
# Quay.io or another OCI registry
env:
registry: ghcr.io
username: degauss-org
repository: census_block_group

strategy:
# Even if one docker container build fails we want the others to continue.
fail-fast: false
# A matrix of Dockerfile paths and associated tags
# Dockerfile in root builds to tag latest
matrix:
dockerfile: [[Dockerfile, latest]]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set Container Tag Normal
run: |
container="${{ env.registry }}/${{ env.username}}/${{ env.repository }}:${{ matrix.dockerfile[1] }}"
echo "container=${container}" >> $GITHUB_ENV
# On a new release create a container with the same tag as the release.
- name: Set Container Tag Release
if: github.event_name == 'release'
run: |
versioned="${{ env.registry }}/${{ env.username}}/${{ env.repository }}:${GITHUB_REF##*/}"
echo "versioned=${versioned}" >> $GITHUB_ENV
# On a PR create a "test" container with the same tag as the branch name.
- name: Set Branch Tag Release
if: github.event_name == 'pull_request'
run: |
versioned="${{ env.registry }}/${{ env.username}}/${{ env.repository }}:${GITHUB_HEAD_REF}"
echo "versioned=${versioned}" >> $GITHUB_ENV
- name: Build ${{ matrix.dockerfile[1] }}
run: |
printf "Preparing to build ${{ env.container }} from ${{ matrix.dockerfile[0] }}"
if [ ! -f "${{ matrix.dockerfile[0]}}" ]; then
printf "Dockerfile ${{ matrix.dockerfile[0] }} does not exist"
exit 1;
fi
docker build -f ${{ matrix.dockerfile[0] }} -t ${{ env.container }} .
docker images
- name: Test ${{ matrix.dockerfile[1] }}
run: |
printf "Testing ${{ env.container }}"
docker run --rm -v "${PWD}/test":/tmp ${{ env.container }} my_address_file_geocoded.csv 2010
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.registry }}
username: ${{ env.username }}
password: ${{ secrets.GITHUB_TOKEN }}

# Example variables for a non GitHub registry like Quay or Docker Hub
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

# Deploy branch container on pull request
- name: Test Deploy ${{ env.versioned }}
if: github.event_name == 'pull_request'
run: |
docker tag ${{ env.container }} ${{ env.versioned }}
docker push ${{ env.versioned }}
# Deploy release container on release
- name: Deploy ${{ env.versioned }}
if: github.event_name == 'release'
run: |
docker tag ${{ env.container }} ${{ env.versioned }}
docker push ${{ env.versioned }}
docker push ${{ env.container }}
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM rocker/r-ver:4.0.0

RUN R --quiet -e "install.packages('remotes', repos = 'https://packagemanager.rstudio.com/all/__linux__/focal/latest')"
# make sure version matches what is used in the project: packageVersion('renv')
ENV RENV_VERSION 0.13.2
ENV RENV_VERSION 0.14.0
RUN R --quiet -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"

WORKDIR /app
Expand All @@ -19,12 +19,12 @@ RUN apt-get update \
COPY renv.lock .
RUN R --quiet -e "renv::restore(repos = c(CRAN = 'https://packagemanager.rstudio.com/all/__linux__/focal/latest'))"

COPY block_groups_2020_5072.rds .
COPY block_groups_2010_5072.rds .
COPY block_groups_2000_5072.rds .
COPY block_groups_1990_5072.rds .
COPY tracts_1980_5072.rds .
COPY tracts_1970_5072.rds .
ADD https://geomarker.s3.us-east-2.amazonaws.com/geometries/block_groups_2020_5072.rds .
ADD https://geomarker.s3.us-east-2.amazonaws.com/geometries/block_groups_2010_5072.rds .
ADD https://geomarker.s3.us-east-2.amazonaws.com/geometries/block_groups_2000_5072.rds .
ADD https://geomarker.s3.us-east-2.amazonaws.com/geometries/block_groups_1990_5072.rds .
ADD https://geomarker.s3.us-east-2.amazonaws.com/geometries/tracts_1980_5072.rds .
ADD https://geomarker.s3.us-east-2.amazonaws.com/geometries/tracts_1970_5072.rds .
COPY census_block_group.R .

WORKDIR /tmp
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
## DeGAUSS example call

```sh
docker run --rm -v $PWD:/tmp degauss/census_block_group:0.4.0 my_address_file_geocoded.csv 2010
docker run --rm -v $PWD:/tmp degauss/census_block_group:0.4.1 my_address_file_geocoded.csv 2010
```

* The first argument (`my_address_file_geocoded.csv`) is the name of your geocoded csv file.
Expand Down
4 changes: 2 additions & 2 deletions census_block_group.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/local/bin/Rscript

dht::greeting(geomarker_name = 'census_block_group',
version = '0.4.0',
version = '0.4.1',
description = 'adds census block group or tract identifiers to geocoded addresses')

dht::qlibrary(dplyr)
Expand Down Expand Up @@ -51,7 +51,7 @@ if (opt$census_year %in% c('1980', '1970')) {
}

message('\nfinding containing geography for each point...')
d <- sf::st_join(d, geography, left = FALSE)
d <- sf::st_join(d, geography, left = FALSE, largest = TRUE)

if(! opt$census_year %in% c('1980', '1970')) {
d <- d %>%
Expand Down
78 changes: 39 additions & 39 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
},
"R6": {
"Package": "R6",
"Version": "2.5.0",
"Version": "2.5.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "b203113193e70978a696b2809525649d"
"Repository": "RSPM",
"Hash": "470851b6d5d0ac559e9d01bb352b4021"
},
"RColorBrewer": {
"Package": "RColorBrewer",
Expand Down Expand Up @@ -130,10 +130,10 @@
},
"cli": {
"Package": "cli",
"Version": "2.3.1",
"Version": "3.1.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "3e3f28efcadfda442cd18651fbcbbecf"
"Hash": "66a3834e54593c89d8beefb312347e58"
},
"clipr": {
"Package": "clipr",
Expand All @@ -151,24 +151,24 @@
},
"cpp11": {
"Package": "cpp11",
"Version": "0.2.6",
"Version": "0.4.2",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "f08909ebdad90b19d8d3930da4220564"
"Repository": "RSPM",
"Hash": "fa53ce256cd280f468c080a58ea5ba8c"
},
"crayon": {
"Package": "crayon",
"Version": "1.4.1",
"Version": "1.4.2",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "e75525c55c70e5f4f78c9960a4b402e9"
"Repository": "RSPM",
"Hash": "0a6a65d92bd45b47b94b84244b528d17"
},
"credentials": {
"Package": "credentials",
"Version": "1.3.0",
"Version": "1.3.2",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "a96728288c75a814c900af9da84387be"
"Repository": "RSPM",
"Hash": "93762d0a34d78e6a025efdbfb5c6bb41"
},
"curl": {
"Package": "curl",
Expand All @@ -186,22 +186,22 @@
},
"desc": {
"Package": "desc",
"Version": "1.2.0",
"Version": "1.4.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "6c8fe8fa26a23b79949375d372c7b395"
"Repository": "RSPM",
"Hash": "28763d08fadd0b733e3cee9dab4e12fe"
},
"dht": {
"Package": "dht",
"Version": "0.0.0.9000",
"Version": "0.3.0",
"Source": "GitHub",
"RemoteType": "github",
"RemoteHost": "api.github.com",
"RemoteRepo": "dht",
"RemoteUsername": "degauss-org",
"RemoteRef": "HEAD",
"RemoteSha": "213b313a13c9a089c2ebbab8ca24a32e5d65975d",
"Hash": "175011676ad4df8d0a66331e3d89c6c1"
"RemoteSha": "aaf71e0c0c7f29b69d0de2f6865a83bd95156a00",
"Hash": "b3cc8e7666d85913c45d76ae58acbc57"
},
"digest": {
"Package": "digest",
Expand Down Expand Up @@ -282,10 +282,10 @@
},
"generics": {
"Package": "generics",
"Version": "0.1.0",
"Version": "0.1.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "4d243a9c10b00589889fe32314ffd902"
"Repository": "RSPM",
"Hash": "3f6bcfb0ee5d671d9fd1893d2faa79cb"
},
"gert": {
"Package": "gert",
Expand All @@ -303,10 +303,10 @@
},
"gh": {
"Package": "gh",
"Version": "1.2.0",
"Version": "1.3.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "05129b4387282404780d2f8593636388"
"Repository": "RSPM",
"Hash": "38c2580abbda249bd6afeec00d14f531"
},
"gitcreds": {
"Package": "gitcreds",
Expand Down Expand Up @@ -408,10 +408,10 @@
},
"lifecycle": {
"Package": "lifecycle",
"Version": "1.0.0",
"Version": "1.0.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "3471fb65971f1a7b2d4ae7848cf2db8d"
"Repository": "RSPM",
"Hash": "a6b6d352e3ed897373ab19d8395c98d0"
},
"lubridate": {
"Package": "lubridate",
Expand Down Expand Up @@ -548,10 +548,10 @@
},
"ps": {
"Package": "ps",
"Version": "1.3.2",
"Version": "1.6.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "98777535b61c57d1749344345e2a4ccd"
"Hash": "32620e2001c1dce1af49c49dccbb9420"
},
"purrr": {
"Package": "purrr",
Expand Down Expand Up @@ -590,10 +590,10 @@
},
"renv": {
"Package": "renv",
"Version": "0.12.5",
"Version": "0.14.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "5c0cdb37f063c58cdab3c7e9fbb8bd2c"
"Hash": "30e5eba91b67f7f4d75d31de14bbfbdc"
},
"reprex": {
"Package": "reprex",
Expand Down Expand Up @@ -758,10 +758,10 @@
},
"usethis": {
"Package": "usethis",
"Version": "2.0.1",
"Version": "2.1.5",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "360e904f9e623286e1a0c6ca0a98c5f6"
"Repository": "RSPM",
"Hash": "c499f488e6dd7718accffaee5bc5a79b"
},
"utf8": {
"Package": "utf8",
Expand Down Expand Up @@ -800,10 +800,10 @@
},
"withr": {
"Package": "withr",
"Version": "2.4.1",
"Version": "2.4.3",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "caf4781c674ffa549a4676d2d77b13cc"
"Repository": "RSPM",
"Hash": "a376b424c4817cda4920bbbeb3364e85"
},
"xfun": {
"Package": "xfun",
Expand Down
1 change: 1 addition & 0 deletions renv/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local/
lock/
library/
python/
Expand Down
Loading

0 comments on commit 739d512

Please sign in to comment.