Shinyapps.io deploy fails on package install - r

I'm posting this because I have not managed to get the solutions posted other places working. I'm trying to re-deploy a shiny dash, but it is failing to install a package at deploy.
It's the BioConductor error, but the package it claims to fail for is a CRAN package, and so I have no idea what to do.
MRE:
library(ggseg); library(shiny); library(tidyverse); library(plotly)
# Define UI ----
ui <- fluidPage(
# Application title
titlePanel("Demonstration of ggseg package"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
radioButtons(inputId = "atlasChoice", label="Choose atlas",
choiceValues = c("dkt_3d","yeo7_3d",),
choiceNames = c("DKT", "Yeo7"),
inline = FALSE, width = NULL),
radioButtons(inputId = "positionChoice", label="Choose position",
choices = c("LCBC left","LCBC right"),
inline = FALSE, width = NULL)
),
# Show a plot of the generated distribution
mainPanel(
uiOutput("plotUI")
)
)
)
# Define server ----
server <- function(input, output) {
output$plotUI <- renderUI({
plotlyOutput("plotlyPlot")
})
output$plotlyPlot <- renderPlotly({
cc = strsplit(input$positionChoice, " ")[[1]]
ggseg3d(atlas=input$atlasChoice,
surface=cc[1],
hemisphere=cc[2]
)
})
}
# Run the application
shinyApp(ui = ui, server = server)
My repos are set as so:
getOption("repos")
BioCsoft
"https://bioconductor.org/packages/3.7/bioc"
BioCann
"https://bioconductor.org/packages/3.7/data/annotation"
BioCexp
"https://bioconductor.org/packages/3.7/data/experiment"
BioCworkflows
"https://bioconductor.org/packages/3.7/workflows"
CRAN
"https://cran.rstudio.com"
And the error is as following:
Preparing to deploy document...DONE
Uploading bundle for document: 619289...DONE
Deploying bundle: 1770029 for document: 619289 ...
Waiting for task: 573690766
building: Parsing manifest
################################ Begin Task Log ################################
################################# End Task Log #################################
Error: Unhandled Exception: Child Task 573690767 failed:
Error parsing manifest: Unable to determine package source for Bioconductor package oompaBase: Repository must be specified
Execution halted

I don't know if Athanasia's solved this in the end, but I had a similar problem today, so here's what worked for me, in case it's useful for someone else :)
My app uses biomaRt, which I think depends on Biobase. When I tried to deploy, I had the error:
Error: Unhandled Exception: Child Task 601909864 failed: Error parsing manifest: Unable to
determine package source for Bioconductor package Biobase: Repository must be specified
I changed my repos settings based on instructions I found here. This alone also didn't work for me.
Once I reinstalled Biomart using BiocInstaller::biocLite(), my app deployed successfully :)

Related

Encoding issue with Shiny App and RStudio

I am having a problem at the time of publishing a Shiny app created in RStudio. Locally it works great, but at the time of publishing, i am getting the following error:
Preparing to deploy application...DONE
Uploading bundle for application: 6271509...Detecting system locale ... DONE
Deploying bundle: 5891038 for application: 6271509 ...
Waiting for task: 1150562680
building: Building image: 6880241
building: Installing packages
building: Installing files
building: Pushing image: 6880241
deploying: Starting instances
success: Stopping old instances
Application successfully deployed to https://victuol.shinyapps.io/CorresponsalesSingleApp/
Deployment completed: https://victuol.shinyapps.io/CorresponsalesSingleApp/
Warning message:
Error detecting locale: Error in read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'raw'
(Using default: en_US)
The following is my working code:
library(shiny)
library(DT)
setwd("C:/Users/Usuario/Desktop/Proyecto Shiny Corresponsales")
library("openxlsx")
df<-read.xlsx("Base Datos Corresponsales Bancolombia LIMPIO Hoja 3.xlsx", sheet = 3,colNames = TRUE,cols=c(1,2,3,4,5,6))
ui <- basicPage(
tags$a(
href="https://lotopunto.negocio.site/",
tags$img(src = "Logo Loto Punto PNG.png", height = 260, width = 320, title = "Loto Punto Corresponsal Bancario")
),
h2(strong("Paga, Juega y Recarga. ¡Todo aquí!")),
h1("Mapa de Corresponsales Bancarios Bancolombia"),
h3("Digita en la celda 'Search', la ciudad donde estás ubicado.
Se desplegarán los Corresponsales Bancarios Bancolombia disponibles"),
DT::dataTableOutput("mytable")
)
server <- function(input, output) {
output$mytable = DT::renderDataTable({
df
})
}
# Run the application
shinyApp(ui, server)
I am using an excel table, which have characters in Spanish (e.g. "'"). Might this be the problem? How can this be fixed? Please provide an example of the solution.
Solved! All i had to do was to eliminate the following line:
setwd("C:/Users/Usuario/Desktop/Proyecto Shiny Corresponsales")
I tried this solution, written at this post: https://groups.google.com/g/shinyapps-users/c/Fuh74H78G4s

Shiny app runs locally, error when trying to deploy it

I am getting an error
The application failed to start: exited unexpectedly with code 1
Error in enforcePackage(name, curVersion) :
The shiny package was not found in the library.
Calls: local ... eval -> eval -> eval -> -> enforcePackage
Execution halted
when I try to deploy shiny app. I found similar problem that claimed that having library(shiny) solves it, it didn't help. I also tried lib=("path/to/shiny"), no effect.
Here is my code
library(shiny)
library(DT)
library(rmarkdown)
###
ui <- fluidPage(fluidRow(column(10, div(dataTableOutput("dataTable")))))
server <- function(input, output, session) {
data <- reactiveFileReader(100, session, 'excel.csv', read.csv)
output$dataTable <- renderDT(
data(),
class = "display nowrap compact",
filter = "top",
options = list(
scrollX = TRUE,
searchCols = default_search_columns,
search = list(regex = FALSE, caseInsensitive = FALSE, search = default_search)
)
)
}
shinyApp(ui, server)
rsconnect::deployApp('C:/path//app1.Rmd')
Any help is appreciated.
The error indicates that Shiny is not installed in the environment you are deploying to.
If deploying to a server you own, first install Shiny Server, and confirm that the examples work as expected.
Then consult with the Administrator's Guide to set it up as you like it.

R - shiny app - ERROR: Invalid git repo specification: 'ShinySky'

I try to run a shiny app on R studio, I get the error
"ERROR: Invalid git repo specification: 'ShinySky'"
with the message at the console:
"there is no package called ‘shinysky’
Warning: Error in parse_repo_spec: Invalid git repo specification: 'ShinySky'"
Any ideas how to resolve the issue?
install.packages("shiny")
library(shiny)
ui <- fluidPage(
sliderInput(inputId ="num", label = "Choose the sample size", value=5,
min=1, max=25 ),
plotOutput("hist")
)
server <- function(input, output, session) {
output$hist <- renderPlot({
hist(rnorm(input$num))
})
}
shinyApp (ui, server)

Error when deploying shiny app with reticulate, python and keras

I am trying to deploy shiny app, that uses reticulate and keras packages. I do not have any problem to run it locally, but real troubles appear, when I try to deploy it to shinyapps.io. My app.r file is as follows:
virtualenv_dir = Sys.getenv("VIRTUALENV_NAME")
python_path = Sys.getenv("PYTHON_PATH")
reticulate::virtualenv_create(envname = virtualenv_dir, python = python_path)
reticulate::virtualenv_install(virtualenv_dir, packages = c("numpy", "h5py", "scipy", "scikit-image", "pyyaml", "pillow"), ignore_installed = TRUE)
reticulate::use_virtualenv(virtualenv = virtualenv_dir)
library(shiny)
library(keras)
library(reticulate)
library(magick)
library(raster)
library(EBImage)
library(rdrop2)
library(plotly)
np <- import("numpy", convert=FALSE)
ndi <- import("scipy.ndimage", convert=FALSE)
segment <- import("skimage.segmentation", convert=FALSE)
feature <- import("skimage.feature", convert=FALSE)
model = load_model_hdf5("model_v02122020.h5")
ui <-
tagList(
fluidPage(
sidebarLayout(sidebarPanel(
fileInput("upload", "Choose a file", accept = c('image/png', 'image/jpeg')),
actionButton('click', 'Start')
),
mainPanel(
tabsetPanel(type="tabs",
tabPanel("Input image", plotOutput("InputImagePlot", height="100%")),
tabPanel("Output image", plotOutput("OutputImagePlot", height="100%")),
)
)
)
)
)
server <-
function(input, output, session) {
observeEvent(input$click, {
## some code for image processing
})
}
shinyApp(ui = ui, server = server)
My .Rprofile file is as follows (credit to this source):
VIRTUALENV_NAME = "virt_tf"
if (Sys.info()[["user"]] == "shiny"){
# Running on shinyapps.io
Sys.setenv(PYTHON_PATH = 'python3')
Sys.setenv(VIRTUALENV_NAME = VIRTUALENV_NAME) # Installs into default shiny virtualenvs dir
Sys.setenv(RETICULATE_PYTHON = paste0('/home/shiny/.virtualenvs/', VIRTUALENV_NAME, '/bin/python'))
} else if (Sys.info()[["user"]] == "rstudio-connect"){
# Running on remote server
Sys.setenv(PYTHON_PATH = '/opt/python/3.7.6/bin/python')
Sys.setenv(VIRTUALENV_NAME = paste0(VIRTUALENV_NAME, '/')) # include '/' => installs into rstudio-connect/apps/
Sys.setenv(RETICULATE_PYTHON = paste0(VIRTUALENV_NAME, '/bin/python'))
} else {
# Running locally
options(shiny.port = 7450)
Sys.setenv(PYTHON_PATH = 'python 3.6.12')
Sys.setenv(VIRTUALENV_NAME = VIRTUALENV_NAME) # exclude '/' => installs into ~/.virtualenvs/
# RETICULATE_PYTHON is not required locally, RStudio infers it based on the ~/.virtualenvs path
}
The deployment process seems to run completely according to R log:
rsconnect::deployApp()
Preparing to deploy application...Update application currently deployed at
https://name.shinyapps.io/appname/? [Y/n] y
DONE
Uploading bundle for application: 3428026...DONE
Deploying bundle: 4035381 for application: 3428026 ...
Waiting for task: 846214175
building: Parsing manifest
building: Building image: 4594673
building: Installing system dependencies
building: Fetching packages
building: Installing packages
building: Installing files
building: Pushing image: 4594673
deploying: Starting instances
terminating: Stopping old instances
Application successfully deployed to https://name.shinyapps.io/appname/
The error I get from the bottom of the log:
Error in value[[3L]](cond) : Installation of TensorFlow not found.
Python environments searched for 'tensorflow' package:
You can install TensorFlow using the install_tensorflow() function.
/home/shiny/.virtualenvs/virt_tf/bin/python3
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
When I try to include tensorflow into the list of packages required to be installed into my virtualenvironment I get the following error message:
Downloading tensorflow-2.3.1-cp35-cp35m-manylinux2010_x86_64.whl (320.4 MB)
Collecting tensorflow
Killed
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Error in value[[3L]](cond) :
Error installing package(s): 'numpy', 'h5py', 'scipy', 'scikit-image', 'pyyaml', 'pillow', 'tensorflow'
Execution halted
Out of memory!
As far as I understand, shinyapps.io pushes me to install tensorflow package into virtualenvironment. However, I guess, it should be in the list of available packages. But how to force using it?
This looks like an issue that might require changes to shinyapps or rsconnect. Please file an issue on github if you're still experiencing this.

R Shiny GoogleSheets4: Authentication error in Shinyio server on deployment?

Here is my code for a simple test app:
library(shiny)
library(shinydashboard)
library(googlesheets4)
library(googledrive)
library(DT)
drive_auth(email = "xxxx")
shinyws1<-gs4_create("WS1")
#table<-read_sheet("xxx")
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("Test App"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
numericInput("bins",
"Number of friends:",
min = 1,
max = 100,
value = 50),
actionButton("submit","Submit",class="btn-success")
),
# Show a plot of the generated distribution
mainPanel(
#blank so far
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
#results<-reactive(input$bins)
observeEvent(input$submit,{
shinyws1 %>% sheet_append(as.data.frame(input$bins))
})
}
# Run the application
shinyApp(ui = ui, server = server)
It works okay in my local server. But deployment fails.
Here is the error message generated after deployment in Shinyio server:
Error in value[[3L]](cond) : Can't get Google credentials.
Are you running googledrive in a non-interactive session? Consider:
* `drive_deauth()` to prevent the attempt to get credentials.
* Call `drive_auth()` directly with all necessary specifics.
* Read more in: https://gargle.r-lib.org/articles/non-interactive-auth.html
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
Does anyone know how to fix it? I've tried every workaround I found online, but it didn't work.

Resources