Skip to content

Commit

Permalink
suppress an unwanted warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcellGranat committed Feb 14, 2023
1 parent dc38e12 commit d10633e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: currr
Title: Apply Mapping Functions in Frequent Saving
Version: 0.1.0
Version: 0.1.1
Authors@R:
person("Marcell", "Granat", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-4036-1500"))
Expand Down
42 changes: 22 additions & 20 deletions R/cp_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ cp_map <- function(.x, .f, ..., name = NULL, cp_options = list()) {
stringr::str_to_lower() |>
stringr::str_flatten("")



if (!name %in% list.files(currr_folder)) {
message(crayon::blue(clisymbols::symbol$warning), " Using name is suggested. Currently named to ", crayon::cyan(name), ".")
}
Expand Down Expand Up @@ -288,12 +286,13 @@ cp_map <- function(.x, .f, ..., name = NULL, cp_options = list()) {
}

job_ids <- readRDS(paste0(currr_folder, "/currr_job_ids.rds"))

tryCatch({
rstudioapi::jobAddOutput(job_ids[[name]], stringr::str_c("This job is still, running. ", crayon::cyan(format(Sys.time(), "%H:%M:%S")), "\n"))
job_running <- TRUE
message(crayon::cyan(clisymbols::symbol$info), " This evaluation is still running in a bg job.\r")
}, error = \(e) {})
suppressWarnings({
tryCatch({
rstudioapi::jobAddOutput(job_ids[[name]], stringr::str_c("This job is still, running. ", crayon::cyan(format(Sys.time(), "%H:%M:%S")), "\n"))
job_running <- TRUE
message(crayon::cyan(clisymbols::symbol$info), " This evaluation is still running in a bg job.\r")
}, error = \(e) {})
})

if (!job_running) {

Expand Down Expand Up @@ -332,10 +331,12 @@ cp_map <- function(.x, .f, ..., name = NULL, cp_options = list()) {

}
} else {
tryCatch({
job_ids <- readRDS(paste0(currr_folder, "/currr_job_ids.rds"))
rstudioapi::jobRemove(job_ids[[name]])
}, error = \(e) {})
suppressWarnings({
tryCatch({
job_ids <- readRDS(paste0(currr_folder, "/currr_job_ids.rds"))
rstudioapi::jobRemove(job_ids[[name]])
}, error = \(e) {})
})
}

# Read back
Expand Down Expand Up @@ -379,14 +380,15 @@ cp_map <- function(.x, .f, ..., name = NULL, cp_options = list()) {
message_dots <- 0
}
message_dots <- message_dots + 1

tryCatch({
eta(name) |>
(\(x) update_status(name = name, done = x$done, n = x$n, eta = x$eta)) ()
}, error = \(e) {
utils::flush.console()
cat(stringr::str_flatten(c("Calculating ETA", rep(".", (message_dots -1) %% 3 + 1), rep(" ", 2 - (message_dots -1) %% 3), " \r"), collapse = ""))
utils::flush.console()
suppressWarnings({
tryCatch({
eta(name) |>
(\(x) update_status(name = name, done = x$done, n = x$n, eta = x$eta)) ()
}, error = \(e) {
utils::flush.console()
cat(stringr::str_flatten(c("Calculating ETA", rep(".", (message_dots -1) %% 3 + 1), rep(" ", 2 - (message_dots -1) %% 3), " \r"), collapse = ""))
utils::flush.console()
})
})
Sys.sleep(.5)
}
Expand Down

0 comments on commit d10633e

Please sign in to comment.