13
13
steps :
14
14
15
15
- name : Checkout repo
16
- uses : actions/checkout@v4
16
+ uses : actions/checkout@v3
17
17
18
18
- name : install libcurl
19
19
run : |
@@ -34,82 +34,59 @@ jobs:
34
34
- name : install purrr
35
35
run : Rscript -e 'install.packages("purrr")'
36
36
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
45
44
46
45
- name : run models
47
46
run : |
48
47
dirs_test <- list.dirs(recursive = FALSE)
49
48
mod_dir_name <- dirs_test[grepl("model", dirs_test)]
50
49
mod_dir_name <- gsub(".*\\./", "", mod_dir_name)
51
50
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
+
76
74
new_mod_dir_name <- "new_models"
77
75
78
76
r4ss::populate_multiple_folders(outerdir.old = mod_dir_name,
79
77
outerdir.new = new_mod_dir_name,
80
78
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)
92
85
93
86
new_mod_runs_folder <- file.path(new_mod_dir_name)
94
87
new_mod_path_list <- list.dirs(new_mod_runs_folder, recursive = FALSE,
95
88
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)
113
90
run_result
114
91
115
92
r4ss::populate_multiple_folders(outerdir.old = new_mod_dir_name,
@@ -133,4 +110,4 @@ jobs:
133
110
with :
134
111
commit_message : Update model files for new ss3 release
135
112
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