Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conversion of warnings and errors to cli #954

Merged
merged 16 commits into from
Nov 21, 2024
Merged

conversion of warnings and errors to cli #954

merged 16 commits into from
Nov 21, 2024

Conversation

topepo
Copy link
Member

@topepo topepo commented Oct 23, 2024

pal was a godsend here 💯

@@ -372,37 +364,37 @@ check_metrics <- function(x, object) {
is_surv_metric_set <- inherits(x, c("survival_metric_set"))

if (!is_numeric_metric_set && !is_class_prob_metric_set && !is_surv_metric_set) {
rlang::abort("The `metrics` argument should be the results of [yardstick::metric_set()].")
cli::cli_abort("The {.arg metrics} argument should be the results of
{.fn yardstick::metric_set}.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous messages has [pkg:fun()] format. Do we want to move to that? I don't think that they were clickable.

"The first argument needs to be an object with class 'tune_results'."
)
cli::cli_abort("The first argument needs to be {.cls tune_results} object,
not {.obj_type_friendly {mtcars}}.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using obj_type_friendly a lot in these messages.

cli::cli_abort(
"There is no `fit_best()` method for an object with \\
{cli::qty(cls)} class{?es} {.var {cls}}."
"No {.fn fit_best} exists for {.obj_type_friendly {x}}."
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I standardized on this message for all of the main default methods.

R/last_fit.R Show resolved Hide resolved
@@ -322,7 +320,8 @@ plot_param_vs_iter <- function(x, call = rlang::caller_env()) {
param_cols <- get_param_columns(x)
pset <- get_param_object(x)
if (is.null(pset)) {
rlang::abort("`autoplot()` requires objects made with tune version 0.1.0 or later.")
cli::cli_abort("{.fn autoplot} requires objects made with {.pkg tune}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe time to retire this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

R/pull.R Show resolved Hide resolved
@simonpcouch simonpcouch marked this pull request as ready for review October 29, 2024 20:58
Copy link
Contributor

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this PR is going to make tidymodels feel much more modern/slick for many users. Heck yeah!

R/acquisition.R Show resolved Hide resolved
R/case_weights.R Outdated Show resolved Hide resolved
R/case_weights.R Show resolved Hide resolved
R/case_weights.R Outdated Show resolved Hide resolved
R/collect.R Outdated Show resolved Hide resolved
R/tune_results.R Outdated Show resolved Hide resolved
R/utils.R Outdated Show resolved Hide resolved
tests/testthat/_snaps/bayes.md Outdated Show resolved Hide resolved
tests/testthat/_snaps/case-weights.md Outdated Show resolved Hide resolved
R/checks.R Outdated Show resolved Hide resolved
@topepo topepo merged commit f6772f4 into main Nov 21, 2024
14 checks passed
@topepo topepo deleted the cli-conversion branch November 21, 2024 17:26
Copy link

github-actions bot commented Dec 7, 2024

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants