Skip to content

Commit

Permalink
fix(data_mile1.R): reorganize on.exit() calls and rename maindir to m…
Browse files Browse the repository at this point in the history
…ain_dir
  • Loading branch information
Bai-Li-NOAA authored and kellijohnson-NOAA committed Dec 10, 2024
1 parent bc2404d commit d7d04d2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions data-raw/data_mile1.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ library(dplyr)
###############################################################################
working_dir <- getwd()

maindir <- tempdir()
main_dir <- tempdir()

# Save the initial OM input using ASSAMC package (sigmaR = 0.4)
model_input <- ASSAMC::save_initial_input()
Expand All @@ -48,7 +48,7 @@ sim_num <- 100
sim_input <- ASSAMC::save_initial_input(
base_case = TRUE,
input_list = model_input,
maindir = maindir,
maindir = main_dir,
om_sim_num = sim_num,
keep_sim_num = sim_num,
figure_number = 1,
Expand All @@ -60,12 +60,9 @@ sim_input <- ASSAMC::save_initial_input(
# using function from the model comparison project
ASSAMC::run_om(input_list = sim_input)

on.exit(unlink(maindir, recursive = TRUE), add = TRUE)

setwd(working_dir)
on.exit(setwd(working_dir), add = TRUE)

load(file.path(maindir, "sim_data", "output", "OM", paste0("OM", 1, ".RData")))
load(file.path(main_dir, "sim_data", "output", "OM", paste0("OM", 1, ".RData")))
returnedom <- list(
om_input = om_input,
om_output = om_output,
Expand Down Expand Up @@ -198,4 +195,6 @@ testthat::expect_equal(test_read, data_mile1)
unlink("FIMS_input_data.csv")

usethis::use_data(data_mile1, overwrite = TRUE)
on.exit(unlink(main_dir, recursive = TRUE), add = TRUE)
on.exit(setwd(working_dir), add = TRUE)
rm(list = ls())

0 comments on commit d7d04d2

Please sign in to comment.