+ "markdown": "---\ntitle: \"Posit Team :: Cheatsheet\"\nimage-alt: \"\"\nengine: knitr\nexecute:\n eval: false\n output: false\n warning: false\ncode-overflow: wrap\n---\n\n::: column-margin\n```{=html}\n<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.\" />\n<br><br>\n```\n:::\n\n\n::: {.cell .column-margin}\n<a href=\"../posit-team.pdf\">\n<p><i class=\"bi bi-file-pdf\"></i> Download PDF</p>\n<img src=\"../pngs/posit-team.png\" width=\"200\" alt=\"\"/>\n</a>\n<br><br>\n:::\n\n\n## Overview\n\nPosit Team is the bundle of Posit's most popular products including: Workbench, Connect, and Package Manager.\nTogether, 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.\n\n- **Posit Workbench:** Development environment for creating insights.\n\n- **Posit Connect:** Hosting environment for accessing and sharing insights.\n\n- **Posit Package Manager:** R and Python package repository management.\n\n## 1. Opening a New Session in Posit Workbench\n\n{fig-align=\"center\"}\n\n- Current integrated development environments (IDEs) include **Jupyter Notebook, JupyterLab, RStudio Pro,** and **Visual Studio Code**.\n\n- Cluster options may vary depending on how Posit Workbench is configured in your environment.\n\n## 2. Configure Package Repositories\n\n### Check Current Repositories\n\nWithin an R session, you can check your R repositories by running:\n\n\n::: {.cell}\n\n```{.r .cell-code}\noptions(\"repos\")\n```\n:::\n\n\nFor Python, you can use `pip` to list your current Python repositories:\n\n\n::: {.cell}\n\n```{.bash .cell-code}\npip config list\n```\n:::\n\n\n### Configure Repositories with Posit Package Manager\n\nTo set your R repositories to Posit Package Manager, run:\n\n\n::: {.cell}\n\n```{.r .cell-code}\noptions(repos = c(CRAN = \"https://your-package-manager-url.com\"))\n```\n:::\n\n\n::: callout-tip\nTo ensure this persists across sessions, add this line to your `.Rprofile` file.\n:::\n\nTo set your Python repositories to Posit Package Manager, run:\n\n\n::: {.cell}\n\n```{.bash .cell-code}\npip config set global.index-url https://your-package-manager-url.com\n```\n:::\n\n\n::: callout-tip\nTo ensure this persists across sessions, add this line to your `.bashrc` or `.bash_profile` file.\n:::\n\n### Obtaining Package Manager URL\n\nTo 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:**.\nYou can also leverage Posit Public Package Manager for CRAN, PyPI, and Bioconductor packages: <https://p3m.dev/>\n\n## 3. Access Your Data\n\nAccess your data within Posit Team no matter where it lives and what format it is in, including:\n\n- **Flat files:** examples including `data.csv`, `data.txt`, `data.parquet`.\n\n- **APIs:** Interact with APIs using packages such as {requests} in Python or {httr2} and {jsonlite} in R.\n\n- **Pins:** Store and retrieve Python/R objects including data and models.\n\n- **Databases:** Connect to a variety of database types using DBI/DB-API/ODBC.\n\n### Database Interface (DBI) Example in R\n\nBelow is an example of connecting to a PostgreSQL database using the DBI package in R:\n\n\n::: {.cell}\n\n```{.r .cell-code}\ncon <- DBI::dbConnect(\n RPostgres::Postgres(),\n hostname = \"db.company.com\",\n port = 5432)\n```\n:::\n\n\n### Python Database API (DB-API) Example in Python\n\nBelow is an example of connecting to a PostgreSQL database using the `psycopg2` package in Python:\n\n\n::: {.cell}\n\n```{.python .cell-code}\ncon = sqlite3.connect('example.db')\n```\n:::\n\n\n### Connecting to a Database using Open Database Connectivity (ODBC)\n\nBelow is an example of connecting to a PostgreSQL database using the `odbc` package in R:\n\n\n::: {.cell}\n\n```{.r .cell-code}\ncon <- DBI::dbConnect(odbc::odbc(),\n driver = \"PostgreSQL Driver\",\n database = \"test_db\",\n UID = Sys.getenv(\"DB_USER\"),\n PWD = Sys.getenv(\"DB_PASSWORD\"),\n host = \"localhost\",\n port = 5432)\n```\n:::\n\n\nBelow is an example of connecting to a PostgreSQL database using the `pyodbc` package in Python:\n\n\n::: {.cell}\n\n```{.python .cell-code}\ncon = pyodbc.connect(\n driver = 'PostgreSQL',\n database = 'test_db',\n server = 'localhost',\n port = 5432,\n uid = os.getenv('DB_USER'),\n pwd = os.getenv('DB_PASSWORD'))\n```\n:::\n\n\n### Posit Professional ODBC Drivers\n\nA full list of Posit provided professional ODBC drivers can be found here: <https://docs.posit.co/pro-drivers/>\n\n## 4. Run your Code\n\nPosit Workbench includes multiple options for running your R and Python code, including:\n\n- Support for multiple R and Python versions.\n\n- Support for virtual environments (e.g., `venv`) and project-oriented workflows.\n\n- 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>).\n\n## 5. Supported Content on Posit Connect\n\nCurrently supported content on Posit Connect includes:\n\n### Documents\n\n- Quarto\n\n- R Markdown\n\n- Jupyter Notebooks\n\n ::: callout-important\n Most documents are considered \"static.\" However, documents created with Voilà or R Markdown that include Shiny components are considered \"interactive.\"\n :::\n\n### Applications\n\n- Shiny (R and Python)\n\n- Bokeh\n\n- Streamlit\n\n- Dash\n\n### APIs\n\n- Plumber\n\n- FastAPI\n\n- Flask\n\n- Tensorflow\n\n- plumbertableau\n\n- FastAPI Tableau\n\n- Vetiver\n\n### Pins\n\n- Pins\n\n## 6. Publishing Content to Posit Connect\n\nConnect supports multiple methods for publishing content, including:\n\n- **`rsconnect`:** Publish content directly from R using the rsconnect R package.\n- **Command Line Interface (CLI):** Publish content using the CLI within the `rsconnect-python` package.\n- **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.\n- **Git:** Publish directly from a Git repository\n\n::: callout-tip\nFor Git deployment, content will automatically fetch from the associated remote Git repository and re-deploy.\nThis allows for integration with Git-centric workflows and continuous deployment automation.\n:::\n\n## 7. Share and Control Content on Posit Connect\n\n::: callout-important\nYour Posit Connect configuration and license may restrict which options are available to your content.\n:::\n\nAs the owner of content published to Posit Connect, you have access to the *content* *settings*.\nThese settings include:\n\n### Info and Content Metadata\n\nEasily modify the content's title and metadata.\nYou can also add a thumbnail to your content and get a glimpse into usage data.\n\n::: callout-tip\nThe Posit Connect API Cookbook contains numerous recipes for accessing and reporting usage data: <https://pos.it/cookbook>.\n:::\n\n### Access Controls\n\nControl who has access to your content.\nOptions include:\n\n- **Anyone - no login required:** Content is public and open to anyone.\n\n- **All users - login required:** Content available to anyone that can access Posit Connect.\n\n- **Specific users or groups:** Content is available to specific users (or user groups) defined by the content's owner.\n\n::: callout-note\nTo share content on Posit Connect with others, all you need to share is the **Content URL** which can be customized.\n:::\n\n### Runtime Settings\n\nRuntime settings allow publishers to easily tune and scale their applications and APIs.\nThese settings include:\n\n- **Processes and Connections:** Interactive or scheduled content requires a **process** to execute the code.\n Examples include an R or Python process.\n Depending on the number of users accessing your content (**Connections**), you can modify the maximum and minimum number of processes for your content.\n\n ::: callout-tip\n Content will remain running if the minimum processes is set to greater than 0.\n This is great for content with a long start up time.\n :::\n\n- **Timeout Configurations:** Control the time thresholds for content startup, idle time, and time since last data sent/received.\n\n- **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.\n Your content may need to run as a different Unix user due to resource permissions and constraints.\n\n- **Execution Environment:** Specify the image used to create the content execution container.\n\n- **CPU and RAM Configurations:** Easily modify initial and max amount of CPU and RAM content can use.\n\n- **GPU Configurations:** Your administrator can set application defaults or upper limits for both AMD and NVIDIA GPUs.\n\n- **Environment Management:** Administrators and content owners can configure the application-level default environment management strategy for a piece of content\n\n### Schedule and Email\n\nStatic documents that were published with accompanying source code can be configured to execute on a schedule of your choosing including:\n\n- By Minute\n\n- Hourly\n\n- Daily\n\n- Weekly\n\n- Semimonthly\n\n- Monthly\n\n- Yearly\n\nScheduled reports can be configured to send an email to targeted recipients upon successful completion.\n\n::: callout-tip\nYou 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)).\n:::\n\n### Tags\n\nTags help organize, discover, and filter content more easily on the Connect dashboard.\nPlease work with your administrator to establish a tag schema that best suits your team.\n\n### Environment Variables\n\nSecurely pass configuration options to your content on Posit Connect as environment variables including **API Keys** and **Passwords**.\n\n::: callout-caution\nAlways avoid hard-coding API keys, passwords, or tokens in the source code of content published to Posit Connect.\nThis is a major security concern!\n:::\n\n## Other Resources\n\n- Questions about sales and licensing?\n Contact sales\\@posit.co\n\n- Experiencing technical issues?\n Contact support\\@posit.co\n\n- Other questions?\n Contact info\\@posit.co\n\n- Posit Team documentation: <https://docs.posit.co>\n\n- Posit Team release notes: <https://docs.posit.co/release-notes.html>\n\n- **Posit Community**: Posit Community is an open forum for any open source or Posit Team quetsions: <https://forum.posit.co>\n\n- **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>\n",
0 commit comments