Viewing Available Python, R, and Quarto Runtime Versions

Problem

You want to view the available versions of Python, R, and Quarto on your Connect server.

Solution

Create a table summarizing the available versions of each runtime. Do this by querying the Connect server for available runtimes, and then formatting the JSON response into a data frame.

from posit.connect import Client
import pandas as pd

def tidy_settings(runtime_type):
    with Client() as client:
        settings = client.get(f"v1/server_settings/{runtime_type}").json()
        df = pd.DataFrame(settings["installations"])
        df["runtime"] = runtime_type
        return df[["runtime", "version"]]

runtimes = ["python", "r", "quarto"]
result = pd.concat([tidy_settings(rt) for rt in runtimes], ignore_index=True)
>>> result
|runtime |version |
|:-------|:-------|
|python  |3.8.17  |
|python  |3.9.17  |
|python  |3.10.13 |
|python  |3.11.6  |
|r       |4.1.3   |
|r       |4.2.3   |
|r       |4.3.2   |
|quarto  |1.3.340 |
|quarto  |1.3.450 |
|quarto  |1.4.549 |
library(connectapi)
library(purrr)
client <- connect()

tidy_settings <- function(type = c("r", "python", "quarto")) {
  type = match.arg(type)
  settings = client$GET(paste0("v1/server_settings/", type))
  out = map_dfr(settings$installations, ~as.data.frame(.))
  out$runtime = type
  return(out[, c("runtime", "version")])
}

result <- map_dfr(c("python", "r", "quarto"), tidy_settings)
> result
|runtime |version |
|:-------|:-------|
|python  |3.8.17  |
|python  |3.9.17  |
|python  |3.10.13 |
|python  |3.11.6  |
|r       |4.1.3   |
|r       |4.2.3   |
|r       |4.3.2   |
|quarto  |1.3.340 |
|quarto  |1.3.450 |
|quarto  |1.4.549 |