Site icon R-bloggers

RStudio Connect 2021.08.0 Python Updates

Python Updates

At RStudio we know that many data science teams leverage both R and Python in their work, so it’s important that we build products to support the best tools available in both languages. For an overview of all the ways our pro products support data science teams using R and Python, check out our Single Home for R and Python page.

APIs are a key to integrating your data science results into other applications and processes (see this blog post for more on APIs). With this RStudio Connect release, you can deploy, manage, and scale Python APIs built with FastAPI and several other ASGI-compliant frameworks. The list of supported Python content types has grown steadily over the last two years. This feature edition extends the capabilities even further with several options that enable asynchronous API development.

RStudio Connect Supported Python Content Types in 2021

Content Type Framework
Documents & Notebooks Jupyter Notebooks
Interactive Applications Dash, Streamlit, Bokeh
WSGI Frameworks Flask
ASGI Frameworks FastAPI, Quart, Falcon, Sanic

Additional Python Updates:

NOTE on versioning: As part of this release, we’ve moved to calendar-based versioning. See this blog post for details.

Click through to learn more about RStudio Connect

New Content Type: FastAPI

Support for Python ASGI frameworks in RStudio Connect.

FastAPI is a Python ASGI web API framework. Endpoints in FastAPI are Python async functions, which means that multiple requests can be processed concurrently. This is useful when the response of a request depends on the results of other async functions.

Example: If you use an asynchronous database client to access a remote database, your FastAPI endpoint function can await the results of the database query. This means that rather than getting blocked waiting for a response, new requests can begin to be processed while earlier requests are awaiting their results.

Learn more about FastAPI in the RStudio Connect User Guide.

Additional ASGI Frameworks

Although ASGI is a standard, frameworks differ in the configuration settings required to support being deployed behind a proxy server (as is the case for APIs deployed within RStudio Connect). These frameworks have been validated for deployment in RStudio Connect:

New Jump Start Example

The new FastAPI jump start example should look familiar to those who experimented with Flask. We’ve implemented the Stock Pricing Service example again in FastAPI so you can quickly see the differences between the two frameworks:

Get Started

FastAPI and other ASGI-compatible APIs can be deployed to RStudio Connect with the rsconnect-python package. Follow the same basic deployment steps required from our other python content types:

Pre-flight checks:

Deploy your ASGI-compliant API with:

rsconnect deploy fastapi -n myServer MyApiPath/
Upgrade your rsconnect-python CLI

Jupyter Notebook Feature: Hiding Code Cells

Introduced in RStudio Connect 1.9.0.

Hiding input code cells can be useful when preparing notebooks for audiences where a cleaner or less code-heavy presentation would be more appreciated.

There are two options for hiding input code cells in Jupyter Notebooks published to RStudio Connect:

If you’ve already set up the push-button publishing plugin for Jupyter Notebooks, make sure to upgrade rsconnect-jupyter, and rsconnect-python so you can get access to the new publishing features.

Learn more in the RStudio Connect User Guide.

Ending Support for Python 2

Starting January 2022, RStudio Connect will no longer support Python 2.

Python 2.7 has reached end of life maintenance status. Support from the Python language governing body ended on January 1, 2020 and it is no longer receiving security patches.

RStudio Connect has continued to support Python 2.7 beyond its EOL status, but we will join the community in ending support as of January 2022.

Factors that have gone into our decision include the following:

Steps for planning your migration:

Administrators should determine whether Python 2 content exists on your RStudio Connect server today.

Publishers should review the official porting guide and redeploy any mission critical content that currently relies on Python 2.

Upgrade to RStudio Connect 2021.08.0

Before upgrading, please review the full release notes. This release contains additional features described in the Custom Branding blog announcement.

Upgrade Planning

Upgrading RStudio Connect should require less than five minutes. If you are upgrading from a version earlier than 1.9.0.1, be sure to consult the release notes for the intermediate releases, as well. As noted above, this release has features that require updates to rsconnect-python and, if applicable, rsconnect-jupyter.

To perform an RStudio Connect upgrade, download and run the installation script. The script installs a new version of Connect on top of the earlier one. Existing configuration settings are respected.

# Download the installation script
curl -Lo rsc-installer.sh https://cdn.rstudio.com/connect/installer/installer-v1.9.3.sh

# Run the installation script
sudo bash ./rsc-installer.sh 2021.08.0
Sign up for RStudio Professional Product Updates