Skip to content

Commit 8417324

Browse files
zacdav-dbZac Daviesclaude
authored
Modernize user messaging with cli package (#107)
* Fix package dependencies and modernize CI infrastructure - Add missing R6 dependency to resolve package loading issues - Add grid to Suggests for execution context image display - Fix URL inconsistencies between pkgdown config and README - Update GitHub Actions to latest versions (checkout@v4, pr-fetch@v2) - Add package validation for suggested dependencies in execution context - Add Claude Code artifacts to gitignore 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Modernize user messaging with cli package Replace base R messaging functions with cli equivalents for better UX: - Convert stop() calls to cli::cli_abort() with argument highlighting - Replace warning() with cli::cli_warn() including pluralization support - Enhance error messages with structured formatting and context bullets - Add semantic styling for arguments, values, functions, and paths - Improve library installation feedback with better progress messaging - Revert codecov badge to original repository reference 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove R CMD check artifacts Clean up temporary R CMD check files that shouldn't be tracked in version control. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Zac Davies <zac@databricks.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 11e5d5b commit 8417324

10 files changed

Lines changed: 25 additions & 23 deletions

R/clusters.R

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ db_cluster_create <- function(
181181
} else if (is.gcp_attributes(cloud_attrs)) {
182182
body[["gcp_attributes"]] <- unclass(cloud_attrs)
183183
} else {
184-
stop(
185-
"Please use `aws_attributes()`, `azure_attributes()`, or `gcp_attributes()` to specify `cloud_attr`"
186-
)
184+
cli::cli_abort(c(
185+
"Invalid cloud attributes specification:",
186+
"i" = "Use {.fn aws_attributes}, {.fn azure_attributes}, or {.fn gcp_attributes} for {.arg cloud_attr}"
187+
))
187188
}
188189

189190
req <- db_request(
@@ -319,9 +320,10 @@ db_cluster_edit <- function(
319320
} else if (is.azure_attributes(cloud_attrs)) {
320321
body[["azure_attributes"]] <- unclass(cloud_attrs)
321322
} else {
322-
stop(
323-
"Please use `aws_attributes()` or `azure_attributes()` to specify `cloud_attr`"
324-
)
323+
cli::cli_abort(c(
324+
"Invalid cloud attributes specification:",
325+
"i" = "Use {.fn aws_attributes} or {.fn azure_attributes} for {.arg cloud_attr}"
326+
))
325327
}
326328
}
327329

@@ -574,7 +576,7 @@ db_cluster_resize <- function(
574576
perform_request = TRUE
575577
) {
576578
if (is.null(num_workers) && is.null(autoscale)) {
577-
stop("Must specify one of `num_workers` or `autoscale`.")
579+
cli::cli_abort("Must specify either {.arg num_workers} or {.arg autoscale}.")
578580
}
579581

580582
body <- list(
@@ -968,12 +970,12 @@ get_latest_dbr <- function(
968970
# don't allow impossible combinations
969971
if (gpu) {
970972
if (!ml) {
971-
stop("GPU runtime only available for ML versions")
973+
cli::cli_abort("{.arg gpu} runtime only available for {.arg ml} versions")
972974
}
973975
}
974976

975977
if ((gpu || ml) && photon) {
976-
stop("Cannot use ML/GPU runtimes with Photon")
978+
cli::cli_abort("Cannot use {.arg ml}/{.arg gpu} runtimes with {.arg photon}")
977979
}
978980

979981
runtimes <- db_cluster_runtime_versions(host = host, token = token)

R/data-structures.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ job_tasks <- function(...) {
14711471
obj <- list(...)
14721472

14731473
if (length(obj) == 0) {
1474-
stop("Must specify at least one task")
1474+
cli::cli_abort("Must specify at least one task")
14751475
}
14761476

14771477
# check that all inputs are job tasks
@@ -1741,7 +1741,7 @@ delta_sync_index_spec <- function(
17411741
}
17421742

17431743
if (is.null(embedding_vector_columns) & is.null(embedding_source_columns)) {
1744-
stop("Must specify at least one embedding vector or source column")
1744+
cli::cli_abort("Must specify at least one embedding vector or source column")
17451745
}
17461746

17471747
obj <- list(
@@ -1835,15 +1835,15 @@ direct_access_index_spec <- function(
18351835
}
18361836

18371837
if (is.null(embedding_vector_columns) & is.null(embedding_source_columns)) {
1838-
stop("Must specify at least one embedding vector or source column")
1838+
cli::cli_abort("Must specify at least one embedding vector or source column")
18391839
}
18401840

18411841
if (is.null(schema)) {
1842-
stop("`schema` must be present.")
1842+
cli::cli_abort("{.arg schema} must be present.")
18431843
}
18441844

18451845
if (!(is.list(schema) && rlang::is_named(schema))) {
1846-
stop("`schema` must be a named list.")
1846+
cli::cli_abort("{.arg schema} must be a named list.")
18471847
}
18481848

18491849
obj <- list(

R/execution-context.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ db_context_command_run <- function(
143143

144144
# only can have one of `command` or `command_file`
145145
if (!is.null(command) && !is.null(command_file)) {
146-
stop("Must `command` OR `command_file` not both.")
146+
cli::cli_abort("Must specify {.arg command} OR {.arg command_file}, not both.")
147147
}
148148

149149
if (!is.null(command_file)) {

R/experiments.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ db_experiments_get <- function(name = NULL, id = NULL,
3333
perform_request = TRUE) {
3434

3535
if (!is.null(name) && !is.null(id)) {
36-
stop("Specify `name` or `id`, not both.")
36+
cli::cli_abort("Specify {.arg name} or {.arg id}, not both.")
3737
}
3838

3939
body <- list()

R/jobs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ db_jobs_runs_list <- function(
502502
run_type <- match.arg(run_type, several.ok = FALSE)
503503

504504
if (active_only && completed_only) {
505-
stop("`active_only` and `completed_only` cannot both be `TRUE`.")
505+
cli::cli_abort("{.arg active_only} and {.arg completed_only} cannot both be {.val TRUE}.")
506506
}
507507

508508
body <- list(

R/lib-management.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ add_lib_path <- function(path, after, version = FALSE) {
3232

3333
lib_path <- normalizePath(lib_path, "/")
3434

35-
message("primary package path is now ", lib_path)
35+
cli::cli_alert_info("Primary package path is now {.path {lib_path}}")
3636
.libPaths(new = append(.libPaths(), lib_path, after = after))
3737
lib_path
3838
}

R/libraries.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ wait_for_lib_installs <- function(
219219

220220
# if failures are not allowed and failur occurs then raise an error
221221
if (!allow_failures && "FAILED" %in% lib_statuses) {
222-
stop("Libraries failed to install")
222+
cli::cli_abort("Libraries failed to install on cluster")
223223
}
224224

225225
if (!any(lib_statuses == "INSTALLING")) break
@@ -229,7 +229,7 @@ wait_for_lib_installs <- function(
229229

230230
if (allow_failures && "FAILED" %in% lib_statuses) {
231231
num_failures <- sum(lib_statuses == "FAILED")
232-
warning("Failed installs: ", num_failures)
232+
cli::cli_warn("Failed to install {.val {num_failures}} librar{?y/ies}")
233233
}
234234

235235
NULL

R/sql-query-execution.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ db_sql_exec_poll_for_success <- function(statement_id, interval = 1) {
271271
} else if (
272272
status$status$status$state %in% c("FAILED", "CLOSED", "CANCELED")
273273
) {
274-
stop(paste0("queries status: ", status$status$state))
274+
cli::cli_abort("Query failed with status: {.val {status$status$state}}")
275275
}
276276
}
277277

R/vector-search.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ db_vs_indexes_create <- function(name, endpoint, primary_key, spec,
226226
index_type <- "DIRECT_ACCESS"
227227
direct_access_index_spec <- spec
228228
} else {
229-
stop("`spec` is invalid type, must be defined by either `delta_sync_index_spec()` or `direct_access_index_spec()`")
229+
cli::cli_abort("{.arg spec} is invalid type, must be defined by either {.fn delta_sync_index_spec} or {.fn direct_access_index_spec}")
230230
}
231231

232232
body <- list(

R/volume-fs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ db_volume_dir_exists <- function(path,
220220

221221
is_valid_volume_path <- function(path) {
222222
if (!grepl("^/Volumes/", path)) {
223-
stop("`path` must start with `/Volumes/`")
223+
cli::cli_abort("{.arg path} must start with {.path /Volumes/}")
224224
}
225225
path
226226
}

0 commit comments

Comments
 (0)