Skip to content

Commit

Permalink
Lint + importFrom fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Insang Song committed Aug 18, 2024
1 parent edb8024 commit eb59b22
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 73 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck, any::remotes, any::units, any::rmarkdown
extra-packages: |
any::rcmdcheck
any::remotes
any::units
any::rmarkdown
needs: check

- name: install remote packages
Expand Down
66 changes: 23 additions & 43 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr, any::remotes
extra-packages: any::covr, any::DT, any::htmltools
needs: coverage

- name: install remote packages
run: |
Rscript -e 'remotes::install_github(sprintf("NIEHS/%s", c("amadeus", "chopin")), upgrade = FALSE)'
shell: bash

- name: Cache C++ and R dependencies
uses: actions/cache@v4
uses: actions/cache@v2
with:
path: |
~/.cache/R
Expand All @@ -43,66 +38,51 @@ jobs:
dependencies-${{ runner.os }}-
- name: Test coverage
run: >
Rscript -e
"covd<-covr::coverage_to_list()$totalcoverage;
run: |
Rscript -e "covpack<-covr::package_coverage(install_path='${{ github.workspace }}/cov', clean=FALSE); \
covr::report(covpack, file = file.path('${{ github.workspace }}', 'chopin-coverage-report.html')); \
covd<-covr::coverage_to_list(covpack)$totalcoverage; \
write.table(covd[length(covd)], file = '${{ github.workspace }}/local_cov.Rout', row.names = F, col.names = F)"
shell: bash

- name: Upload covr report as artifact
uses: actions/upload-artifact@v4
with:
name: covr-report
path: ${{ github.workspace }}/chopin-coverage-report.html

- name: Upload workspace dump as artifact if the test fails
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: test-outputs
path: ${{ github.workspace }}/**

- name: Get Values
id: get-values
shell: bash
run: |
COV=$(cat ${{ github.workspace }}/local_cov.Rout)
echo "Patch coverage read from local_cov.Rout: $COV"
echo "coverage=$COV" >> $GITHUB_OUTPUT
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Patch comparison
id: patch-comparison
shell: bash
run: |
cov_patch="${{ steps.get-values.outputs.coverage }}"
if [[ ! -f cov_current.Rout ]]; then
cov_current=0
else
cov_current=$(cat cov_current.Rout)
fi
echo "Current coverage: $cov_current"
if (( $(echo "$cov_patch >= $cov_current" | bc -l) )); then
echo "Patch coverage ($cov_patch) is greater than or equal to current coverage ($cov_current)."
echo "cov_update=$cov_patch" >> $GITHUB_OUTPUT
else
echo "Patch coverage ($cov_patch) is less than current coverage ($cov_current)."
exit 1
fi
- name: Overwrite cov_current.Rout
if: ${{ github.event_name == 'push' }}
shell: bash
run: |
cov_update="${{ steps.patch-comparison.outputs.cov_update }}"
touch cov_current.Rout
echo "$cov_update" > cov_current.Rout

- name: Create Badges
shell: bash
run: |
npm i -g badgen-cli
export COV=${{ steps.get-values.outputs.coverage }}
COLOR=$(node -p '+process.env.COV >= 95 ? `green` : `yellow`')
COLOR=$(node -p '+process.env.COV >= 95 ? `green` : `orange`')
mkdir -p badges
badgen -j coverage -s $COV% -c $COLOR > badges/coverage.svg
- name: Deploy Badges
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update badges [skip ci] & cov_current.Rout"
commit_message: "Update badges [skip ci]"
branch: gh-pages
skip_fetch: true
skip_checkout: true
Expand All @@ -113,4 +93,4 @@ jobs:
- name: Checkout Back
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
ref: ${{ github.ref }}
16 changes: 16 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ export(switch_generate_cv_rset)
export(switch_model)
export(unmarshal_function)
export(vis_spt_rset)
importFrom(amadeus,calc_covariates)
importFrom(amadeus,calc_prepare_locs)
importFrom(amadeus,calc_temporal_dummies)
importFrom(amadeus,calc_worker)
importFrom(amadeus,check_for_null_parameters)
importFrom(amadeus,download_data)
importFrom(amadeus,download_sanitize_path)
importFrom(amadeus,generate_date_sequence)
importFrom(amadeus,process_aqs)
importFrom(amadeus,process_covariates)
importFrom(amadeus,process_gmted_codes)
importFrom(anticlust,balanced_clustering)
importFrom(collapse,fnth)
importFrom(collapse,fvar)
Expand All @@ -62,6 +73,7 @@ importFrom(dplyr,"%>%")
importFrom(dplyr,`%>%`)
importFrom(dplyr,across)
importFrom(dplyr,all_of)
importFrom(dplyr,full_join)
importFrom(dplyr,group_by)
importFrom(dplyr,slice_sample)
importFrom(dplyr,summarize)
Expand Down Expand Up @@ -101,11 +113,15 @@ importFrom(stringi,stri_replace_all_regex)
importFrom(targets,tar_resources)
importFrom(targets,tar_resources_future)
importFrom(terra,crs)
importFrom(terra,describe)
importFrom(terra,extract)
importFrom(terra,rast)
importFrom(terra,sds)
importFrom(terra,subset)
importFrom(terra,time)
importFrom(terra,varnames)
importFrom(terra,vect)
importFrom(tibble,tribble)
importFrom(tidyselect,all_of)
importFrom(tigris,counties)
importFrom(tune,control_bayes)
Expand Down
2 changes: 1 addition & 1 deletion R/base_learner.R
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ generate_cv_index_sp <-
}
}

return(newcv)
return(newcv)

Check warning on line 878 in R/base_learner.R

View workflow job for this annotation

GitHub Actions / lint

file=R/base_learner.R,line=878,col=2,[indentation_linter] Indentation should be 4 spaces but is 2 spaces.
}


Expand Down
17 changes: 1 addition & 16 deletions R/calc_postprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ post_calc_join_yeardate <-
#' @note This version assumes the time_id contains Date-like strings.
#' @return data.frame
#' @importFrom data.table merge.data.table
#' @importFrom amadeus calc_temporal_dummies
#' @export
post_calc_merge_all <-
function(
Expand Down Expand Up @@ -750,20 +751,4 @@ append_predecessors <-
}


# nested parallelization
# IN PROGRESS
# TODO: identify bottleneck
#' @noRd
par_nest <-
function(
path,
...
) {
chopin::par_grid(
path,
fun_dist = calculate,
...
)
}

# nocov end
15 changes: 7 additions & 8 deletions R/calculate.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
#' hard-coded subsets for subdataset selection
#' @author Mitchell Manware, Insang Song
#' @return a `SpatRaster` object;
#' @importFrom terra rast
#' @importFrom terra time
#' @importFrom terra varnames
#' @importFrom terra crs
#' @importFrom terra subset
#' @importFrom sf st_as_sf
#' @importFrom future.apply future_lapply
#' @importFrom data.table rbindlist
#' @importFrom future plan multicore sequential
#' @importFrom amadeus generate_date_sequence
#' @importFrom terra describe rast time subset crs varnames vect sds extract
#' @importFrom dplyr full_join
#' @export
calc_geos_strict <-
function(path = NULL,
Expand Down Expand Up @@ -223,9 +222,9 @@ calc_geos_strict <-
#' @param fun character(1). Function to apply.
#' @param ... Additional parameters to be passed to other functions.
#' @return A data.frame containing the extracted GMTED data.
#' @importFrom terra rast
#' @importFrom terra varnames
#' @importFrom terra extract
#' @importFrom terra rast varnames extract
#' @importFrom amadeus process_gmted_codes calc_prepare_locs calc_worker
#' @importFrom amadeus download_sanitize_path
#' @export
calc_gmted_direct <- function(
variable = NULL,
Expand Down
1 change: 1 addition & 0 deletions R/init_arguments.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#' * nthreads_impute: Number of threads for imputing data.
#' @author Insang Song
#' @importFrom qs qsave
#' @importFrom tibble tribble
#' @export
# nolint start
set_args_calc <-
Expand Down
4 changes: 4 additions & 0 deletions R/injection.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#' dataset.
#' @param dataset_name character(1). Dataset name.
#' @param ... Arguments passed to `amadeus::download_data`
#' @importFrom amadeus download_data
#' @importFrom rlang inject
#' @return logical(1).
#' @export
feature_raw_download <-
Expand Down Expand Up @@ -96,6 +98,8 @@ set_target_years <-
#' @return A data.table object.
#' @importFrom data.table rbindlist
#' @importFrom rlang inject
#' @importFrom amadeus process_covariates calc_covariates
#' @importFrom future plan sequential multicore
#' @export
calculate <-
function(
Expand Down
1 change: 1 addition & 0 deletions R/load.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ load_modis_files <- function(path, pattern = "hdf$", date = character(2)) {
#' @param ... Passed arguments to `fun_aqs`
#' @return Depending on `fun_aqs` specification.
#' @importFrom qs qsave
#' @importFrom amadeus process_aqs
#' @export
read_locs <-
function(
Expand Down
4 changes: 3 additions & 1 deletion R/processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ process_geos_bulk <-
#' path = "/path/to/data"
#' )
#' }
#'
#' @importFrom amadeus download_sanitize_path check_for_null_parameters
#' @importFrom amadeus generate_date_sequence
#' @importFrom terra rast time subset
#' @export
process_narr2 <- function(
date = c("2023-09-01", "2023-09-01"),
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<p>

[![R-CMD-check](https://github.com/NIEHS/beethoven/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/NIEHS/beethoven/actions/workflows/check-standard.yaml)
[![cov](https://NIEHS.github.io/beethoven/badges/coverage.svg)](https://github.com/NIEHS/beethoven/actions)
[![cov](https://NIEHS.github.io/beethoven/badges/coverage.svg)](https://github.com/NIEHS/beethoven/actions/workflows/test-coverage.yaml)
[![lint](https://github.com/NIEHS/beethoven/actions/workflows/lint.yaml/badge.svg)](https://github.com/NIEHS/beethoven/actions/workflows/lint.yaml)
[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
Expand Down Expand Up @@ -705,6 +705,7 @@ append_predecessors(
The calculated features contain a fair amount of `NA` or `NaN`s depending on the raw dataset. We distinguish these into "true zeros" and "true missing" for the subsequent imputation process. For imputation, `missRanger` is used. The `missRanger` arguments can be adjusted in the `impute_all()` function.

- True zeros: TRI features include many `NA`s as the raw data is a long `data.frame` with source location-chemicals pair keys. This structure requires long-to-wide pivoting, resulting in a sparse `data.frame` with `NA`s where no chemicals were reported in certain locations. Therefore, these `NA`s are considered true zeros.

- Missing: daily satellite-derived features except for the 16-day NDVI are considered to include missing values. Such missing values are mainly coming from intermittent data transmission disruption or planned maintenance. `NA`s in the 16-day NDVI field are filled by the "last observation carried forward" principle. `NaN` values in others are replaced with `NA` and put into the imputation function.


Expand All @@ -713,7 +714,7 @@ The calculated features contain a fair amount of `NA` or `NaN`s depending on the

For efficiency, GPU-enabled version is recommended for `xgboost`/`lightgbm` and `brulee`. These packages need to be installed manually with modifications of system environment variables. Developers should consult `lightgbm` official documentation for building the package by hand, `xgboost` GitHub repository release page for installing the CUDA version manually and `brulee` GitHub repository (i.e., in `gpu` branch) to install the proper version of each package with careful consideration on the computing infrastructure. "GPU" here refers to CUDA-enabled devices produced by NVIDIA corporation. This does not necessarily mean that this package as a part of U.S. government work endorses NVIDIA corporation and its products in any sort.

[!WARNING]
> [!WARNING]
> As of version 0.3.10, `xgboost` < v2.1.0 should be used due to breaking changes in v2.1.0 in handling additional arguments in `xgb.DMatrix` (cf. [xgboost pull record](https://github.com/dmlc/xgboost/pull/9862)), which leads to break `parsnip::boost_tree()` function call.

Expand Down
1 change: 0 additions & 1 deletion man/process_narr2.Rd

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

0 comments on commit eb59b22

Please sign in to comment.