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

Add more detail to greta_sitrep() #679

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
#'
Expand All @@ -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(),
Expand Down Expand Up @@ -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"))) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -1175,7 +1201,7 @@ are_null <- function(x){
x,
is.null,
FUN.VALUE = logical(1)
)
)
}

are_greta_array <- function(x){
Expand Down