Skip to content

Commit

Permalink
Merge pull request #559 from ryjohnson09/main
Browse files Browse the repository at this point in the history
Add Posit Team Cheatsheet
  • Loading branch information
mine-cetinkaya-rundel authored Oct 1, 2024
2 parents 4ee6c2f + 78cee89 commit 7d7b3b5
Show file tree
Hide file tree
Showing 6 changed files with 397 additions and 0 deletions.
59 changes: 59 additions & 0 deletions html/images/logo-team-full-color.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/posit-workbench-session.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
338 changes: 338 additions & 0 deletions html/posit-team.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,338 @@
---
title: "Posit Team :: Cheatsheet"
image-alt: ""
engine: knitr
execute:
eval: false
output: false
warning: false
code-overflow: wrap
---

::: column-margin
```{=html}
<img src="images/logo-team-full-color.svg" height="50" alt="Posit Team logo with the Posit orange and blue logo on the left followed by Posit Team text." />
<br><br>
```
:::

```{r}
#| output: asis
#| echo: false
#| eval: true
#| column: margin
source("common.R")
sheet_name <- tools::file_path_sans_ext(knitr::current_input())
pdf_preview_link(sheet_name)
translation_list(sheet_name)
```

## 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](images/posit-workbench-session.png){fig-align="center"}

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

```{r}
options("repos")
```

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

```{bash}
pip config list
```

### Configure Repositories with Posit Package Manager

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

```{r}
options(repos = c(CRAN = "https://your-package-manager-url.com"))
```

::: callout-tip
To ensure this persists across sessions, add this line to your `.Rprofile` file.
:::

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

```{bash}
pip config set global.index-url https://your-package-manager-url.com
```

::: callout-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:

```{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:

```{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:

```{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:

```{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:

- Support for multiple R and Python versions.

- Support for virtual environments (e.g., `venv`) and project-oriented workflows.

- Submit long-running Python/R jobs to Posit Workbench server to run in independent sessions using **Workbench Jobs** within RStudio Pro (<https://docs.posit.co/ide/server-pro/user/rstudio-pro/guide/workbench-jobs.html>) and VS Code (<https://docs.posit.co/ide/server-pro/user/vs-code/guide/workbench-jobs.html>).

## 5. Supported Content on Posit Connect

Currently supported content on Posit Connect includes:

### Documents

- Quarto

- R Markdown

- Jupyter Notebooks

::: callout-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

::: callout-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

::: callout-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.

::: callout-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.

::: callout-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.

::: callout-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.

::: callout-tip
You can customize the email sent by Connect using R Markdown ([pos.it/rmd_email](https://pos.it/rmd_email)) and Quarto ([pos.it/qmd_email](https://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**.

::: callout-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>
Binary file added pngs/posit-team.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added posit-team.pdf
Binary file not shown.
Binary file added powerpoints/posit-team.pptx
Binary file not shown.

0 comments on commit 7d7b3b5

Please sign in to comment.