Skip to content

Commit 13f30dd

Browse files
committed
convert to cli_warn()
1 parent 81b64c3 commit 13f30dd

File tree

8 files changed

+29
-33
lines changed

8 files changed

+29
-33
lines changed

R/arguments.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ check_eng_args <- function(args, obj, core_args) {
88
if (length(common_args) > 0) {
99
args <- args[!(names(args) %in% common_args)]
1010
common_args <- paste0(common_args, collapse = ", ")
11-
rlang::warn(
12-
glue::glue(
13-
"The following arguments cannot be manually modified ",
14-
"and were removed: {common_args}."
15-
)
11+
cli::cli_warn(
12+
"The arguments {common_args} cannot be manually modified and were removed."
1613
)
1714
}
1815
args

R/fit.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,14 @@ fit.cluster_spec <- function(
103103
eng_vals <- possible_engines(object)
104104
object$engine <- eng_vals[1]
105105
if (control$verbosity > 0) {
106-
rlang::warn(glue::glue("Engine set to `{object$engine}`."))
106+
cli::cli_warn("Engine set to {.code {object$engine}}.")
107107
}
108108
}
109109

110110
if (all(c("x", "y") %in% names(dots))) {
111111
cli::cli_abort(
112-
"The {.fn fit.cluster_spec} function is for the formula methods. Use {.fn fit_xy} instead."
112+
"The {.fn fit.cluster_spec} function is for the formula methods.
113+
Use {.fn fit_xy} instead."
113114
)
114115
}
115116
cl <- match.call(expand.dots = TRUE)

R/predict.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ predict.cluster_fit <- function(
9696
...
9797
) {
9898
if (inherits(object$fit, "try-error")) {
99-
rlang::warn("Model fit failed; cannot make predictions.")
99+
cli::cli_warn(
100+
"Model fit failed; cannot make predictions."
101+
)
100102
return(NULL)
101103
}
102104

R/predict_cluster.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ predict_cluster.cluster_fit <- function(object, new_data, ...) {
2323
check_spec_pred_type(object, "cluster")
2424

2525
if (inherits(object$fit, "try-error")) {
26-
rlang::warn("Model fit failed; cannot make predictions.")
26+
cli::cli_warn("Model fit failed; cannot make predictions.")
2727
return(NULL)
2828
}
2929

R/predict_raw.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ predict_raw.cluster_fit <- function(object, new_data, opts = list(), ...) {
1616
check_spec_pred_type(object, "raw")
1717

1818
if (inherits(object$fit, "try-error")) {
19-
rlang::warn("Cluster fit failed; cannot make predictions.")
19+
cli::cli_warn("Cluster fit failed; cannot make predictions.")
2020
return(NULL)
2121
}
2222

R/tune_cluster.R

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,12 @@ tune_cluster_workflow <- function(
182182
)
183183

184184
if (is_cataclysmic(resamples)) {
185-
rlang::warn("All models failed. See the `.notes` column.")
185+
cli::cli_warn(
186+
c(
187+
"All models failed.",
188+
"i" = "See the {.code .notes} column."
189+
)
190+
)
186191
}
187192

188193
workflow <- set_workflow(workflow, control)
@@ -999,12 +1004,13 @@ check_grid <- function(grid, workflow, pset = NULL) {
9991004
}
10001005

10011006
if (nrow(pset) == 0L) {
1002-
msg <- paste0(
1003-
"No tuning parameters have been detected, ",
1004-
"performance will be evaluated using the resamples with no tuning. ",
1005-
"Did you want to [tune()] parameters?"
1007+
cli::cli_warn(
1008+
c(
1009+
"No tuning parameters have been detected, performance will be evaluated using
1010+
the resamples with no tuning.",
1011+
"i" = "Did you want to {.fn tune} parameters?"
1012+
)
10061013
)
1007-
rlang::warn(msg)
10081014

10091015
# Return `NULL` as the new `grid`, like what is used in `fit_resamples()`
10101016
return(NULL)
@@ -1017,7 +1023,7 @@ check_grid <- function(grid, workflow, pset = NULL) {
10171023

10181024
grid_distinct <- dplyr::distinct(grid)
10191025
if (!identical(nrow(grid_distinct), nrow(grid))) {
1020-
rlang::warn(
1026+
cli::cli_warn(
10211027
"Duplicate rows in grid of tuning combinations found and removed."
10221028
)
10231029
}

R/tune_helpers.R

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,11 @@ set_workflow <- function(workflow, control) {
3131
if (!is.null(workflow$pre$actions$recipe)) {
3232
w_size <- utils::object.size(workflow$pre$actions$recipe)
3333
if (w_size / 1024^2 > 5) {
34-
msg <- paste0(
35-
"The workflow being saved contains a recipe, which is ",
36-
format(w_size, units = "Mb", digits = 2),
37-
" in memory. If this was not intentional, please set the control ",
38-
"setting `save_workflow = FALSE`."
34+
cli::cli_inform(
35+
"The workflow being saved contains a recipe, which is {format(w_size, units = 'Mb',
36+
digits = 2)} in memory. If this was not intentional, please set the control
37+
setting {.code save_workflow = FALSE}."
3938
)
40-
cols <- get_tidyclust_colors()
41-
msg <- strwrap(
42-
msg,
43-
prefix = paste0(
44-
cols$symbol$info(cli::symbol$info),
45-
" "
46-
)
47-
)
48-
msg <- cols$message$info(paste0(msg, collapse = "\n"))
49-
rlang::inform(msg)
5039
}
5140
}
5241
workflow

tests/testthat/_snaps/tune_cluster.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@
8585
! The following predi...
8686
Condition
8787
Warning:
88-
All models failed. See the `.notes` column.
88+
All models failed.
89+
i See the `.notes` column.
8990

9091
# argument order gives errors for recipes
9192

0 commit comments

Comments
 (0)