Skip to content

Commit

Permalink
try test models update fix
Browse files Browse the repository at this point in the history
  • Loading branch information
e-perl-NOAA committed Oct 31, 2024
1 parent f30ed19 commit e9aeb5f
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions .github/workflows/update-ss3-models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,50 @@ jobs:
mod_dir_name <- dirs_test[grepl("model", dirs_test)]
mod_dir_name <- gsub(".*\\./", "", mod_dir_name)
update_ref_files <- function(new_mod_path, ss_examples_folder = file.path(getwd(), mod_dir_name)) {
mod_name <- basename(new_mod_path)
git_mod_path <- file.path(ss_examples_folder, mod_name)
# list model files that need to be moved
files_to_move <- c("ss.par", "ss3.par", "ss_summary.sso", "warning.sso")
# copy model files from new_mod_path folder to the git_mod_path folder,
results_of_move <- lapply(files_to_move,
function(x, new_mod_path, git_mod_path) {
file.remove(file.path(git_mod_path, x))
file.copy(from = file.path(new_mod_path, x),
to = file.path(git_mod_path, x),
overwrite = FALSE)
#to make sure worked:
worked <- file.exists(file.path(git_mod_path, x))
}, new_mod_path = new_mod_path, git_mod_path = git_mod_path)
if(all(unlist(results_of_move) == TRUE)) {
files_replaced <- TRUE
} else {
files_replaced <- FALSE
}
files_replaced
}
update_ref_files <- function(new_mod_path, mod_dir_name) {
ss_examples_folder <- file.path(getwd(), mod_dir_name)
mod_name <- basename(new_mod_path)
git_mod_path <- file.path(ss_examples_folder, mod_name)
# list model files that need to be moved
files_to_move <- c("ss.par", "ss3.par", "ss_summary.sso", "warning.sso")
# copy model files from new_mod_path folder to the git_mod_path folder,
results_of_move <- lapply(files_to_move,
function(x, new_mod_path, git_mod_path) {
# file.remove(file.path(git_mod_path, x))
file.copy(from = file.path(new_mod_path, x),
to = file.path(git_mod_path, x),
overwrite = TRUE)
#to make sure worked:
worked <- file.exists(file.path(git_mod_path, x))
}, new_mod_path = new_mod_path, git_mod_path = git_mod_path)
if(all(unlist(results_of_move) == TRUE)) {
files_replaced <- TRUE
} else {
files_replaced <- FALSE
}
files_replaced
}
new_mod_dir_name <- "new_models"
r4ss::populate_multiple_folders(outerdir.old = mod_dir_name,
outerdir.new = new_mod_dir_name,
exe.file = NULL, verbose = FALSE)
purrr::map(
.x = file.path(new_mod_dir_name, list.files(new_mod_dir_name)),
.f = r4ss::run,
exe = "/usr/local/bin/ss3",
verbose = TRUE)
purrr::map(
.x = file.path(new_mod_dir_name, list.files(new_mod_dir_name)),
.f = r4ss::run,
exe = "/usr/local/bin/ss3",
verbose = TRUE)
new_mod_runs_folder <- file.path(new_mod_dir_name)
new_mod_path_list <- list.dirs(new_mod_runs_folder, recursive = FALSE,
full.names = TRUE)
run_result <- lapply(new_mod_path_list, update_ref_files)
run_result <- purrr::map(
.x = new_mod_path_list,
.f = update_ref_files,
mod_dir_name = mod_dir_name)
run_result
r4ss::populate_multiple_folders(outerdir.old = new_mod_dir_name,
Expand Down

0 comments on commit e9aeb5f

Please sign in to comment.