Continued odd behavior from Reticulate + Plumber

This is a follow up to an existing issue that was closed here: Unexpected Plumber API issues with Reticulate and RStudio Connect

I was successful in using the method that @edavidaja recommended - Include Python in the manifest.json and a requirements.txt file. However, when I called the API, I noticed that the non-standard RunAs user from Plumber was not included in the Python environment. It tried to run the Python code as rstudio-connect and it very silently failed.

Here is what I see in the application logs for RStudio Connect:

01/05 20:25:19.842 (GMT)

Environment will be built with Python "3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:39:48) [GCC 9.3.0]" at /opt/Python/3.9.6/bin/python3.9

01/05 20:25:19.843 (GMT)

Running as user: rstudio-connect

Is there a way to force Python to use the RunAs user that Plumber is using? Otherwise I'm stuck using the virtualenv approach that causes problems.

Apologies for the delayed response here! That's interesting!!

So to confirm I understand properly:

  • You have a Plumber API that is reticulated
  • The Plumber API is running as a non-default RunAs user
  • You are getting an issue running the python code / activating the python environment?

To answer your question in the previous thread: Yes, Connect will build a python environment for your Plumber API!

However, it is important to be sure that it is done properly. Would it be possible to share (either publicly here or privately in DM) your manifest.json file? Alternatively, you can compare it to the manifest.json in the repo that David linked in the last thread.

Basically the pieces needed to create a "python runtime" and make it available to the Plumber API:

  • requirements.txt
  • manifest.json with the appropriate "python bits" (python version, etc.)

If those are present, you should see deployment logs that show a "python environment restore" happening. If that is not happening, it would be best to make sure that the rsconnect package is updated to the latest version, the reticulate package is getting picked up in the manifest.json, etc.

I hope that helps (even if a good bit delayed :sweat_smile: )!