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 |
Note

This functionality requires connectapi version 0.4.0 or later.

Use the get_runtimes() function to get a data frame of all available runtimes on the server.

library(connectapi)

client <- connect()
result <- get_runtimes(client)

The resulting table contains information on R, Python, Quarto, and Tensorflow versions available on the server. The cluster_name and image_name columns contain information relevant to off-host execution. They contain "Local" if Connect is not configured to use off-host execution.

> result
# A tibble: 7 × 4
   runtime    version cluster_name image_name
   <chr>      <chr>   <chr>        <chr>

 1 r          4.3.1   Local        Local
 2 r          4.4.0   Local        Local
 3 python     3.11.3  Local        Local
 4 python     3.12.4  Local        Local
 5 quarto     1.4.557 Local        Local
 6 quarto     1.5.55  Local        Local
 7 tensorflow 2.16.1  Local        Local

You can pass in any combination of "r", "python", "quarto", and "tensorflow" to get only information on those runtimes.

> get_runtimes(client, c("r", "python"))
# A tibble: 4 × 4
   runtime    version cluster_name image_name
   <chr>      <chr>   <chr>        <chr>

 1 r          4.3.1   Local        Local
 2 r          4.4.0   Local        Local
 3 python     3.11.3  Local        Local
 4 python     3.12.4  Local        Local