add offset option for ENV Q #300
Workflow file for this run
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
# Check that SS_output and SS_plots run with changes in ss3. | |
name: test-r4ss-with-ss3 | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- '**.tpl' | |
branches: | |
- main | |
pull_request: | |
types: ['opened', 'edited', 'reopened', 'synchronize', 'ready_for_review'] | |
paths: | |
- '**.tpl' | |
branches: | |
- main | |
# run models without estimation, then run r4ss SS_plots and SS_output | |
jobs: | |
test-r4ss-with-ss3: | |
if: github.event.pull_request.draft == false | |
runs-on: ubuntu-latest | |
env: | |
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
R_KEEP_PKG_SOURCE: yes | |
steps: | |
- name: Checkout ss3 repo | |
uses: actions/checkout@v4 | |
- name: Checkout models repo | |
uses: actions/checkout@v4 | |
with: | |
repository: 'nmfs-ost/ss3-test-models' | |
path: test-models-repo | |
- 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 R packages | |
run: Rscript -e 'install.packages(c("remotes","parallely", "furrr", "future"))' | |
- name: install r4ss | |
run: Rscript -e 'remotes::install_github("r4ss/r4ss")' | |
# - name: Get admb and put in path, linux | |
# run: | | |
# wget https://github.com/admb-project/admb/releases/download/admb-13.1/admb-13.1-linux.zip | |
# sudo unzip admb-13.1-linux.zip -d /usr/local/bin | |
# sudo chmod 755 /usr/local/bin/admb-13.1/bin/admb | |
# echo "/usr/local/bin/admb-13.1/bin" >> $GITHUB_PATH | |
# - name: Build stock synthesis | |
# run: | | |
# rm -rf SS330 | |
# mkdir SS330 | |
# /bin/bash ./Make_SS_330_new.sh -b SS330 | |
- name: Build stock synthesis with admb docker image | |
run: | | |
rm -rf SS330 | |
rm -rf ss3_osx.tar | |
mkdir SS330 | |
chmod 777 SS330 | |
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330 | |
- name: move exes, scripts to needed locations | |
run: | | |
mv test-models-repo/models test-models-repo/model_runs | |
mv SS330/ss3 test-models-repo/model_runs/ss3 | |
mv test-models-repo/.github/r_scripts/run_from_par.R test-models-repo/run_from_par.R | |
mv test-models-repo/.github/r_scripts/run_compare_noest.R test-models-repo/run_compare_noest.R | |
- name: change permissions on ss3 exes | |
run: sudo chmod a+x test-models-repo/model_runs/ss3 | |
- name: run models without estimation | |
run: | | |
cd test-models-repo && Rscript run_from_par.R | |
- name: run SS3 output and SS3 plots | |
run: | | |
ncores <- parallelly::availableCores(omit = 1) | |
future::plan(future::multisession, workers = ncores) | |
mod_names <- list.dirs("test-models-repo/model_runs", full.names = FALSE, recursive = FALSE) | |
print(mod_names) | |
if(length(mod_names) == 0) { | |
stop("Did not r4ss on any models; perhaps path to models is not correct?") | |
} | |
out <- furrr::future_map(mod_names, function(i) { | |
tryCatch(r4ss::SS_output(file.path("test-models-repo", "model_runs", i), | |
verbose = FALSE, hidewarn = TRUE, printstats = FALSE), | |
error = function(e) { | |
print(e) | |
} | |
) | |
}) | |
plots <- furrr::future_map(out, function(x) { | |
tryCatch(r4ss::SS_plots(x, verbose = FALSE, openfile = FALSE), | |
error = function(e) { | |
print(e) | |
}) | |
}) | |
# determine if job fails or not | |
out_issues <- mod_names[unlist(lapply(out, function(x) "error" %in% class(x)))] | |
plotting_issues<- mod_names[unlist(lapply(plots, function(x) "error" %in% class(x)))] | |
if(length(out_issues) == 0 & length(plotting_issues) == 0) { | |
message("all r4ss functions completed successfully") | |
} else { | |
message("There were some errors. SS_output failed to run for model_runs ", | |
paste0(out_issues, collapse = ", "), "; SS_plots failed to run for ", | |
"models ", paste0(plotting_issues, collapse = " ,"), ". More info ", | |
"below.") | |
message("Problems with SS_output:") | |
for(i in out_issues) { | |
message(i) | |
tmp_loc <- which(mod_names == i) | |
print(out[[tmp_loc]]) | |
} | |
for(p in plotting_issues) { | |
message(p) | |
tmp_loc <- which(mod_names == p) | |
print(plots[[tmp_loc]]) | |
} | |
q(status = 1) | |
} | |
shell: Rscript {0} | |
# could archive files, but the archive will be large, so may not be worth it. |