Workbench job R and Python versions

Workbench supports configuring R and Python versions available to Workbench jobs in a couple of ways:

  • Workbench can include interpreters registered for a particular cluster and resource in the cluster.
  • If a py-versions or r-versions file is present in the session, they are included in the list of possible interpreters.

Interpreters

The most comprehensive solution for making interpreters available is the rstudio-server interpreters command-line tool. This allows you to add R and Python interpreters to Workbench scoped to a particular cluster.

Interpreters include the following fields:

  • clusterName: Name of the cluster.
  • language: Interpreter language (r or python).
  • displayName: Human-readable name.
  • source: Source type (global, user, conda, venv, etc.).
  • path: Path to the interpreter.
  • executable: Identical to path unless it is a symlink in which case it is the ultimate target.
  • (Optional) resourceId: Resource identifier for the cluster. If resourceId is omitted, all jobs in the cluster use these interpreters. If resourceId is present, the jobs in the cluster use either an image or the name of a Slurm queue, depending on context.

Add interpreters

Interpreters can be registered globally, allowing any Workbench Job in the cluster to select them as an option. For example:

sudo rstudio-server interpreters add '[{
  "clusterName": "Local",
  "language": "r",
  "displayName": "R 4.4.3",
  "source": "system",
  "path": "/opt/R/4.4.3/bin/R",
  "executable": "/opt/R/4.4.3/bin/R"
}]'

In a containerized environment like Kubernetes, they can be associated with an image:

sudo rstudio-server interpreters add '[{
  "clusterName": "Kubernetes",
  "language": "r",
  "displayName": "R 4.4.3",
  "resource_id": "rstudio/workbench-session:ubuntu2204-r4.4.3_4.3.3-py3.12.11_3.11.13",
  "source": "system",
  "path": "/opt/R/4.4.3/bin/R",
  "executable": "/opt/R/4.4.3/bin/R"
}]'

In a Slurm environment, they can be associated with a queue:

sudo rstudio-server interpreters add '[{
  "clusterName": "Slurm",
  "language": "python",
  "displayName": "Python 3.12.1",
  "resource_id": "high-memory",
  "source": "system",
  "path": "/opt/python/3.12.1/bin/python",
  "executable": "/opt/python/3.12.1/bin/python3.12"
}]'

List interpreters

View all available interpreter environments or filter by cluster and resource ID:

# List all interpreters
sudo rstudio-server interpreters list
# Filter by cluster name
sudo rstudio-server interpreters list --cluster=Local
# Filter by cluster and resource ID
sudo rstudio-server interpreters list --cluster=Kubernetes \
   --resource-id=rstudio/workbench-session:ubuntu2204-r4.4.3_4.3.3-py3.11.13_3.10.18

Delete interpreters

Remove interpreter environments by ID, cluster, or resource:

# Delete by runtime ID
sudo rstudio-server interpreters delete --id=8f7e6d5c-4b3a-2d1c-9f8e-7d6c5b4a3f2e
# Delete all interpreters for a cluster
sudo rstudio-server interpreters delete --cluster=Kubernetes
# Delete by cluster and resource ID
sudo rstudio-server interpreters delete --cluster=Kubernetes \
  --resource-id=rstudio/workbench-session:ubuntu2204-r4.4.3_4.3.3-py3.11.13_3.10.18
Warning

If you delete by cluster name without specifying a resource ID, all interpreters for that cluster are deleted, regardless of their resource ID.

Inspect interpreters

Preview

Note

Inspection of interpreters is currently released as a preview and is not available for SUSE. Additionally the error handling is unpolished.

Discover available R and Python versions in your clusters, images, or queues:

# Inspect all interpreters in a cluster
sudo rstudio-server interpreters inspect --cluster=Local --user=a-workbench-user
  
# Inspect specific image
sudo rstudio-server interpreters inspect --cluster=Kubernetes \
  --user=a-workbench-user \
  --image=rstudio/workbench-session:ubuntu2204-r4.4.3_4.3.3-py3.11.13_3.10.18

# Inspect specific queue
sudo rstudio-server interpreters inspect --cluster=Slurm \
  --user=a-workbench-user \
  --queue=high-mem

# Include additional paths
sudo rstudio-server interpreters inspect --cluster=Local \
  --user=a-workbench-user \
  --python-path=/custom/python/3.12 \
  --r-path=/custom/R/4.4.0

The inspect command automatically discovers R and Python installations in the specified environment and returns their details. This is a read-only command and does not modify any interpreters.

To save the results, they may be written to file and add it later:

# Write the output of inspection to a file
sudo rstudio-server interpreters inspect --cluster=Local --user=a-workbench-user > local.json

# When the file looks good, add it
sudo rstudio-server interpreters add --file local.json

Or added directly through standard input:

# Pipe the output of inspection directly to add
sudo rstudio-server interpreters inspect --cluster=Local --user=a-workbench-user | sudo rstudio-server interpreters add --stdin

Inspection configuration

Configure default inspection behavior in /etc/rstudio/rserver.conf:

Setting Description Default
inspection-python-paths Python paths to search during inspection /opt/python
inspection-r-paths R paths to search during inspection /opt/R
inspection-timeout Maximum seconds for inspection job execution 300

See rserver.conf reference for complete configuration details.

py-versions and r-versions files

Including an r-versions file in the session at /var/lib/rstudio-server/r-versions adds the included R binaries to the options available when launching a Workbench Job:

[
  {
    "number": "4.3.2",
    "environment": {
      "R_HOME": "/opt/R/4.3.2"
    }
  },
  {
    "number": "4.2.3",
    "environment": {
      "R_HOME": "/opt/R/4.2.3"
    }
  }
]

Including a py-versions file in the session at /var/lib/rstudio-server/py-versions adds the included Python interpreters to the options available when launching a Workbench Job:

[
  {
    "number": "3.11.6",
    "path": "/opt/python/3.11.6/bin/python3"
  },
  {
    "number": "3.10.13",
    "path": "/opt/python/3.10.13/bin/python3"
  }
]
Back to top