diff --git a/R/utils.R b/R/utils.R index f47cc101..060318cd 100644 --- a/R/utils.R +++ b/R/utils.R @@ -146,7 +146,7 @@ get_seed <- function() { sample.int( n = 2^30, size = 1 - ) + ) } # does a pointer exist (as a named object) and is it from the current session @@ -680,8 +680,8 @@ as_tf_function <- function(r_fun, ...) { sub_dag <- dag_class$new(targets) # TF1/2 check remove - # `get_default_graph()` doesn't work with either eager execution or - # `tf.function`. + # `get_default_graph()` doesn't work with either eager execution or + # `tf.function`. # use the default graph, so that it can be overwritten when this is called? # alternatively fetch from above, or put it in greta_stash? # sub_dag$tf_graph <- tf$compat$v1$get_default_graph() @@ -879,10 +879,10 @@ check_if_software_available <- function(software_available, } compare_version_vec <- Vectorize( - FUN = compareVersion, - vectorize.args = "b", - SIMPLIFY = TRUE - ) + FUN = compareVersion, + vectorize.args = "b", + SIMPLIFY = TRUE +) #' Greta Situation Report #' @@ -898,21 +898,35 @@ compare_version_vec <- Vectorize( #' } greta_sitrep <- function(){ + config_info <- reticulate::py_config() + + cli::cli_h1("R") + cli::cli_ul("version: {.val {getRversion()}}") + cli::cli_ul("path: {R.home()}") + cli::cli_h1("{.pkg greta}") + cli::cli_ul("version: {.val {packageVersion('greta')}}") + + cli::cli_h1("{.pkg Python}") check_if_software_available(software_available = have_python(), version = reticulate::py_version(), software_name = "python") + cli::cli_h1("{.pkg Tensorflow}") check_if_software_available(software_available = have_tf(), version = version_tf(), software_name = "TensorFlow") + cli::cli_h1("{.pkg Tensorflow Probability}") check_if_software_available(software_available = have_tfp(), version = version_tfp(), software_name = "TensorFlow Probability") + cli::cli_h1("{.pkg greta conda environment} ") check_if_software_available(software_available = have_greta_conda_env(), software_name = "greta conda environment") + show_greta_conda_env_path() + software_available <- c( python = have_python(), tf = have_tf(), @@ -958,6 +972,18 @@ greta_sitrep <- function(){ } +show_greta_conda_env_path <- function(){ + if (!have_greta_conda_env()){ + cli::cli_ul("path: no conda env found for {.var greta-env-tf2}") + } + + py_cl <- reticulate::conda_list() + which_greta_env <- which(py_cl$name == "greta-env-tf2") + greta_env_path <- py_cl$python[which_greta_env] + cli::cli_ul("path: {greta_env_path}") + +} + # adapted from https://github.com/rstudio/tensorflow/blob/main/R/utils.R is_mac_arm64 <- function() { if (nzchar(Sys.getenv("GRETA_M1_MESSAGE_TESTING"))) { @@ -1043,8 +1069,8 @@ check_dag_introduces_new_variables <- function(dag, mcmc_dag) { } check_targets_stochastic_and_not_sampled <- function( - target, - mcmc_dag_variables + target, + mcmc_dag_variables ) { target_nodes <- lapply(target, get_node) target_node_names <- extract_unique_names(target_nodes) @@ -1134,7 +1160,7 @@ node_type_colour <- function(type){ data = cli::col_green(type), operation = cli::col_cyan(type), distribution = cli::col_yellow(type) - ) + ) switch_cols } @@ -1175,7 +1201,7 @@ are_null <- function(x){ x, is.null, FUN.VALUE = logical(1) - ) + ) } are_greta_array <- function(x){