Posit Team :: Cheatsheet

Overview

Posit Team is the bundle of Posit’s most popular products including: Workbench, Connect, and Package Manager. Together, this bundle delivers an end-to-end toolchain for data science teams committed to R and Python, improving every step of a data scientist’s workflow, from developing insights, to deploying data products, to managing environments.

  • Posit Workbench: Development environment for creating insights.

  • Posit Connect: Hosting environment for accessing and sharing insights.

  • Posit Package Manager: R and Python package repository management.

1. Opening a New Session in Posit Workbench

Posit Workbench - New Session Options
  • Current integrated development environments (IDEs) include Jupyter Notebook, JupyterLab, RStudio Pro, and Visual Studio Code.

  • Cluster options may vary depending on how Posit Workbench is configured in your environment.

2. Configure Package Repositories

Check Current Repositories

Within an R session, you can check your R repositories by running:

options("repos")

For Python, you can use pip to list your current Python repositories:

pip config list

Configure Repositories with Posit Package Manager

To set your R repositories to Posit Package Manager, run:

options(repos = c(CRAN = "https://your-package-manager-url.com"))
Tip

To ensure this persists across sessions, add this line to your .Rprofile file.

To set your Python repositories to Posit Package Manager, run:

pip config set global.index-url https://your-package-manager-url.com
Tip

To ensure this persists across sessions, add this line to your .bashrc or .bash_profile file.

Obtaining Package Manager URL

To obtain the URL for your Posit Package Manager, click the SETUP button within the user interface of Posit Package Manager and scroll to Repository URL:. You can also leverage Posit Public Package Manager for CRAN, PyPI, and Bioconductor packages: https://p3m.dev/

3. Access Your Data

Access your data within Posit Team no matter where it lives and what format it is in, including:

  • Flat files: examples including data.csv, data.txt, data.parquet.

  • APIs: Interact with APIs using packages such as {requests} in Python or {httr2} and {jsonlite} in R.

  • Pins: Store and retrieve Python/R objects including data and models.

  • Databases: Connect to a variety of database types using DBI/DB-API/ODBC.

Database Interface (DBI) Example in R

Below is an example of connecting to a PostgreSQL database using the DBI package in R:

con <- DBI::dbConnect(
  RPostgres::Postgres(),
  hostname = "db.company.com",
  port = 5432)

Python Database API (DB-API) Example in Python

Below is an example of connecting to a PostgreSQL database using the psycopg2 package in Python:

con = sqlite3.connect('example.db')

Connecting to a Database using Open Database Connectivity (ODBC)

Below is an example of connecting to a PostgreSQL database using the odbc package in R:

con <- DBI::dbConnect(odbc::odbc(),
  driver = "PostgreSQL Driver",
  database = "test_db",
  UID = Sys.getenv("DB_USER"),
  PWD = Sys.getenv("DB_PASSWORD"),
  host = "localhost",
  port = 5432)

Below is an example of connecting to a PostgreSQL database using the pyodbc package in Python:

con = pyodbc.connect(
  driver = 'PostgreSQL',
  database = 'test_db',
  server = 'localhost',
  port = 5432,
  uid = os.getenv('DB_USER'),
  pwd = os.getenv('DB_PASSWORD'))

Posit Professional ODBC Drivers

A full list of Posit provided professional ODBC drivers can be found here: https://docs.posit.co/pro-drivers/

4. Run your Code

Posit Workbench includes multiple options for running your R and Python code, including:

5. Supported Content on Posit Connect

Currently supported content on Posit Connect includes:

Documents

  • Quarto

  • R Markdown

  • Jupyter Notebooks

    Important

    Most documents are considered “static.” However, documents created with Voilà or R Markdown that include Shiny components are considered “interactive.”

Applications

  • Shiny (R and Python)

  • Bokeh

  • Streamlit

  • Dash

APIs

  • Plumber

  • FastAPI

  • Flask

  • Tensorflow

  • plumbertableau

  • FastAPI Tableau

  • Vetiver

Pins

  • Pins

6. Publishing Content to Posit Connect

Connect supports multiple methods for publishing content, including:

  • rsconnect: Publish content directly from R using the rsconnect R package.
  • Command Line Interface (CLI): Publish content using the CLI within the rsconnect-python package.
  • Push Button Deployment: Publish content with the click of a button using push button deployment. This is natively available within RStudio Pro and Jupyter Notebooks. You can also access push button deployment using the Posit Publisher extension in Visual Studio Code.
  • Git: Publish directly from a Git repository
Tip

For Git deployment, content will automatically fetch from the associated remote Git repository and re-deploy. This allows for integration with Git-centric workflows and continuous deployment automation.

7. Share and Control Content on Posit Connect

Important

Your Posit Connect configuration and license may restrict which options are available to your content.

As the owner of content published to Posit Connect, you have access to the content settings. These settings include:

Info and Content Metadata

Easily modify the content’s title and metadata. You can also add a thumbnail to your content and get a glimpse into usage data.

Tip

The Posit Connect API Cookbook contains numerous recipes for accessing and reporting usage data: https://pos.it/cookbook.

Access Controls

Control who has access to your content. Options include:

  • Anyone - no login required: Content is public and open to anyone.

  • All users - login required: Content available to anyone that can access Posit Connect.

  • Specific users or groups: Content is available to specific users (or user groups) defined by the content’s owner.

Note

To share content on Posit Connect with others, all you need to share is the Content URL which can be customized.

Runtime Settings

Runtime settings allow publishers to easily tune and scale their applications and APIs. These settings include:

  • Processes and Connections: Interactive or scheduled content requires a process to execute the code. Examples include an R or Python process. Depending on the number of users accessing your content (Connections), you can modify the maximum and minimum number of processes for your content.

    Tip

    Content will remain running if the minimum processes is set to greater than 0. This is great for content with a long start up time.

  • Timeout Configurations: Control the time thresholds for content startup, idle time, and time since last data sent/received.

  • Process Execution: Content is initially configured to run on the server as a Unix user configured by your Posit Connect administrator, defaulting to the rstudio-connect user. Your content may need to run as a different Unix user due to resource permissions and constraints.

  • Execution Environment: Specify the image used to create the content execution container.

  • CPU and RAM Configurations: Easily modify initial and max amount of CPU and RAM content can use.

  • GPU Configurations: Your administrator can set application defaults or upper limits for both AMD and NVIDIA GPUs.

  • Environment Management: Administrators and content owners can configure the application-level default environment management strategy for a piece of content

Schedule and Email

Static documents that were published with accompanying source code can be configured to execute on a schedule of your choosing including:

  • By Minute

  • Hourly

  • Daily

  • Weekly

  • Semimonthly

  • Monthly

  • Yearly

Scheduled reports can be configured to send an email to targeted recipients upon successful completion.

Tip

You can customize the email sent by Connect using R Markdown (pos.it/rmd_email) and Quarto (pos.it/qmd_email).

Tags

Tags help organize, discover, and filter content more easily on the Connect dashboard. Please work with your administrator to establish a tag schema that best suits your team.

Environment Variables

Securely pass configuration options to your content on Posit Connect as environment variables including API Keys and Passwords.

Caution

Always avoid hard-coding API keys, passwords, or tokens in the source code of content published to Posit Connect. This is a major security concern!

Other Resources

  • Questions about sales and licensing? Contact sales@posit.co

  • Experiencing technical issues? Contact support@posit.co

  • Other questions? Contact info@posit.co

  • Posit Team documentation: https://docs.posit.co

  • Posit Team release notes: https://docs.posit.co/release-notes.html

  • Posit Community: Posit Community is an open forum for any open source or Posit Team quetsions: https://forum.posit.co

  • Monthly End-to-End Workflow Demos with Posit Team: Join our monthly Posit Team Demos on the last Wednesday of every month: https://pos.it/team-demo