Skip to content

Commit

Permalink
Some small name changes in installation(ers)
Browse files Browse the repository at this point in the history
* change function greta_python_deps() --> greta_deps_spec()
* argument: python_deps --> deps
* minor changes to logfile writing
  • Loading branch information
njtierney committed Aug 20, 2024
1 parent ca5a775 commit 1561d59
Show file tree
Hide file tree
Showing 17 changed files with 288 additions and 298 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ S3method(mean,greta_array)
S3method(min,greta_array)
S3method(plot,greta_model)
S3method(print,greta_array)
S3method(print,greta_deps_spec)
S3method(print,greta_mcmc_list)
S3method(print,greta_model)
S3method(print,greta_python_deps)
S3method(print,initials)
S3method(print,optimiser)
S3method(print,sampler)
Expand Down Expand Up @@ -198,9 +198,9 @@ export(gradient_descent)
export(greta_array)
export(greta_create_conda_env)
export(greta_deps_receipt)
export(greta_deps_spec)
export(greta_install_miniconda)
export(greta_notes_tf_num_error)
export(greta_python_deps)
export(greta_set_install_logfile)
export(greta_sitrep)
export(hmc)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The following optimisers are removed, as they are no longer supported by Tensorf
This release provides a few improvements to installation in greta. It should now provide more information about installation progress, and be more robust. The intention is, it should _just work_, and if it doesn't fail gracefully with some useful advice on problem solving.

* Added option to restart R + run `library(greta)` after installation (#523)
* Added installation deps object, `greta_python_deps()` to help simplify specifying package versions (#664)
* Added installation deps object, `greta_deps_sepc()` to help simplify specifying package versions (#664)
* removed `method` and `conda` arguments from `install_greta_deps()` as they
were not used.
* removed `manual` argument in `install_greta_deps()`.
Expand Down
2 changes: 1 addition & 1 deletion R/data-deps-tf-tfp.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' <https://www.tensorflow.org/install/source_windows>, and by inspecting
#' <https://github.com/tensorflow/probability/releases>.
#'
#' We recommend using the default versions provided in `greta_python_deps()`.
#' We recommend using the default versions provided in `greta_deps_spec()`.
#'
#' @format ## `greta_deps_tf_tfp`
#' A data frame with 63 rows and 5 columns:
Expand Down
12 changes: 6 additions & 6 deletions R/greta_create_conda_env.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
#' "greta-env-tf2". This is used within [install_greta_deps()] as part of
#' setting up python dependencies. It uses a version of python that is
#' compatible with the versions of tensorflow and tensorflow-probability,
#' which is established with [greta_python_deps()]. We mostly recommend
#' which is established with [greta_deps_spec()]. We mostly recommend
#' users use [install_greta_deps()] to manage their python dependency
#' installation.
#'
#'
#' @param timeout time (minutes) until installation stops. Default is 5 minutes.
#' @param python_deps dependency specification, see [greta_python_deps()] for
#' @param deps dependency specification, see [greta_deps_spec()] for
#' more details.
#'
#' @return nothing - creates a conda environment for a specific python version
#' @export
greta_create_conda_env <- function(timeout = 5,
python_deps = greta_python_deps()) {
deps = greta_deps_spec()) {

check_greta_python_deps(python_deps)
check_greta_deps_spec(deps)

stdout_file <- create_temp_file("out-greta-conda")
stderr_file <- create_temp_file("err-greta-conda")
Expand All @@ -31,7 +31,7 @@ greta_create_conda_env <- function(timeout = 5,
python_version = python_version
)
},
args = list(python_version = python_deps$python_version),
args = list(python_version = deps$python_version),
stdout = stdout_file,
stderr = stderr_file
)
Expand All @@ -43,7 +43,7 @@ greta_create_conda_env <- function(timeout = 5,
timeout = timeout,
cli_start_msg = glue::glue(
"Creating 'greta-env-tf2' conda environment using python \\
v{python_deps$python_version}, this may take a minute"
v{deps$python_version}, this may take a minute"
),
cli_end_msg = "greta-env-tf2 environment created!"
)
Expand Down
22 changes: 11 additions & 11 deletions R/greta_install_python_deps.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
greta_install_python_deps <- function(timeout = 5,
python_deps = greta_python_deps()) {
deps = greta_deps_spec()) {

stdout_file <- create_temp_file("out-python-deps")
stderr_file <- create_temp_file("err-python-deps")

callr_conda_install <- callr::r_process_options(
func = function(python_deps) {
func = function(deps) {
cli::cli_progress_step(
msg = "Installing TF (v{python_deps$tf_version})",
msg_done = "Installed TF (v{python_deps$tf_version})!",
msg_failed = "Error installing TF (v{python_deps$tf_version})"
msg = "Installing TF (v{deps$tf_version})",
msg_done = "Installed TF (v{deps$tf_version})!",
msg_failed = "Error installing TF (v{deps$tf_version})"
)
tensorflow::install_tensorflow(
version = python_deps$tf_version,
version = deps$tf_version,
envname = "greta-env-tf2",
method = "conda"
)
dep_tfp <- glue::glue("tensorflow-probability=={python_deps$tfp_version}")
dep_tfp <- glue::glue("tensorflow-probability=={deps$tfp_version}")
cli::cli_progress_step(
msg = "Installing TFP (v{python_deps$tfp_version})",
msg_done = "Installed TFP (v{python_deps$tfp_version})!",
msg_failed = "Error installing TFP (v{python_deps$tfp_version})"
msg = "Installing TFP (v{deps$tfp_version})",
msg_done = "Installed TFP (v{deps$tfp_version})!",
msg_failed = "Error installing TFP (v{deps$tfp_version})"
)
reticulate::py_install(
packages = dep_tfp,
Expand All @@ -29,7 +29,7 @@ greta_install_python_deps <- function(timeout = 5,
method = "conda"
)
},
args = list(python_deps = python_deps),
args = list(deps = deps),
stdout = stdout_file,
stderr = stderr_file
)
Expand Down
Loading

0 comments on commit 1561d59

Please sign in to comment.