Skip to content

sol-eng/python-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Posit Connect & Python

Posit Connect is a publishing platform for the work your team creates in R and Python. This repository contains examples of Python content you can deploy to Connect, including:

Interactive apps

Web APIs

Documents

Reticulate

Reticulate allows you to call Python from within an R session. This enables you to use models built in Python to power Shiny apps, visualize pandas dataframes with ggplot2, and much more.

Interactive apps

Documents

Getting Started

You can deploy examples from this repo to your Connect server via git-backed deployment, or clone the repository and deploy examples from their manifests with the rsconnect CLI.

If you want to explore an example more closely before deploying it:

  • Clone this repository
  • create a virtual environment in the folder you want to work in
  • restore the needed packages into the virtual environment
$ cd flask-sentiment-analysis-api
$ python -m venv .venv
$ source .venv/bin/activate
$ python -m pip install -U pip setuptools wheel
$ python -m pip install -r requirements.txt

For reticulated content, set the RETICULATE_PYTHON environment variable to point to your virtual environment, by placing an .Renviron file in the folder containing the following:

RETICULATE_PYTHON=.venv/bin/python

Publishing basics

Overview:

  • Create and activate a virtual environment
  • Run the examples locally
  • Acquire an API key
  • Publish the examples with the rsconnect cli
  • Save the environment and deployment details for future git-backed publishing
rsconnect add \
    --api-key <MY-API-KEY> \
    --server <https://connect.example.org:3939> \
    --name <SERVER-NICKNAME>
rsconnect deploy api . -n <SERVER-NICKNAME>