diff --git a/.Rbuildignore b/.Rbuildignore index 5ca465b..95b3786 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,7 @@ ^\.Rproj\.user$ ^data-raw$ ^\.devcontainer$ +^\.github$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index aa53181..d2886ca 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,7 +13,7 @@ "packages": "clang,clang-format,clang-tidy,cmake,doxygen,g++,gcc,libxt6,libxtst6,make,ninja-build" }, "ghcr.io/rocker-org/devcontainer-features/r-packages:1": { - "packages": "dplyr,devtools,ggplot2,jsonlite,methods,mockery,Rcpp,RcppEigen,scales,snowfall,TMB,tibble,tidyr,usethis", + "packages": "dplyr,devtools,ggplot2,jsonlite,methods,mockery,Rcpp,RcppEigen,scales,snowfall,spelling,TMB,tibble,tidyr,usethis", "installSystemRequirements": true }, // option to run rstudio. you can type rserver into the command line to diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..99a91c6 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,55 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + # Unncomment the following line once the tests are passing + # branches: [main] + pull_request: + +name: R-CMD-check.yaml + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + with: + # This will install Git LFS and checkout the LFS objects during the checkout process. + lfs: true + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/call-build-pkgdown.yml b/.github/workflows/call-build-pkgdown.yml new file mode 100644 index 0000000..7b429f8 --- /dev/null +++ b/.github/workflows/call-build-pkgdown.yml @@ -0,0 +1,16 @@ +# Checks that the pkgdown site builds for a repository, assuming that one +# already exists, but it does not actually deploy it. See +# call-update-pkgdown.yml for that. +name: call-build-pkgdown + +on: + # TODO: remove push trigger once tests are passing + push: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + call-workflow: + uses: nmfs-ost/ghactions4r/.github/workflows/build-pkgdown.yml@main \ No newline at end of file diff --git a/.github/workflows/call-doc-and-style-r.yml b/.github/workflows/call-doc-and-style-r.yml new file mode 100644 index 0000000..0bebcc1 --- /dev/null +++ b/.github/workflows/call-doc-and-style-r.yml @@ -0,0 +1,17 @@ +# Runs devtools::document() and styler::style_active_package(), then opens a +# pull request to the branch that had changes in the push that triggered the +# workflow. +name: call-doc-and-style-r + +on: + push: + # TODO: uncomment following lines once tests are passing + # branches: + # - main + workflow_dispatch: + +jobs: + call-workflow: + uses: nmfs-ost/ghactions4r/.github/workflows/doc-and-style-r.yml@main + secrets: + PAT: ${{ secrets.PAT }} \ No newline at end of file diff --git a/.github/workflows/call-pr-checklist.yml b/.github/workflows/call-pr-checklist.yml new file mode 100644 index 0000000..929c1c1 --- /dev/null +++ b/.github/workflows/call-pr-checklist.yml @@ -0,0 +1,44 @@ +# Adds a comment to a newly opened PR letting reviewers know what should be +# included in their review. +name: Add a comment with reviewer checklist when PR opened + +on: + # TODO: remove push trigger once tests are passing + push: + pull_request: + types: [opened] + +jobs: + pr-checklist: + runs-on: ubuntu-latest + name: pr-checklist + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: 'Comment PR' + uses: actions/github-script@v0.3.0 + if: github.event_name == 'pull_request' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var msg = `# Instructions for code reviewer + + Hello reviewer, thanks for taking the time to review this PR! + + - Please use this checklist during your review, checking off items that you have verified are complete, but feel free to skip over items that are not relevant! + - See the [GitHub documentation for how to comment on a PR](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/commenting-on-a-pull-request) to indicate where you have questions or changes are needed before approving the PR. + - Please use conventions in the [guidelines for conventional commit messages](https://www.conventionalcommits.org/) for both commit messages and comments. + - PR reviews are a great way to learn so feel free to share your tips and tricks. However, when suggesting changes to the PR that are optional please include \`nit:\` (for nitpicking) as the comment type. For example, \`nit:\` I prefer using a \`data.frame()\` instead of a \`matrix\` because ... + - Engage with the developer when they respond to comments and check off additional boxes as they become complete so the PR can be merged in when all the tasks are fulfilled. Make it clear when the PR is approved by selecting the approved status, and potentially by commenting on the PR with something like \`This PR is now ready to be merged, no additional changes are needed\`. + + ## Checklist + + - [ ] The PR is requested to be merged into the appropriate branch (typically dev). + - [ ] The code is well-designed. + - [ ] The functionality is good for the users of the code. + - [ ] Code coverage remains high, indicating the new code is tested. + - [ ] The code is commented and the comments are clear, useful, and mostly explain why instead of what. + - [ ] Code is appropriately documented. + ` + const { issue: { number: issue_number }, repo: { owner, repo } } = context; + github.issues.createComment({ issue_number, owner, repo, body: msg }); \ No newline at end of file diff --git a/.github/workflows/call-spell-check.yml b/.github/workflows/call-spell-check.yml new file mode 100644 index 0000000..23fa524 --- /dev/null +++ b/.github/workflows/call-spell-check.yml @@ -0,0 +1,16 @@ +# Runs devtools::spell_check(). +name: call-spell-check + +on: + pull_request: + branches: + - main + push: + # TODO: uncomment following lines once tests are passing + # branches: + # - main + workflow_dispatch: + +jobs: + call-workflow: + uses: nmfs-ost/ghactions4r/.github/workflows/spell-check.yml@main \ No newline at end of file diff --git a/.github/workflows/call-update-pkgdown.yml b/.github/workflows/call-update-pkgdown.yml new file mode 100644 index 0000000..8c19fa1 --- /dev/null +++ b/.github/workflows/call-update-pkgdown.yml @@ -0,0 +1,12 @@ +# Updates the exiting pkgdown site for a repository by deploying the changes +# made to the pkgdown site to a branch called gh-pages. +name: call-update-pkgdown + +on: + push: + # TODO: uncomment following lines once tests are passing + # branches: [main] + +jobs: + call-workflow: + uses: nmfs-ost/ghactions4r/.github/workflows/update-pkgdown.yml@main \ No newline at end of file diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml new file mode 100644 index 0000000..6040e55 --- /dev/null +++ b/.github/workflows/greetings.yml @@ -0,0 +1,26 @@ +name: Greetings + +on: [pull_request_target, issues] + +jobs: + greeting: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/first-interaction@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + issue-message: > + Thank you for contributing to ecosystemdata and opening your first issue + here! We are happy to have your contributions. We encourage you to + introduce yourself to the community on the [introduction thread in + our Discussions](https://github.com/orgs/NOAA-FIMS/discussions/801). + pr-message: > + Thank you for contributing to ecosystemdata and opening your first PR + here! We are happy to have your contributions. Please ensure that the + PR is made to the dev branch and let us know if you need any help! + Also, we encourage you to introduce yourself to the community on the + [introduction thread in our + Discussions](https://github.com/orgs/NOAA-FIMS/discussions/801). \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7cc8b6a..b27cb91 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ po/*~ # RStudio Connect folder rsconnect/ .Rproj.user +docs diff --git a/DESCRIPTION b/DESCRIPTION index 0790c43..ad50b08 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,18 +2,18 @@ Package: ecosystemdata Title: Ecosystem database of Ecopath with Ecosim and Atlantis models Version: 0.1.0 Authors@R: c( - person("Bai", "Li", email = "bai.li@noaa.gov", role = c("aut", "cre"), + person("Bai", "Li", , "bai.li@noaa.gov", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-8249-1442")), - person(c("Kelli", "F."), "Johnson", email = "kelli.johnson@noaa.gov", - role = "aut", comment = c(ORCID = "0000-0002-5149-451X")) + person(c("Kelli", "F."), "Johnson", , "kelli.johnson@noaa.gov", role = "aut", + comment = c(ORCID = "0000-0002-5149-451X")) ) -Description: Ecosystem database of Ecopath with Ecosim and Atlantis models. - The package provides functions to access and manipulate the ecosystem output - files from the Ecopath with Ecosim and Atlantis models. +Description: Ecosystem database of Ecopath with Ecosim and Atlantis + models. The package provides functions to access and manipulate the + ecosystem output files from the Ecopath with Ecosim and Atlantis + models. License: GPL (>= 3) | file LICENSE -Encoding: UTF-8 -Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +Depends: + R (>= 3.5) Imports: cli, dplyr, @@ -28,6 +28,8 @@ Suggests: testthat (>= 3.0.0), usethis Config/testthat/edition: 3 -Depends: - R (>= 3.5) +Encoding: UTF-8 +Language: en-US LazyData: true +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.3.2 diff --git a/R/ewe_nwatlantic.R b/R/ewe_nwatlantic.R index 99f564c..72ec57e 100644 --- a/R/ewe_nwatlantic.R +++ b/R/ewe_nwatlantic.R @@ -12,7 +12,7 @@ #' relative path. This column is helpful for understanding which EWE model #' and which run the data came from. #' } -#' \item{type}{The type refers to what data type this row is, e.g., landings, +#' \item{type}{The type refers to what data type this row is, e.g., landings, #' catch, biomass, weight, and mortality. #' } #' \item{year}{A four-digit integer specifying the year.} diff --git a/R/get_functional_groups.R b/R/get_functional_groups.R index c289961..a62326b 100644 --- a/R/get_functional_groups.R +++ b/R/get_functional_groups.R @@ -4,7 +4,7 @@ utils::globalVariables(c("V1", "V2")) #' #' @description #' Functional group names are useful for the column names of output data from -#' an EeW model, and thus, this function is a way to get them automatically +#' an EwE model, and thus, this function is a way to get them automatically #' from the EwE output. The functional group names come from the basic #' estimates file. #' @@ -39,12 +39,12 @@ get_functional_groups <- function(file_path) { out_vector <- utils::read.table( text = as.character(temp[-1]), sep = "," - ) |> + ) |> # Extract non-NA rows from the first column dplyr::filter(!is.na(V1)) |> # Pull the names of the functional groups dplyr::pull(V2) - + # Return a tibble with the functional groups, species, and group names split_functional_groups(out_vector) } diff --git a/R/load_.R b/R/load_.R index cd97355..99ceecf 100644 --- a/R/load_.R +++ b/R/load_.R @@ -7,7 +7,7 @@ utils::globalVariables(c("timestep", "group", "fleet", "month", "type", "year")) #' #' @param file_path The path to the CSV file containing the EwE output data. #' @param model_years A vector of years corresponding to the model years. TODO: this can be removed -#' after havgina a utility function to extract model years globally from annual data +#' after having a utility function to extract model years globally from annual data #' @param functional_groups A vector of names of the functional groups in the model. #' #' @export diff --git a/R/use_template.R b/R/use_template.R index c45f271..d8c3861 100644 --- a/R/use_template.R +++ b/R/use_template.R @@ -56,4 +56,4 @@ use_testthat_template <- function(name) { cli::cli_abort("{path} already exists.") } invisible(TRUE) -} \ No newline at end of file +} diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..3796f23 --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,4 @@ +url: https://NOAA-FIMS.github.io/ecosystemdata +template: + bootstrap: 5 + diff --git a/inst/WORDLIST b/inst/WORDLIST new file mode 100644 index 0000000..1623825 --- /dev/null +++ b/inst/WORDLIST @@ -0,0 +1,14 @@ +Brito +Buchheister +Chagaris +Cieri +Ecopath +Ecosim +EwE +Schueller +bookdown +fmars +nwatlantic +testthat +tibble +usethis \ No newline at end of file diff --git a/man/ewe_nwatlantic_base.Rd b/man/ewe_nwatlantic_base.Rd index f742aec..a950410 100644 --- a/man/ewe_nwatlantic_base.Rd +++ b/man/ewe_nwatlantic_base.Rd @@ -9,7 +9,7 @@ \subsection{\verb{EWE NW Atlantic}}{ A tibble with 35640 rows and the following -8 columns: +10 columns: \describe{ \item{file_name}{The path to the file name, note that the path could be a relative path. This column is helpful for understanding which EWE model @@ -28,7 +28,7 @@ row pertains to. } } -An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 35640 rows and 8 columns. +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 35640 rows and 10 columns. } \source{ \url{https://www.github.com/nmfs-ost/} diff --git a/man/get_functional_groups.Rd b/man/get_functional_groups.Rd index e82e8bd..65c5b3e 100644 --- a/man/get_functional_groups.Rd +++ b/man/get_functional_groups.Rd @@ -27,7 +27,7 @@ multiple groups. } \description{ Functional group names are useful for the column names of output data from -an EeW model, and thus, this function is a way to get them automatically +an EwE model, and thus, this function is a way to get them automatically from the EwE output. The functional group names come from the basic estimates file. } diff --git a/man/load_csv_ewe.Rd b/man/load_csv_ewe.Rd index 67cf739..5cff9bd 100644 --- a/man/load_csv_ewe.Rd +++ b/man/load_csv_ewe.Rd @@ -10,7 +10,7 @@ load_csv_ewe(file_path, model_years, functional_groups) \item{file_path}{The path to the CSV file containing the EwE output data.} \item{model_years}{A vector of years corresponding to the model years. TODO: this can be removed -after havgina a utility function to extract model years globally from annual data} +after having a utility function to extract model years globally from annual data} \item{functional_groups}{A vector of names of the functional groups in the model.} } diff --git a/tests/testthat/test-load_model.R b/tests/testthat/test-load_model.R index 2adfa3c..8414a35 100644 --- a/tests/testthat/test-load_model.R +++ b/tests/testthat/test-load_model.R @@ -26,12 +26,12 @@ model_years <- 1985:2017 test_that("load_model() works with correct inputs", { ewe_model <- load_model( directory = base_run_dir, - functional_groups = functional_groups, + functional_groups = functional_groups, type = "ewe" ) - + expected_colnames <- c( - "file_name", "type", "year", "month", "functional_group", + "file_name", "type", "year", "month", "functional_group", "value", "species", "group", "fleet", "reference" ) #' @description Test that load_model() returns correct columns.