Skip to content

Commit

Permalink
Merge pull request #95 from USEPA/main
Browse files Browse the repository at this point in the history
Merging main branch into state level
  • Loading branch information
knoiva-indecon authored Oct 11, 2023
2 parents 8811151 + 6d3bf9d commit bb5ba2a
Show file tree
Hide file tree
Showing 229 changed files with 16,126 additions and 369,245 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/build_fredi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
### https://github.com/actions/upload-artifact
### https://github.blog/changelog/2021-11-10-github-actions-input-types-for-manual-workflows/
### https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows
### https://github.com/r-lib/actions/tree/v2/setup-r-dependencies
### https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution
### For uploading artifacts:
### "path:" is the output path where Pandoc will write the compiled PDF.
### Note, this should be the same directory as the input paper.md
name: Build FrEDI Package

on: [workflow_dispatch]

jobs:
compile_data:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

name: Load Package Code
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup R
uses: r-lib/actions/setup-r@v2

- name: Setup R package dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
cache: true
cache-version: 1
packages: |
any::tidyverse
any::ggpubr
any::openxlsx
any::devtools
- name: Remove existing build
run: |
rm *.tar.gz
- name: Run create_DoW_results
run: |
Rscript -e '
### Main repo path, FrEDI project path, scripts path
rPath0 <- ".";
pPath0 <- rPath0 |> file.path("FrEDI")
oPath0 <- pPath0 |> file.path("data", "defaultResults.rda")
###### Create Default Results ######
pPath0 |> devtools::load_all()
defaultResults <- run_fredi()
save(defaultResults, file=oPath0))
###### Update Documentation ######
###### - Build Manual
###### - Add and build vignettes
###### - Generate Documentation
roxygen2::roxygenise(pPath0)
devtools::document(pkg = pPath0)
# devtools::build_manual(pkg = pPath0)
# devtools::build_vignettes(pkg = pPath0)
###### Build Package ######
###### - Build Package but don't include vignettes
devtools::build(pkg=pPath0, path=rPath0)
'
- name: Commit results
run: |
git config --local core.autocrlf false
git config --local user.email "${{ github.actor }}@users.noreply.github.com"
git config --local user.name "${{ github.actor }}"
git add *.tar.gz
git pull origin ${{ github.head_ref }} --autostash --rebase -X ours
git commit -a -m "New package build"
git push
168 changes: 168 additions & 0 deletions .github/workflows/test_fredi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
### https://github.com/actions/upload-artifact
### https://github.blog/changelog/2021-11-10-github-actions-input-types-for-manual-workflows/
### https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows
### https://github.com/r-lib/actions/tree/v2/setup-r-dependencies
### https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution
### For uploading artifacts:
### "path:" is the output path where Pandoc will write the compiled PDF.
### Note, this should be the same directory as the input paper.md
name: Test FrEDI Package

# on: [workflow_dispatch]
on:
workflow_dispatch:
inputs:
run_tests:
type: choice
description: Run general tests
required: true
options:
- no
- yes
make_figures:
type: choice
description: Create report figures
required: true
options:
- no
- yes

jobs:
compile_data:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

name: Load Package Code
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Send input status
run: |
echo "${{ inputs.run_tests }} ${{ inputs.make_figures }}"
- name: Setup R
uses: r-lib/actions/setup-r@v2

- name: Setup R package dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
cache: true
cache-version: 1
packages: |
any::tidyverse
any::ggpubr
any::openxlsx
any::devtools
- name: Install FrEDI
run: |
Rscript -e '
devtools::install_github(
repo = "https://github.com/USEPA/FrEDI",
ref = "main",
subdir = "FrEDI",
dependencies = FALSE,
upgrade = "never",
force = TRUE,
type = "source"
)'
- name: Run create_DoW_results
run: |
Rscript -e '
### Which tests to do
do_tests <- "${{ inputs.run_tests }}" == "true"
do_figs <- "${{ inputs.make_figures }}" == "true"
### Main repo path, FrEDI project path, scripts path
rPath0 <- ".";
pPath0 <- rPath0 |> file.path("FrEDI")
sPath0 <- pPath0 |> file.path("scripts")
rPath0 |> list.files() |> print()
pPath0 |> list.files() |> print()
sPath0 |> list.files() |> print()
### Load FrEDI
pPath0 |> devtools::load_all()
### Where to save results
oPath0 <- pPath0 |> file.path("data_tests")
oPath1 <- oPath0 |> file.path("general")
oPath2 <- oPath0 |> file.path("report_figures")
### Test results
if(do_tests){
### Run FrEDI
results0 <- run_fredi()
### Run tests
tests0 <- results0 |> general_fredi_test(
outPath = oPath1,
save = TRUE,
return = TRUE,
overwrite = TRUE
)
### Create plot totals
listResults <- create_default_tablePlot()
save0 <- listResults |> save(file= oPath1 |> file.path("defaultScenarioTotals.rda")) |> try()
### Remove results
rm(results0, test0, listResults)
}
### Create report results
if(do_figs){
### Load source
sPath0 |> file.path("create_DoW_results.R") |> source()
### Create report figures
reports0 <- create_DoW_results(
outPath = oPath2,
saveFile = TRUE,
loadCode = "project",
silent = FALSE,
testing = TRUE,
return = FALSE,
fpath = pPath0
)
### Figure H results
results0 <- run_fredi(aggLevels=c("modelaverage", "national"))
results0 <- results0 |> filter(year %in% seq(2010, 2090, by=5))
save0 <- write.csv(results0, file=oPath1 |> file.path("FigH_results.csv", row.names=F)) |> try()
}
'
- name: Upload Tests
if: |
inputs.run_tests == 'yes'
uses: actions/upload-artifact@v3
with:
name: Test Data
path: |
./FrEDI/data_tests/general/defaultScenarioTotals.rda
./FrEDI/data_tests/general/testResults_fredi_general.xlsx
- name: Upload Report Figures
if: |
inputs.make_figures == 'yes'
uses: actions/upload-artifact@v3
with:
name: Report Data
path: |
./FrEDI/data_tests/report_figures/
./FrEDI/data_tests/general/FigH_results.csv
# #
# - name: Commit results
# run: |
# git config --local core.autocrlf false
# git config --local user.email "${{ github.actor }}@users.noreply.github.com"
# git config --local user.name "${{ github.actor }}"
# git add data/tmp_sysdata.rda
# git add data_tests/**.xlsx
# git pull origin ${{ github.head_ref }} --autostash --rebase -X ours
# git commit -a -m "Updated temporary system data and tests"
# git push

File renamed without changes.
45 changes: 23 additions & 22 deletions FrEDI/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@ Package: FrEDI
Title: The Framework for Evaluating Damages and Impacts (FrEDI)
Version: 3.4
Authors@R: c(person("Corinne", "Hartin",
email = "[email protected]",
role = c("aut","cre"),
email = "[email protected]",
role = c("aut","cre"),
comment = c(ORCID = "0000-0003-1834-6539",
github = "cahartin")),
person("Erin","McDuffie",
email = "[email protected]",
role = c("aut","ctb"),
comment = c(ORCID = "0000-0002-6845-6077",
github = "emcduffie")),
person("Karen","Noiva",
role = c("aut","ctb"),
comment = c(github = "knoiva-indecon")),
person("Will","Maddock",
role = "ctb",
comment = c(github = "maddockw")),
person("Tony","Gardella",
role = "ctb",
comment = c(github = "tonygard-indecon"))
)
github = "cahartin")),
person("Erin","McDuffie",
email = "[email protected]",
role = c("aut","ctb"),
comment = c(ORCID = "0000-0002-6845-6077",
github = "emcduffie")),
person("Karen","Noiva",
role = c("aut","ctb"),
comment = c(ORCID = "0000-0002-4412-5302",
github = "knoiva-indecon")),
person("Will","Maddock",
role = "ctb",
comment = c(ORCID = "0000-0002-6107-0315",
github = "maddockw")),
person("Tony","Gardella",
role = "ctb",
comment = c(ORCID = "0000-0003-4380-3412",
github = "tonygard-indecon"))
)
URL: https://usepa.github.io/FrEDI, https://epa.gov/cira/FrEDI/, https://github.com/USEPA/FrEDI/
Description: This R package models damages and impacts from climate change in the contiguous United States (CONUS)
using the Framework for Evaluating Damages and Impacts (FrEDI) developed as part of the Climate Change Impacts and
Expand All @@ -33,13 +36,11 @@ License: file LICENSE
Encoding: UTF-8
Depends: R (>= 3.5.0),
tidyverse,
dplyr,
ggplot2,
tidyr,
ggpubr,
openxlsx
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
LazyData: TRUE
Suggests: knitr, rmarkdown, prettydoc
Suggests: knitr, rmarkdown, prettydoc, devtools
VignetteBuilder: knitr
Language: en-US
Loading

0 comments on commit bb5ba2a

Please sign in to comment.