Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
^\.Rproj\.user$
^data-raw$
^\.devcontainer$
^\.github$
^_pkgdown\.yml$
^docs$
^pkgdown$
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
55 changes: 55 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -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")'
16 changes: 16 additions & 0 deletions .github/workflows/call-build-pkgdown.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions .github/workflows/call-doc-and-style-r.yml
Original file line number Diff line number Diff line change
@@ -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 }}
44 changes: 44 additions & 0 deletions .github/workflows/call-pr-checklist.yml
Original file line number Diff line number Diff line change
@@ -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 });
16 changes: 16 additions & 0 deletions .github/workflows/call-spell-check.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .github/workflows/call-update-pkgdown.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -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).
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ po/*~
# RStudio Connect folder
rsconnect/
.Rproj.user
docs
24 changes: 13 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
2 changes: 1 addition & 1 deletion R/ewe_nwatlantic.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.}
Expand Down
6 changes: 3 additions & 3 deletions R/get_functional_groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#'
Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion R/load_.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/use_template.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ use_testthat_template <- function(name) {
cli::cli_abort("{path} already exists.")
}
invisible(TRUE)
}
}
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: https://NOAA-FIMS.github.io/ecosystemdata
template:
bootstrap: 5

14 changes: 14 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Brito
Buchheister
Chagaris
Cieri
Ecopath
Ecosim
EwE
Schueller
bookdown
fmars
nwatlantic
testthat
tibble
usethis
4 changes: 2 additions & 2 deletions man/ewe_nwatlantic_base.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/get_functional_groups.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/load_csv_ewe.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/test-load_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down