Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reticulate support for conda #409

Merged
merged 10 commits into from Mar 9, 2020
Merged

Conversation

scottmmjackson
Copy link
Contributor

Added two new args to deployApp (and therefore every deploy function that uses deployApp and passes args) and writeManifest:

  • forceGeneratePythonEnvironment: write a python environment file even if it exists
  • forceRequirementsTxtEnvironment: write a requirements.txt file even if we're in a conda environment

Updated environment.py to the latest version from https://github.com/rstudio/rsconnect-python/blob/2b8c5fe249e254e4b0dfdfa21301241375fbe49b/rsconnect/environment.py

Review Notes

environment.py doesn't need to be reviewed a second time

paste0 isn't used because it's not supported under our minimum version of R. (is there a tool we can use to give us these hints?)

Copy link

@jskress jskress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks.

Also, to sanity check -- are the Python script changes compatible with both Python 2 and Python 3? Do we still need to support both for rsconnect?

R/bundle.R Outdated Show resolved Hide resolved
R/bundle.R Outdated Show resolved Hide resolved
R/bundle.R Outdated Show resolved Hide resolved
R/bundle.R Outdated

tryCatch({
output <- system2(command = python, args = args, stdout = TRUE, stderr = NULL, wait = TRUE)
if(require('reticulate') && reticulate::py_config()$anaconda && !compatibilityMode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(require('reticulate') && reticulate::py_config()$anaconda && !compatibilityMode) {
if (requireNamespace('reticulate', quietly = TRUE) && reticulate::py_config()$anaconda && !compatibilityMode) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might also want to check reticulate::py_available(initialize = FALSE) as otherwise calling reticulate::py_config() will force reticulate to initialize Python.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using 'reticulate' %in% installed.packages() to avoid including reticulate in the namespace where it doesn't belong.

R/deployApp.R Outdated Show resolved Hide resolved
R/deployApp.R Outdated Show resolved Hide resolved
scottmmjackson and others added 8 commits March 9, 2020 09:02
Co-Authored-By: Kevin Ushey <kevin@rstudio.com>
Co-Authored-By: Kevin Ushey <kevin@rstudio.com>
Co-Authored-By: Kevin Ushey <kevin@rstudio.com>
Co-Authored-By: Kevin Ushey <kevin@rstudio.com>
Co-Authored-By: Kevin Ushey <kevin@rstudio.com>
@scottmmjackson scottmmjackson merged commit 30dc1d4 into master Mar 9, 2020
@scottmmjackson scottmmjackson deleted the sj-reticulate-conda branch March 9, 2020 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants