rstudio / rsconnect

Publish Shiny Applications, RMarkdown Documents, Jupyter Notebooks, Plumber APIs, and more
http://rstudio.github.io/rsconnect/
133 stars 81 forks source link

error when using configureApp(): attempt to apply non-function #271

Closed jorgepda closed 6 years ago

jorgepda commented 6 years ago

I have an app that's successfully deployed on shinyapps.io. When running the following line of code

rsconnect::configureApp("renkejhsph3863256", size="small", account="dnalc")

I get the error message

Error in client$configureApplication(application$id, propertyName, propertyValue) : 
  attempt to apply non-function
gusmclennan commented 6 years ago

I am having the same issue. Trying to resize a deployed app due to memory issues, but can't find a way to submit the configureApp command without getting the above error message. Let me know if you were able to resolve this @jorgepda !

colearendt commented 6 years ago

Very interesting! It looks like in configureApp, client no longer has a configureApplication method. Perhaps this is a bug, or maybe intentional removing?

https://github.com/rstudio/rsconnect/blob/31aaf03e7b2c7da4203b5d5511d5a10791d1a940/R/configureApp.R#L52-L59

names(client)
 [1] "status"                      "currentUser"                 "accountsForUser"             "getAccountUsage"            
 [5] "getBundle"                   "updateBundleStatus"          "createBundle"                "listApplications"           
 [9] "getApplication"              "getApplicationMetrics"       "getLogs"                     "createApplication"          
[13] "listApplicationProperties"   "setApplicationProperty"      "unsetApplicationProperty"    "uploadApplication"          
[17] "deployApplication"           "terminateApplication"        "inviteApplicationUser"       "addApplicationUser"         
[21] "removeApplicationUser"       "listApplicationAuthoization" "listApplicationUsers"        "listApplicationGroups"      
[25] "listApplicationInvitations"  "listTasks"                   "getTaskInfo"                 "getTaskLogs"                
[29] "waitForTask"  

I was able to determine that client$setApplicationProperty is ultimately what we want for sizing changes. I also confirmed that this worked.

client$setApplicationProperty("app-id", "application.instances.template", "small")

It looks like we may be getting a strange client that is unexpected (lucid has similar methods, but the two are not identical, which is putting us into this case). Maybe our comparison to lucid with identical is too strict? Not sure how to enumerate differences:

> names(lucid)
 [1] "status"                      "currentUser"                 "accountsForUser"             "getAccountUsage"            
 [5] "getBundle"                   "updateBundleStatus"          "createBundle"                "listApplications"           
 [9] "getApplication"              "getApplicationMetrics"       "getLogs"                     "createApplication"          
[13] "listApplicationProperties"   "setApplicationProperty"      "unsetApplicationProperty"    "uploadApplication"          
[17] "deployApplication"           "terminateApplication"        "inviteApplicationUser"       "addApplicationUser"         
[21] "removeApplicationUser"       "listApplicationAuthoization" "listApplicationUsers"        "listApplicationGroups"      
[25] "listApplicationInvitations"  "listTasks"                   "getTaskInfo"                 "getTaskLogs"                
[29] "waitForTask" 
jspiewak commented 6 years ago

I presume the issue is that it is choosing the wrong branch of the if clause in the case of trying to deploy to shinyapps.io, as it ought to be using the lucid.setApplicationProperty call.

jspiewak commented 6 years ago

This seems to be the only case of using identical to determine which client we have. I wonder if the introduction of the certificate in clientForAccount caused this identical call to start failing?

@jmcphers ?

jmcphers commented 6 years ago

Yes, it looks like we think the client isn't Lucid for some reason. This seems like an unusual way to dispatch to the appropriate setter so I've rewritten it.

https://github.com/rstudio/rsconnect/commit/cd0e0aa16d669197ac564d22c494d0b70345e9cf

@colearendt and/or @gusmclennan, can you confirm whether this fixes your issue? (You can use devtools::install_github("rstudio/rsconnect") install the development version.)

gusmclennan commented 6 years ago

Hey - have run devtools to install dev version, and retested. Getting different error messages now, so some progress...

Resubmitted configureApp request specifying "xlarge" size, and got this unexpected response:

> rsconnect::configureApp("GLORIA_Demo_1000_LaTrobe_Street", size = "xlarge", account = "brintelligence")
Error: HTTP 400
PUT https://api.shinyapps.io/v1/applications/360869/properties/application.instances.template?force=0
Validation Error: 'xlarge' is not allowed.

Wasn't sure whether our current account settings were restricting available size for instances (we are only the Starter plan). So tried to resize instance to Medium, and received this error message:

> rsconnect::configureApp("GLORIA_Demo_1000_LaTrobe_Street", size = "medium", account = "brintelligence")
Error in lint(appDir, appFiles, appPrimaryDoc) : 
  Cancelling deployment: invalid project layout.
The project should have one of the following layouts:
1. 'shiny.R' and 'ui.R' in the application base directory,
2. 'shiny.R' and 'www/index.html' in the application base directory,
3. 'app.R' or a single-file Shiny .R file,
4. An R Markdown (.Rmd) document,
5. A static HTML (.html) or PDF (.pdf) document.
6. 'plumber.R' API description .R file
7. 'entrypoint.R' plumber startup script
8. A tensorflow saved model

The app we have deployed is a single Shiny R file, that currently works on shinyapps.io, albeit with memory issues since the most recent deployment.

FYI - I am running Microsoft R Open v3.5.0, and RStudio v1.0.153

Thanks for your assistance, please let me know when you need me to retest anything.

jspiewak commented 6 years ago

@gusmclennan the Starter plan cannot use instance types beyond "large". Clearly the error message could use some improvement there.

Just to confirm, for the second error your working directory was the project directory?

gusmclennan commented 6 years ago

@jspiewak - yes, I think so. I deployed the app to Shinyapps from my working directory in R Studio (if that answers the question...).

jspiewak commented 6 years ago

@gusmclennan in that case I need to defer to folks more familiar with the innards of rsconnect. Could you please add a directory listing for your project directory?

jorgepda commented 6 years ago

Hi all. I installed the dev version and was able to run the command rsconnect::configureApp("renkejhsph3863256", size="small", account="dnalc")

I am now getting the following error

Preparing to deploy application...DONE
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 1, 0
jmcphers commented 6 years ago

Should be fixed now on master -- thanks for reporting!