Skip to content

Commit 818313b

Browse files
committed
I don't think is correctly implemented, might save this for another release
1 parent 53dd4af commit 818313b

5 files changed

+36
-27
lines changed

R/checkers.R

+13-11
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
#' @importFrom utils compareVersion
66
#' @importFrom reticulate py_available
7-
#' @importFrom cli cli_process_start
8-
#' @importFrom cli cli_process_done
9-
#' @importFrom cli cli_process_failed
107
check_tf_version <- function(alert = c("none",
118
"error",
129
"warn",
@@ -26,9 +23,10 @@ check_tf_version <- function(alert = c("none",
2623

2724
if (!greta_stash$python_has_been_initialised) {
2825

29-
cli_process_start(
26+
cli::cli_progress_step(
3027
msg = "Initialising python and checking dependencies, this may take a \\
31-
moment."
28+
moment.",
29+
spinner = TRUE
3230
)
3331
}
3432

@@ -42,20 +40,22 @@ check_tf_version <- function(alert = c("none",
4240

4341
if (!greta_stash$python_has_been_initialised) {
4442

45-
cli_process_done(
46-
msg_done = "Initialising python and checking dependencies ... done!")
47-
cat("\n")
43+
cli::cli_progress_update()
4844
greta_stash$python_has_been_initialised <- TRUE
45+
cli::cli_progress_step(
46+
msg_done = "Done intialising python and checking dependencies!"
47+
)
48+
cli::cli_progress_done()
4949

5050
}
5151

5252
}
5353

5454
if (!all(requirements_valid)) {
5555

56-
cli_process_failed()
57-
58-
cli_msg <- c(
56+
cli::cli_progress_update()
57+
cli::cli_progress_step(
58+
msg_failed = c(
5959
"x" = "The expected python packages are not available",
6060
"i" = "We recommend installing them (in a fresh R session) with:",
6161
"{.code install_greta_deps()}",
@@ -64,7 +64,9 @@ check_tf_version <- function(alert = c("none",
6464
"({.strong Note}: Your R session should not have initialised \\
6565
Tensorflow yet.)",
6666
"i" = "For more information, see {.code ?install_greta_deps}"
67+
),
6768
)
69+
cli::cli_progress_done()
6870

6971
# if there was a problem, append the solution
7072
message_text <- cli::format_message(cli_msg)

R/install_greta_deps.R

-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161
#' @importFrom reticulate conda_create
6262
#' @importFrom reticulate conda_install
6363
#' @importFrom cli cli_alert_info
64-
#' @importFrom cli cli_process_start
65-
#' @importFrom cli cli_process_done
6664
#' @importFrom cli cli_ul
6765
#' @importFrom callr r_process_options
6866
#' @importFrom callr r_process

R/new_install_process.R

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ new_install_process <- function(callr_process,
44
stderr_file = NULL,
55
cli_start_msg = NULL,
66
cli_end_msg = NULL){
7-
cli::cli_process_start(cli_start_msg)
7+
cli::cli_progress_step(msg = cli_start_msg,
8+
spinner = TRUE)
89
# convert max timeout from milliseconds into minutes
910
timeout_minutes <- timeout * 1000 * 60
1011
r_callr_process <- callr::r_process$new(callr_process)
12+
cli::cli_progress_update()
1113
r_callr_process$wait(timeout = timeout_minutes)
14+
cli::cli_progress_update()
1215

1316
status <- r_callr_process$get_exit_status()
1417
output_notes <- read_char(stdout_file)
@@ -18,20 +21,22 @@ new_install_process <- function(callr_process,
1821
output_error <- output_error %||% "No output detected in stderr"
1922

2023
if (is.null(status)) {
21-
cli::cli_process_failed()
24+
cli::cli_progress_step(msg_failed = "Installation timed out")
2225
msg_timeout <- timeout_install_msg(timeout, output_error)
2326
cli::cli_abort(
24-
msg_timeout
27+
message = msg_timeout
2528
)
2629
} else if (no_output) {
27-
cli::cli_process_failed()
30+
cli::cli_progress_step(msg_failed = "Installation failed")
2831
msg_other <- other_install_fail_msg(output_error)
2932
cli::cli_abort(
3033
msg_other
3134
)
3235
}
3336

34-
cli_process_done(msg_done = cli_end_msg)
37+
cli::cli_progress_update()
38+
cli::cli_progress_step(msg_done = cli_end_msg)
39+
cli::cli_progress_done()
3540

3641
return(
3742
list(output_notes = output_notes,

R/reinstallers.R

+6-1
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,13 @@ reinstall_greta_deps <- function(python_deps = greta_python_deps(),
9999
destroy_greta_deps <- function(){
100100
cli::cli_progress_step(
101101
msg = "You are removing greta env and miniconda",
102-
msg_done = c("You have successfully removed greta env and miniconda")
102+
spinner = TRUE
103103
)
104+
cli::cli_progress_update()
104105
remove_greta_env()
106+
cli::cli_progress_update()
107+
cli::cli_progress_step(msg_done = "You have successfully removed greta env")
105108
remove_miniconda()
109+
cli::cli_progress_update()
110+
cli::cli_progress_step(msg_done = "You have successfully removed miniconda")
106111
}

R/utils.R

+7-8
Original file line numberDiff line numberDiff line change
@@ -798,19 +798,18 @@ check_if_software_available <- function(software_available,
798798
ideal_version = NULL,
799799
software_name){
800800

801-
cli::cli_process_start("checking if {.pkg {software_name}} available")
801+
cli::cli_progress_step(msg = "checking if {.pkg {software_name}} available",
802+
spinner = TRUE)
802803
# if the software is detected
803804

804805
if (!software_available) {
805-
cli::cli_process_failed(
806-
msg_failed = "{.pkg {software_name}} not available"
807-
)
806+
cli::cli_progress_step(msg_failed = "{.pkg {software_name}} not available")
808807
}
809808

810809
if (software_available) {
811810

812811
if (is.null(ideal_version) & !is.null(version)){
813-
cli::cli_process_done(
812+
cli::cli_progress_step(
814813
msg_done = "{.pkg {software_name}} (v{version}) available"
815814
)
816815
}
@@ -822,20 +821,20 @@ check_if_software_available <- function(software_available,
822821
version_match <- compareVersion(version_chr, ideal_version) == 0
823822

824823
if (version_match){
825-
cli::cli_process_done(
824+
cli::cli_progress_step(
826825
msg_done = "{.pkg {software_name}} (v{version}) available"
827826
)
828827
}
829828
if (!version_match){
830-
cli::cli_process_failed(
829+
cli::cli_progress_step(
831830
msg_failed = "{.pkg {software_name}} available, \\
832831
however {.strong {ideal_version}} is needed and \\
833832
{.strong {version}} was detected"
834833
)
835834
}
836835
# if there is no version for the software
837836
} else if (is.null(version)){
838-
cli::cli_process_done(
837+
cli::cli_progress_step(
839838
msg_done = "{.pkg {software_name}} available"
840839
)
841840
}

0 commit comments

Comments
 (0)