Skip to content

Conversation

@cristinamullin
Copy link
Collaborator

Pull Request Checklist

Preparation

  • Update your branch from the latest develop and resolve any merge conflicts

  • Before creating a pull request trigger the format-update GitHub Action on your branch to format the code

Documentation

  • Add/update inline and/or block comments to clarify complexity, context and intent

  • Add/update function documentation (roxygen), include working examples, build docs locally using devtools::document(), and inspect added/updated help pages for content and format

  • Add/update vignettes for corresponding changes in functionality, list these under articles in _pkgdown.yml, and ensure added/updated vignettes run and build with proper formatting locally

Maintenance & Data Refresh

  • Add new dependencies to DESCRIPTION and document appropriately

  • Run spelling maintenance in requiredMaintenance.R

  • If changes affect other package or the shiny app functions, update those impacted functions accordingly

  • If columns were added/updated, add/update them in RequiredCols.R

  • Run .TADA_UpdateRefFiles() and .TADA_UpdateExampleData() locally via MaintenanceScheduled.R or trigger the Component File Update GitHub Action

  • If new example data files were added, document them in ExampleData.R and include them in MaintenanceScheduled.R for regular refresh

Tests and checks

  • Add/update tests in tests/testthat to cover changes

  • Run devtools::test() to verify new and existing tests pass

  • Run devtools::check() and address any errors, warnings or notes

Pull Request Description

  • Includes a summary of the changes made

  • Includes relevant context/motivation

  • Includes links to related issues or pull requests (keywords like "Closes #issue_number" automatically close related issues when pull request is merged)

Review

  • Review the bot-commented coverage-report generated by test-coverage to confirm all changes are covered by tests

  • Review/accept any bot-suggested format changes

  • Request review from at least one developer team member

Key additions:

Guarding against NULLs and vector org_id values, and explicitly defaulting org_id = "all" when org_id is NULL (common in Shiny) so the function will query ATTAINS unless org_id is explicitly set to "none".
Preflight connectivity check to ATTAINS with timing and more informative messages.
Increased timeout and timing instrumentation around the ATTAINS web-service calls to make their latency visible.
tryCatch around remote/geospatial calls to avoid hard failures on server and to surface diagnostic messages.
Guards around sf operations and missing coordinates.
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

air

[air] reported by reviewdog 🐶

if ("TADA.LongitudeMeasure" %in% names(get.attains) && "TADA.LatitudeMeasure" %in% names(get.attains)) {


[air] reported by reviewdog 🐶

dplyr::filter(!is.na(.data$TADA.LongitudeMeasure), !is.na(.data$TADA.LatitudeMeasure))


[air] reported by reviewdog 🐶

message("st_as_sf (get.attains geometry) failed: ", conditionMessage(e))


[air] reported by reviewdog 🐶

if (exists("get.attains.matches") &&
!is.null(get.attains.matches$without_ATTAINS_catchment) &&
!is.null(get.attains.matches$TADA_without_ATTAINS)) {


[air] reported by reviewdog 🐶

message("fill_USGS_catch = TRUE, but there are no USGS catchment outputs to append (no unmatched MLs or matching failed).")


[air] reported by reviewdog 🐶

EPATADA/R/RequiredCols.R

Lines 528 to 530 in 4d704a8

na.cols <- .data |>
purrr::keep(~ all(is.na(.x))) |>
names()


[air] reported by reviewdog 🐶

check_inv <- .data[
,


[air] reported by reviewdog 🐶

EPATADA/R/UnitConversions.R

Lines 323 to 325 in 4d704a8

tada.all <- tada.all |>
dplyr::select(-CharUnit) |>
dplyr::distinct()


[air] reported by reviewdog 🐶

.data[[col.name]] <- switch(col.type,


[air] reported by reviewdog 🐶

EPATADA/R/autoClean.R

Lines 277 to 279 in 4d704a8

do.list <- do.data |>
dplyr::select(ResultIdentifier) |>
dplyr::pull()


[air] reported by reviewdog 🐶

files <- append(other_files, vignettes) |>
append(articles) |>
append(r_files)

Comment on lines 430 to 432
all.pairs <- pair.activityid |>
rbind(pair.ml.time) |>
dplyr::distinct()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
all.pairs <- pair.activityid |>
rbind(pair.ml.time) |>
dplyr::distinct()
all.pairs <- pair.activityid |> rbind(pair.ml.time) |> dplyr::distinct()

Comment on lines 380 to 381
~tribal_area, ~url,
"Alaska Native Allotments", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
~tribal_area, ~url,
"Alaska Native Allotments", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/0",
~tribal_area , ~url ,
"Alaska Native Allotments" , "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/0" ,

Comment on lines 383 to 385
"American Indian Reservations", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/2",
"Off-reservation Trust Lands", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/3",
"Oklahoma Tribal Statistical Areas", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/4" # ,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
"American Indian Reservations", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/2",
"Off-reservation Trust Lands", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/3",
"Oklahoma Tribal Statistical Areas", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/4" # ,
"American Indian Reservations" , "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/2" ,
"Off-reservation Trust Lands" , "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/3" ,
"Oklahoma Tribal Statistical Areas" , "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/4" # ,

Comment on lines 904 to 906
record_count <- query_avail |>
dplyr::pull(resultCount) |>
sum()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
record_count <- query_avail |>
dplyr::pull(resultCount) |>
sum()
record_count <- query_avail |> dplyr::pull(resultCount) |> sum()

Comment on lines 1104 to 1110
~tribal_area, ~url,
"Alaska Native Allotments", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/0",
"Alaska Native Villages", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/1",
"American Indian Reservations", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/2",
"Off-reservation Trust Lands", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/3",
"Oklahoma Tribal Statistical Areas", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/4",
"Virginia Federally Recognized Tribes", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/5"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
~tribal_area, ~url,
"Alaska Native Allotments", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/0",
"Alaska Native Villages", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/1",
"American Indian Reservations", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/2",
"Off-reservation Trust Lands", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/3",
"Oklahoma Tribal Statistical Areas", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/4",
"Virginia Federally Recognized Tribes", "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/5"
~tribal_area , ~url ,
"Alaska Native Allotments" , "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/0" ,
"Alaska Native Villages" , "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/1" ,
"American Indian Reservations" , "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/2" ,
"Off-reservation Trust Lands" , "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/3" ,
"Oklahoma Tribal Statistical Areas" , "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/4" ,
"Virginia Federally Recognized Tribes" , "https://geopub.epa.gov/arcgis/rest/services/EMEF/Tribal/MapServer/5"

crs = 4326
# ADDED: Guard against missing coordinates which can occur if inputs have NA lat/long
# This avoids errors in st_as_sf on Shiny servers with incomplete data
if ("TADA.LongitudeMeasure" %in% names(user) && "TADA.LatitudeMeasure" %in% names(user)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
if ("TADA.LongitudeMeasure" %in% names(user) && "TADA.LatitudeMeasure" %in% names(user)) {
if (
"TADA.LongitudeMeasure" %in%
names(user) &&
"TADA.LatitudeMeasure" %in% names(user)
) {

# This avoids errors in st_as_sf on Shiny servers with incomplete data
if ("TADA.LongitudeMeasure" %in% names(user) && "TADA.LatitudeMeasure" %in% names(user)) {
user <- user |>
dplyr::filter(!is.na(.data$TADA.LongitudeMeasure), !is.na(.data$TADA.LatitudeMeasure))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
dplyr::filter(!is.na(.data$TADA.LongitudeMeasure), !is.na(.data$TADA.LatitudeMeasure))
dplyr::filter(
!is.na(.data$TADA.LongitudeMeasure),
!is.na(.data$TADA.LatitudeMeasure)
)

attains,
coords = c("TADA.LongitudeMeasure", "TADA.LatitudeMeasure"),
crs = 4326
if ("TADA.LongitudeMeasure" %in% names(attains) && "TADA.LatitudeMeasure" %in% names(attains)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
if ("TADA.LongitudeMeasure" %in% names(attains) && "TADA.LatitudeMeasure" %in% names(attains)) {
if (
"TADA.LongitudeMeasure" %in%
names(attains) &&
"TADA.LatitudeMeasure" %in% names(attains)
) {

crs = 4326
if ("TADA.LongitudeMeasure" %in% names(attains) && "TADA.LatitudeMeasure" %in% names(attains)) {
attains <- attains |>
dplyr::filter(!is.na(.data$TADA.LongitudeMeasure), !is.na(.data$TADA.LatitudeMeasure))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
dplyr::filter(!is.na(.data$TADA.LongitudeMeasure), !is.na(.data$TADA.LatitudeMeasure))
dplyr::filter(
!is.na(.data$TADA.LongitudeMeasure),
!is.na(.data$TADA.LatitudeMeasure)
)

Comment on lines 3918 to 3921
get.attains <- tryCatch(sf::st_make_valid(get.attains), error = function(e) {
message("st_make_valid (get.attains) failed: ", conditionMessage(e))
get.attains
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
get.attains <- tryCatch(sf::st_make_valid(get.attains), error = function(e) {
message("st_make_valid (get.attains) failed: ", conditionMessage(e))
get.attains
})
get.attains <- tryCatch(
sf::st_make_valid(get.attains),
error = function(e) {
message("st_make_valid (get.attains) failed: ", conditionMessage(e))
get.attains
}
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants