Skip to content
Merged
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
20 changes: 5 additions & 15 deletions inst/tutorials/introduction-to-python/tutorial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,13 @@ description: Tutorial for introducing students to the Python language.
# Don't let reticulate auto-pick some random Python
Sys.setenv(RETICULATE_AUTOCONFIGURE = "FALSE")

# ---- Safe CRAN mirror + interactive-only installs ----
# DK: Why the if clause here?

if (is.null(getOption("repos")["CRAN"]) || !nzchar(getOption("repos")["CRAN"])) {
options(repos = c(CRAN = "https://cloud.r-project.org"))
}

# DK: What happens if all the packages are installed?

# Does interactive produce false here? And therefore no installs are ever done? Need to test that this works by removing some of the packages and running it. Do we need this section at all?

# ---- interactive-only installs ----
needed <- c("learnr", "tutorial.helpers", "knitr", "reticulate")
to_install <- setdiff(needed, rownames(installed.packages()))
if (interactive() && length(to_install)) {
install.packages(to_install, quiet = TRUE)
}

# SU: for the above im thinking of just taking it out and moving knitr and reticulate out of suggests and into imports in the description file to, which presumably do the same thing as above
library(learnr)
library(tutorial.helpers)
library(knitr)
Expand All @@ -50,15 +40,15 @@ learnr::tutorial_options(
exercise.timelimit = 60,
exercise.startover = TRUE
)

## CI stuff to check if the tutorial is being run in github actions and R CMD Check, because then the check wil fail because it cant run python packages or modify the env, like the venv
# ---- Environment flags ----
is_windows <- identical(.Platform$OS.type, "windows")

# Do we need in_ci? What does it mean?

in_ci <- identical(tolower(Sys.getenv("CI")), "true") ||
identical(tolower(Sys.getenv("R_CMD_CHECK")), "true") ||
!interactive()
identical(tolower(Sys.getenv("R_CMD_CHECK")), "true")


venv <- ".venv"
py_bin <- if (is_windows) file.path(venv, "Scripts", "python.exe") else file.path(venv, "bin", "python")
Expand Down