Skip to content

Commit 716862a

Browse files
committed
try fixing workflow
1 parent 3e1e46f commit 716862a

File tree

1 file changed

+39
-62
lines changed

1 file changed

+39
-62
lines changed

.github/workflows/update-ss3-models.yml

Lines changed: 39 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414

1515
- name: Checkout repo
16-
uses: actions/checkout@v4
16+
uses: actions/checkout@v3
1717

1818
- name: install libcurl
1919
run: |
@@ -34,82 +34,59 @@ jobs:
3434
- name: install purrr
3535
run: Rscript -e 'install.packages("purrr")'
3636

37-
# - name: Get the latest SS3 executable
38-
# run: |
39-
# wget -O ss3 https://github.com/nmfs-ost/ss3-source-code/releases/latest/download/ss3_linux
40-
# sudo chmod a+x ss3
41-
# mv ss3 /usr/local/bin/ss3
42-
# mv models/ss3
43-
# export PATH=/usr/local/bin/ss3:$PATH
44-
# echo "/usr/local/bin/ss3" >> $GITHUB_PATH
37+
- name: Get the latest SS3 executable
38+
run: |
39+
wget -O ss3 https://github.com/nmfs-ost/ss3-source-code/releases/latest/download/ss3_linux
40+
sudo chmod a+x ss3
41+
mv ss3 /usr/local/bin/ss3
42+
export PATH=/usr/local/bin/ss3:$PATH
43+
echo "/usr/local/bin/ss3" >> $GITHUB_PATH
4544
4645
- name: run models
4746
run: |
4847
dirs_test <- list.dirs(recursive = FALSE)
4948
mod_dir_name <- dirs_test[grepl("model", dirs_test)]
5049
mod_dir_name <- gsub(".*\\./", "", mod_dir_name)
5150
52-
update_ref_files <- function(new_mod_path, mod_dir_name) {
53-
ss_examples_folder <- file.path(getwd(), mod_dir_name)
54-
mod_name <- basename(new_mod_path)
55-
git_mod_path <- file.path(ss_examples_folder, mod_name)
56-
# list model files that need to be moved
57-
files_to_move <- c("ss.par", "ss3.par", "ss_summary.sso", "warning.sso")
58-
# copy model files from new_mod_path folder to the git_mod_path folder,
59-
results_of_move <- lapply(files_to_move,
60-
function(x, new_mod_path, git_mod_path) {
61-
# file.remove(file.path(git_mod_path, x))
62-
file.copy(from = file.path(new_mod_path, x),
63-
to = file.path(git_mod_path, x),
64-
overwrite = TRUE)
65-
#to make sure worked:
66-
worked <- file.exists(file.path(git_mod_path, x))
67-
}, new_mod_path = new_mod_path, git_mod_path = git_mod_path)
68-
if(all(unlist(results_of_move) == TRUE)) {
69-
files_replaced <- TRUE
70-
} else {
71-
files_replaced <- FALSE
72-
}
73-
files_replaced
74-
}
75-
51+
update_ref_files <- function(new_mod_path, ss_examples_folder = file.path(getwd(), mod_dir_name)) {
52+
mod_name <- basename(new_mod_path)
53+
git_mod_path <- file.path(ss_examples_folder, mod_name)
54+
# list model files that need to be moved
55+
files_to_move <- c("ss.par", "ss3.par", "ss_summary.sso", "warning.sso")
56+
# copy model files from new_mod_path folder to the git_mod_path folder,
57+
results_of_move <- lapply(files_to_move,
58+
function(x, new_mod_path, git_mod_path) {
59+
file.remove(file.path(git_mod_path, x))
60+
file.copy(from = file.path(new_mod_path, x),
61+
to = file.path(git_mod_path, x),
62+
overwrite = FALSE)
63+
#to make sure worked:
64+
worked <- file.exists(file.path(git_mod_path, x))
65+
}, new_mod_path = new_mod_path, git_mod_path = git_mod_path)
66+
if(all(unlist(results_of_move) == TRUE)) {
67+
files_replaced <- TRUE
68+
} else {
69+
files_replaced <- FALSE
70+
}
71+
files_replaced
72+
}
73+
7674
new_mod_dir_name <- "new_models"
7775
7876
r4ss::populate_multiple_folders(outerdir.old = mod_dir_name,
7977
outerdir.new = new_mod_dir_name,
8078
exe.file = NULL, verbose = FALSE)
81-
82-
run_ssnew <- function(dir) {
83-
wd <- getwd()
84-
print(wd)
85-
on.exit(system(paste0("cd ", wd)))
86-
system(paste0("cd ", dir, " && ../ss3"))
87-
model_ran <- file.exists(file.path(dir, "control.ss_new"))
88-
return(model_ran)
89-
}
90-
91-
r4ss::get_ss3_exe(dir = file.path(getwd(), new_mod_dir_name))
79+
80+
purrr::map(
81+
.x = file.path(new_mod_dir_name, list.files(new_mod_dir_name)),
82+
.f = r4ss::run,
83+
exe = "/usr/local/bin/ss3",
84+
verbose = TRUE)
9285
9386
new_mod_runs_folder <- file.path(new_mod_dir_name)
9487
new_mod_path_list <- list.dirs(new_mod_runs_folder, recursive = FALSE,
9588
full.names = TRUE)
96-
97-
# Run models in parallel using .ss_new files and print out error messages
98-
purrr::map(
99-
.x = new_mod_path_list,
100-
.f = run_ssnew)
101-
102-
# purrr::map(
103-
# .x = file.path(new_mod_dir_name, list.files(new_mod_dir_name)),
104-
# .f = r4ss::run,
105-
# exe = "ss3",
106-
# verbose = TRUE)
107-
108-
run_result <- purrr::map(
109-
.x = new_mod_path_list,
110-
.f = update_ref_files,
111-
mod_dir_name = mod_dir_name)
112-
89+
run_result <- lapply(new_mod_path_list, update_ref_files)
11390
run_result
11491
11592
r4ss::populate_multiple_folders(outerdir.old = new_mod_dir_name,
@@ -133,4 +110,4 @@ jobs:
133110
with:
134111
commit_message: Update model files for new ss3 release
135112
branch: update-test-models
136-
title: 'Update test model files for new ss3 release'
113+
title: 'Update test model files for new ss3 release'

0 commit comments

Comments
 (0)