Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug in progress (20241115) #378

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2abba7b
common R libraries
mitchellmanware Sep 25, 2024
f0fccce
initiate development 09/30
mitchellmanware Sep 30, 2024
fc275d2
set up container, def, and archive old bash scripts
kyle-messier Oct 1, 2024
bad244e
add dev to branches triggering GH actions
kyle-messier Oct 1, 2024
45a2170
Merge pull request #368 from NIEHS/container-01
kyle-messier Oct 1, 2024
f602529
appendable date range
mitchellmanware Oct 1, 2024
30b0f89
def files, bash scipts for containers, testing yaml
kyle-messier Oct 1, 2024
4c42f5a
fixing [on] typo
kyle-messier Oct 1, 2024
969565b
GH action path correction
kyle-messier Oct 1, 2024
66c65aa
name change
kyle-messier Oct 1, 2024
27d64e3
def file was wrong name
kyle-messier Oct 1, 2024
f4db895
rel path update for container build
kyle-messier Oct 1, 2024
89a2f95
path fix, fakeroot
kyle-messier Oct 1, 2024
8af11cd
path change for test functions
kyle-messier Oct 1, 2024
7afc578
cache fixing attempt
kyle-messier Oct 1, 2024
ab3dfb7
path fix attempts
kyle-messier Oct 1, 2024
775c98d
change order of yaml names to include new R test file in mnt
kyle-messier Oct 1, 2024
691aa16
remove _targets/ path from mount
kyle-messier Oct 1, 2024
ddee948
cache updating and check sections
kyle-messier Oct 1, 2024
ee9da0b
test cache of sif
kyle-messier Oct 1, 2024
401a78a
Merge branch 'dev' into container-01
kyle-messier Oct 1, 2024
e460622
Merge pull request #369 from NIEHS/container-01
kyle-messier Oct 1, 2024
d8f5fad
refactor calc_*_modis
mitchellmanware Oct 1, 2024
51a6733
_targets.R, test and run bash scripts
kyle-messier Oct 2, 2024
8790b40
Merge branch 'dev' into container-01
kyle-messier Oct 2, 2024
7d17aba
Merge pull request #370 from NIEHS/container-01
kyle-messier Oct 2, 2024
2adeadb
commit to pull container dev
mitchellmanware Oct 2, 2024
4c3cd75
Merge branch 'dev' into dev-0930
mitchellmanware Oct 2, 2024
ec6d7e6
query_modis_files function
mitchellmanware Oct 2, 2024
03d3782
rectify merge overwrite
mitchellmanware Oct 2, 2024
91619f5
refactoring targets + container run
mitchellmanware Oct 2, 2024
62c2b9b
migrate dev/refactor/ -> root/
mitchellmanware Oct 3, 2024
8c5a79e
successful container run
mitchellmanware Oct 3, 2024
bc2c82e
refactor + integrate download targets (requires amadeus::download_mod…
mitchellmanware Oct 7, 2024
fac9aae
read_locs -> amadeus::process_aqs
mitchellmanware Oct 7, 2024
2cfbdef
update critical targets
mitchellmanware Oct 7, 2024
a06a12b
organize; group storage location
mitchellmanware Oct 8, 2024
3153f90
restore
mitchellmanware Oct 8, 2024
091cfcc
manually calculate ecoregions
mitchellmanware Oct 8, 2024
2b5a5c7
organize
mitchellmanware Oct 9, 2024
5364135
organize 2
mitchellmanware Oct 9, 2024
40847d8
/inst/targets/README.md
mitchellmanware Oct 9, 2024
af7f5c3
--force; query_modis_files
mitchellmanware Oct 9, 2024
7124813
drop SLURM from container
mitchellmanware Oct 10, 2024
d7118ca
un-future calc_geos_strict
mitchellmanware Oct 10, 2024
56f2a3a
Merge pull request #377 from NIEHS/dev-0930
mitchellmanware Oct 10, 2024
7db5cf9
debug in progress
sigmafelix Oct 27, 2024
acab12a
debug in progress
sigmafelix Nov 10, 2024
3197979
debug
sigmafelix Nov 12, 2024
cc06cc2
small update
sigmafelix Nov 12, 2024
c230aa0
HMS calculation fix
sigmafelix Nov 12, 2024
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: 2 additions & 2 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: [main, master, dev]
pull_request:
branches: [main, master]
branches: [main, master, dev]

name: R-CMD-check

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: [main, master, dev]
pull_request:
branches: [main, master]
branches: [main, master, dev]

name: lint

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: [main, master, dev]
pull_request:
branches: [main, master]
branches: [main, master, dev]
release:
types: [published]
workflow_dispatch:
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/test-container-dl-calc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Test Coverage for Download and Calculate via Apptainer

on:
push:
branches: [main, master, dev]
pull_request:
branches: [main, master, dev]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create run_dl_calc_tests.R dynamically
run: |
mkdir -p tests/testthat # Ensure the directory exists
echo 'testthat::test_file("tests/testthat/test_download.R")' > tests/testthat/run_dl_calc_tests.R
echo 'testthat::test_file("tests/testthat/test_calculate.R")' >> tests/testthat/run_dl_calc_tests.R

- name: Install Apptainer dependencies
run: |
sudo apt-get update && sudo apt-get install -y \
libseccomp-dev \
squashfs-tools \
cryptsetup \
wget

- name: Install Apptainer
run: |
wget https://github.com/apptainer/apptainer/releases/download/v1.1.0/apptainer-1.1.0.tar.gz
tar -xvf apptainer-1.1.0.tar.gz
cd apptainer-1.1.0
./mconfig && make -C builddir && sudo make -C builddir install

- name: Restore .sif file from cache
id: cache-sif
uses: actions/cache@v3
with:
path: beethoven_dl_calc.sif
key: sif-cache-${{ runner.os }}-${{ hashFiles('container/beethoven_dl_calc.def') }}
restore-keys: |
sif-cache-${{ runner.os }}-

- name: Build the Apptainer container (if cache miss)
if: steps.cache-sif.outputs.cache-hit != 'true'
run: |
apptainer build --force --fakeroot beethoven_dl_calc.sif container/beethoven_dl_calc.def

- name: Cache the .sif file
if: steps.cache-sif.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
path: beethoven_dl_calc.sif
key: sif-cache-${{ runner.os }}-${{ hashFiles('container/beethoven_dl_calc.def') }}

- name: Check if .sif file exists
run: |
if [ ! -f beethoven_dl_calc.sif ]; then
echo "Error: .sif file not found!"
exit 1
fi

- name: Run R tests
run: |
apptainer exec \
--bind $PWD/inst:/pipeline \
--bind $PWD/input:/input \
--bind $PWD:/mnt \
beethoven_dl_calc.sif \
Rscript /mnt/tests/testthat/run_dl_calc_tests.R
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: [main, master, dev]
pull_request:
branches: [main, master]
branches: [main, master, dev]

name: test-coverage-local

Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ _targets
# future batchtools outputs
.future
slurm_error.log
slurm/

# SLURM messages and logs
**/*.err
Expand All @@ -110,4 +111,10 @@ targets_start.Rout

.netrc
.urs_cookies
beethoven_branching_notes.txt
beethoven_branching_notes.txt

# NASA Earthdata login credentials
inst/extdata/nasa_token.txt

# flexible library for beethoven ad-hoc update
lib-flex
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: beethoven
Title: Building an Extensible, rEproducible, Test-driven, Harmonized, Open-source, Versioned, ENsemble model for air quality
Version: 0.4.1
Version: 0.4.2
Authors@R: c(
person("Kyle", "Messier", , "kyle.messier@nih.gov", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9508-9623")),
person("Insang", "Song", role = c("aut", "ctb"), comment = c(ORCID = "0000-0001-8732-3256")),
Expand Down
6 changes: 4 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export(fit_base_learner)
export(fit_base_tune)
export(fit_meta_learner)
export(fl_dates)
export(fl_dates_flatten)
export(generate_cv_index_sp)
export(generate_cv_index_spt)
export(generate_cv_index_ts)
Expand All @@ -38,6 +39,7 @@ export(pred_colname)
export(predict_meta_learner)
export(process_geos_bulk)
export(process_narr2)
export(query_modis_files)
export(read_locs)
export(read_paths)
export(reduce_list)
Expand All @@ -51,10 +53,10 @@ 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,calculate_covariates)
importFrom(amadeus,calculate_temporal_dummies)
importFrom(amadeus,check_for_null_parameters)
importFrom(amadeus,download_data)
importFrom(amadeus,download_sanitize_path)
Expand Down
4 changes: 2 additions & 2 deletions R/calc_postprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ post_calc_df_year_expand <- function(
#' @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
#' @importFrom amadeus calculate_temporal_dummies
#' @export
post_calc_merge_all <-
function(
Expand Down Expand Up @@ -314,7 +314,7 @@ post_calc_merge_all <-
# need POSIXt class for amadeus function
locs_merged[[time_id]] <- as.POSIXct(locs_merged[[time_id]])
locs_merged <-
amadeus::calc_temporal_dummies(
amadeus::calculate_temporal_dummies(
locs = locs_merged,
locs_id = locs_id,
year = target_years
Expand Down
46 changes: 39 additions & 7 deletions R/calculate.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ calc_geos_strict <-
paths <- list.files(
path,
pattern = "GEOS-CF.v01.rpl",
full.names = TRUE
full.names = TRUE,
recursive = TRUE
)
paths <- paths[grep(
".nc4",
Expand Down Expand Up @@ -203,13 +204,18 @@ calc_geos_strict <-
return(rast_ext)

}
future::plan(future::multicore, workers = 10)
# future::plan(future::multicore, workers = 10)
# rast_summary <-
# future.apply::future_lapply(
# future_inserted,
# function(fs) summary_byvar(fs = fs)
# )
# future::plan(future::sequential)
rast_summary <-
future.apply::future_lapply(
lapply(
future_inserted,
function(fs) summary_byvar(fs = fs)
)
future::plan(future::sequential)
rast_summary <- data.table::rbindlist(rast_summary)

return(rast_summary)
Expand Down Expand Up @@ -519,10 +525,11 @@ par_narr <- function(domain, path, date, locs, nthreads = 24L) {
if (!dir.exists(path)) {
stop("The specified path does not exist.")
}
future::plan(future::multicore, workers = nthreads)
# future::plan(future::multicore, workers = nthreads)

res <-
future.apply::future_lapply(
# future.apply::future_lapply(
lapply(
domain,
function(x) {
from <- process_narr2(
Expand All @@ -538,7 +545,32 @@ par_narr <- function(domain, path, date, locs, nthreads = 24L) {
},
future.seed = TRUE
)
future::plan(future::sequential)
# future::plan(future::sequential)
return(res)

}

#' Identify MODIS files
#' @description
#' This function identifies the relevant MODIS file paths based on
#' path, list of julian dates, and index. Designed to help set arguments
#' for the `inject_modis_par` function.
#' @keywords Calculation
#' @param path A character vector specifying the path to the MODIS data.
#' @param list A list of julian dates.
#' @param index An integer specifying the index of the julian date to use.
#' @return A character vector of MODIS file paths.
#' @export
query_modis_files <- function(path, list, index) {
grep_files <- list.files(
path,
full.names = TRUE,
recursive = TRUE
) |> grep(
pattern = paste0(
"A", list[[index]], collapse = "|"
),
value = TRUE
)
return(grep_files)
}
34 changes: 34 additions & 0 deletions R/helpers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Helper functions for checking SLURM jobs and nodes

# nocov start
job <- function(job_id) {
system(
paste0("sacct -j ", job_id, " --format=JobID,Elapsed,TotalCPU,MaxRSS")
)
}

kb_to_gb <- function(kb) {
gb <- kb / (1024^2)
return(gb)
}

geo <- function() {
system("srun --partition=geo --cpus-per-task=1 --pty top")
}

node <- function(node = "gn040815") {
system(paste0("scontrol show node ", node))
}

queue <- function() {
system("squeue -u $USER")
}

cancel <- function() {
system("scancel -u $USER")
}

batch <- function(file = "run.sh") {
system(paste0("sbatch ", file))
}
# nocov end
Loading
Loading