Skip to content

Commit

Permalink
log files organized by session
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencarlislewalker committed Nov 15, 2024
1 parent 19dd287 commit 22a5583
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: macpan2
Title: Fast and Flexible Compartmental Modelling
Version: 1.11.0
Version: 1.11.1
Authors@R: c(
person("Steve Walker", email="swalk@mcmaster.ca", role=c("cre", "aut")),
person("Weiguang Guan", role="aut"),
Expand Down
10 changes: 9 additions & 1 deletion R/log_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#' * Other methods inherited from \code{\link{Files}}
#'
#' @noRd
LogFile = function(directory = tempdir()) {
LogFile = function(directory = NULL) {
if (is.null(directory)) directory = mp_session_dir()
self = Files(fix_dir(directory), reader_spec("log.txt", TXTReader))
self$log = function() self$get("log")
self$data_arg = function() list(log_file = self$.file_path("log"))
Expand All @@ -27,6 +28,13 @@ LogFile = function(directory = tempdir()) {
return_object(self, "LogFile")
}

mp_session_dir = function() {
session_name = getOption("macpan2_session_name")
wd = getwd()
ld = file.path(wd, ".macpan", session_name)
if (!dir.exists(ld)) dir.create(ld, recursive = TRUE)
return(ld)
}
make_file = function(directory) {
file_path = file.path(directory, "log.txt")
file.create(file_path)
Expand Down
2 changes: 2 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
, macpan2_vec_by = c("state", "flow_rates", "trans_rates") |> self_named_vector()
#, macpan2_memoise = TRUE

# where the log files go (e.g. `.macpan2/default`)
, macpan2_session_name = "default"

# tolerances
, macpan2_tol_hazard_div = 1e-8
Expand Down

0 comments on commit 22a5583

Please sign in to comment.