-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add boarhead files and test workflow
- Loading branch information
1 parent
1473499
commit 01ed093
Showing
6 changed files
with
846 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: update-ss3-test-models-mac | ||
on: | ||
push: | ||
|
||
jobs: | ||
update-ss3-test-models-mac: | ||
runs-on: macos-14 | ||
env: | ||
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
|
||
steps: | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: install libcurl | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libcurl4-openssl-dev | ||
- name: setup R | ||
uses: r-lib/actions/setup-r@v2 | ||
|
||
- name: install remotes | ||
run: Rscript -e 'install.packages("remotes")' | ||
|
||
- name: install r4ss | ||
run: Rscript -e 'remotes::install_github("r4ss/r4ss")' | ||
|
||
- name: install other r packages | ||
run: Rscript -e 'install.packages("purrr","furrr","parallely","future")' | ||
|
||
- name: Get the latest SS3 executable | ||
run: | | ||
wget -O ss3 https://github.com/nmfs-ost/ss3-source-code/releases/latest/download/ss3_osx | ||
sudo chmod a+x ss3 | ||
mv ss3 /usr/local/bin/ss3 | ||
export PATH=/usr/local/bin/ss3:$PATH | ||
echo "/usr/local/bin/ss3" >> $GITHUB_PATH | ||
- name: Run models | ||
run: | | ||
mod_names <- list.dirs(file.path("models"), full.names = FALSE, recursive = FALSE) | ||
mod_paths <- list.dirs(file.path("models"), full.names = TRUE, recursive = FALSE) | ||
print(mod_names) | ||
run_ss <- function(dir) { | ||
wd <- getwd() | ||
print(wd) | ||
on.exit(system(paste0("cd ", wd))) | ||
# rename the reference files | ||
file.rename(file.path(dir, "ss_summary.sso"), | ||
file.path(dir, "ss_summary_ref.sso")) | ||
file.rename(file.path(dir, "warning.sso"), | ||
file.path(dir, "warning_ref.sso")) | ||
file.copy(file.path(dir, "ss3.par"), file.path(dir, "ss3_ref.par")) | ||
# run the models with estimation and see if model finishes without error | ||
message("running ss on ", basename(dir)) | ||
system(paste0("cd ", dir, " && ../ss3 -nox")) | ||
model_ran <- file.exists(file.path(dir, "control.ss_new")) | ||
return(model_ran) | ||
} | ||
mod_ran <- furrr::future_map(mod_paths, function(x){tryCatch(run_ss(x), | ||
error = function(e) print(e))}) | ||
mod_errors <- mod_names[unlist(lapply(mod_ran, function(x) "simpleError" %in% class(x)))] | ||
success <- TRUE | ||
if(length(mod_errors) > 0) { | ||
message("Model code with errors were: ", paste0(mod_errors, collapse = ", "), | ||
". See error list above for more details.") | ||
success <- FALSE | ||
} else { | ||
message("All code ran without error, but model runs may still have failed.") | ||
} | ||
mod_no_run <- mod_names[unlist(lapply(mod_ran, function(x) isFALSE(x)))] # false means model didn't run | ||
if(length(mod_no_run) > 0) { | ||
message("Models that didn't run are ", paste0(mod_no_run, collapse = ", ")) | ||
success <- FALSE | ||
} else { | ||
message("All models ran without error.") | ||
} | ||
# determine if job fails or passes | ||
if(success == FALSE) { | ||
stop("Job failed due to code with errors or models that didn't run.") | ||
} else { | ||
message("All models successfully ran.") | ||
} | ||
shell: Rscript {0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.