Deploying R shiny app as a standalone application [closed] - r

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 months ago.
The community reviewed whether to reopen this question 5 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I have developed a RShiny application which I would like to share internally with my colleagues (Hosting the app on a server, is not an option at this stage).
I was exploring various options, and I came across a technique for bundling your app as a standalone desktop application, with an installer file, which you can then share & distribute. (The approach is explained here & here)
This is quite neat, because the users installing it need not have R (and any other required packages) to install and run the app (it has portable versions of R, chrome etc)
I was able to follow the approach and create a standalone desktop application, with an installer file, which I can now start sharing.
However, this is my concern:
Ideally, I would not want my users to be able to access the source code. Is there a way to restrict such access? In the tutorial (the first link that I posted), this is what the author says:
*
Lastly, keep in mind that your source code is easily accessible. If
this is a concern for you (e.g. if you are distributing to a client
that should not have access to the code) the best you can do is impede
access by first compiling the sensitive source code into a binary
package. That said, any user who knows R (and has sufficient intent)
can simply dump the code to the console.
*
Are there better, more fool-proof ways to impede access?
Thanks!

There is now a way to turn a Shiny app into a standalone Electron app (which is a desktop app, used for apps like Slack). To find out more, see this excellent presentation (YouTube) from useR 2018, which contains further links:
GitHub ColumbusCollaboratory: electron-quick-start
GitHub ColumbusCollaboratory: Photon. RStudio Add-in to build Shiny apps utilizing the Electron framework
#TravisHinkelman's blog "Deploying a Shiny app as a desktop application with Electron"

I'm not sure if it would be a great fit on the code obscurity question, but the RInno package is designed to help with the data security problem, i.e. when a company does not want to share their data with a third party. It also automates the process you referenced above and allows you to connect your app to GitHub/Bitbucket to push out updates to locally installed shiny apps via API calls on startup.
To get started:
install.packages("RInno")
require(RInno)
RInno::install_inno()
Then you just need to call two functions to create an installation framework:
create_app(app_name = "myapp", app_dir = "path/to/myapp")
compile_iss()
If you would like to include R for your co-workers who don't have it installed, add include_R = TRUE to create_app:
create_app(app_name = "myapp", app_dir = "path/to/myapp", include_R = TRUE)
It defaults to include shiny, magrittr and jsonlite, so if you are using other packages like ggplot2 or plotly, just add them to the pkgs argument. You can also include GitHub packages to the remotes argument:
create_app(
app_name = "myapp",
app_dir = "path/to/myapp"
pkgs = c("shiny", "jsonlite", "magrittr", "plotly", "ggplot2"),
remotes = c("talgalili/installr", "daattali/shinyjs"))
If you are interested in other features, check out FI Labs - RInno. If you'd like a guide on how to connect it to GitHub/Bitbucket check out the Continuous Installation guide :).

You might be interested in DesktopDeployR, a framework for deploying self-contained R-based applications to the desktop.
https://github.com/wleepang/DesktopDeployR

I'm not familiar with that approach, is it common? I personally haven't ever seen it. It looks like essentially what you're doing is bundling R, Shiny, a web browser, and your code, into a file. It's as if the client installs R, Chrome, shiny, and runs your code, but he just does it all in one click. You're literally giving the user your code. I don't know how it works, but if the author himself claimed that the client will be able to see the source code, then that makes sense to me and I don't think you can avoid that.
Why not just host the file on a shiny server or shinyapps.io? The client won't see your code then. Also, is it really that important that they can't see your code? A lot of times people are afraid of others seeing their code but in reality nobody really cares to look at others people's code and steal it. Unless you have some very proprietary and advanced patented code.

You can also run your shiny app from a ".bat" executable file with code that runs your app from the command line.
Just open a txt editor and add the following line:
R -e "shiny::runApp('app.R',launch.browser=TRUE)
You can save it as, for example "test.bat". Rename app.R to whatever your shiny app name is. Make sure you have the launch browser set to TRUE, otherwise the app will only be "listening".
If you want to make sure any Rmd reporting works smoothly, also add the pandoc path to the code of your shiny app. For example add the line:
Sys.setenv(RSTUDIO_PANDOC="C:/Program Files/RStudio/bin/pandoc")
You can get your pandoc path by running: rmarkdown::find_pandoc()
Also make sure R is in your path environment (e.g. add "C:\Program Files\R\R-4.1.0\bin" to your path environment)
Users will have access to your source code if they really want to and R needs to be installed on the PC that runs the bat file, but it might be a nice way to quickly deploy a shinyapp, for instance, for small teams that have a shared workstation. And you don't need to pay for or install a server.

Related

R and Rstudio Docker vs Binder

My problem is that I can't use R-studio at my work place as the IT does not support it . I want to use R and R-studio that installed on my personnel laptop on my company laptop ( using a modern browser which is behind firewall ) . Some of the options I am thinking of two two things
should I need to build a docker for R and R-studio (I see base images are already available) , I am mostly interested in basic R , Dplyr (haven ,xporter, and Reticulate ) packages .
Should I have to use a binder . I am not technical person and my programming skills are very limited can any one suggest me way .
What exactly are the difference between using Docker option vs Binder ?
I know I can use R-Studio online and get my work done but with the new paid account I am running out of project hours and very slow sometimes . Thanks in advance
Here are some examples beyond the modern RStudio MyBinder example:
https://github.com/fomightez/pythonista_skewedf
https://github.com/fomightez/r_phylogenetics_worshop
https://github.com/fomightez/chapter7/tree/master/binder
The modern RStudio MyBinder example has been set as a template on GitHub so you can use
The first one is for a special use of a package not on conda. And I started that one from square one.
The other two were converted from content by others to aid in making them Binder-ready.
You essentially list everything you need from conda in the environment.yml along with the appropriate channels. If you need special stuff not on conda, you need the other configuration files included there.
Getting everything working can take some iterations on adding things, letting the image get built, and testing your libraries are available. Although you seem to think your situation is not overly complex.
The binder launch badges you see are just images where you modify the URL to point the MyBinder federation site at your repository. Look at the URL and you should see the pattern where you put studio at the end of the URL pointing at your repo. The form at MyBinder.org site can help with this; however, most often it is easier to just adapt a working launch badge's code copied from elsewhere. The form isn't set up at this time for making the URLs for launching to RStudio.
Download anything useful your create in a running session. The sessions timeout after 10 minutes, although RStudio usually keeps them active.
Lack of Persistence and limited memory, storage, & power can be drawbacks. The inherent reproducibility and portability are advantages.
MyBinder.org doesn't work with private repos. If you have code you don't want to share, you can upload it to the temporary session, using the repo for specifying the environment. You could host a private binderhub that does allow the use of private git repositories; however, that is probably overkill for your use case and exceed your ability level at this time.
GitHub isn't the only place to host repositories that can be pointed at the MyBinder system. If you go to the MyBinder.org page and click where it says 'GitHub' on the left side of the top line of the form, you can see a list of the sources at which you can host a repository and point the system to build an image and launch a container with that specified image.
Building the image from a source repository takes some minutes the first time. Once the image is built though on the service, launch is typically less than 30 seconds. Each time you make a change on the source repo, a build is necessary. Some changes don't cause the new build to be as long as the initial one as some optimizing is done to only build what is necessary after a change. Keep in mind there are several members of the federation around the workd and if traffic on the internet gets sent to where the built image isn't yet available, it will be built from scratch again first.
The Holepunch project is out there to offer some help for users working in the R ecosystem; however, with the R-Conda system that is now integrated into MyBinder it is pretty much as easy to do it the way I described. Last I knew, the Holepunch route makes a Dockerfile that isn't as easy to troubleshoot as using the current the R-Conda system route. Dockerfiles are essentially a last ditch configuration file that MyBinder can handle. The reason being the other configuration files are much easier and don't require knowing Dockerfile syntax. MyBinder aims to offer the ability to take advantage of Docker offering containers with a specified environment without users needing to know anything about Docker.
There is a Binder Help category for posting to get help at the Jupyter Discourse Forum. Some other examples of posts already there may help you troubleshoot.
Notice of a common pitfall
Most of the the configuration files for making a repository Binder-ready are simply text and can be edited right in the GitHub browser interface, without need to git or even cloning the repo locally.
Last I knew, there are two exceptions to this. The postBuild and start configuration files have settings that allow them to be run as scripts and these get altered in a way they no longer work if you edit them via the GitHub browser interface. (This was my experience when last I tried. Your mileage may vary or things may have changed now.) To edit those, you have to have git available on a system you have and pull one from some other source. Then edit that on your machine that has git working & add it your repo and push it back up from your local computer.
(If this is a problem, you can post in the Jupyter Discourse Forum Binder help category and you and I could coordinate where I fork and edit those files in your repo to your specifications and then make a pull request to update your source of the fork with those changes.)
If you are using Jupyter notebooks extensively then it may make sense to use Binder
But if you simply want to use R and Rstudio, then all you need is docker. A good resource is
https://github.com/rocker-org/rocker

How to run a shiny app as a standalone application?

I've some shiny app and I want to execute and to make it standalone application (it will be awesome if it will open via chrome).
I can't upload the app to the Net and I want that also co-workers without R studio or R
will use this app.
because of the security company - I can't download any software except R packages.
I saw here a few solution, but all of them included any software download.
I have done some research on this issue. The commenters are basically correct: you need the R binaries in some way, either a portable R or an R server. But there are solutions that allow it to bundle those with your code and hide the details from your users.
On option is to wrap your app along with
a portable R into a container application like Electron. The electron-quick-start project tries this.
The RInno package provides functions to bundle your app and R portable into an installer app. Every user runs the installer on their system once which will install your app, the packages and the code. But in the end users may not see the difference to other apps. They get a link in the start menu and that's it. I did that successfully. But it did not work out of the box. I had to adjust the output manually in several places.
A second container solution works with docker. That is what ShinyProxy does. See also this blog.
The package shinyShortcut (I quote) "will produce an executable file that runs the shiny app directly in the user's default browser".
Important to note: I haven't tested most of them. From reviewing the solutions I often get the feeling that these solutions might make releases somewhat complicated because there are always manual steps involved.

How to make sure the user of a shiny app is using the right package versions in R

Due to recent experience with several bugs created by updating packages, I wonder what the best approach is for the following problem:
I currently provide a stand alone version so to say of my shiny App (just the script files to run it locally) and run a long list of require() functions to load / install the needed packages. However, in the end I would like to use fixed package versions to avoid bugs created by changes in packages.
Is there a way to ensure that the user, who may have older or newer versions of packages on their computer, is using the right version of all the packages my app needs?
You can consider using packrat: https://rstudio.github.io/packrat/.
Unfortunately, private libraries don’t travel well; like all R
libraries, their contents are compiled for your specific machine
architecture, operating system, and R version. Packrat lets you
snapshot the state of your private library, which saves to your
project directory whatever information packrat needs to be able to
recreate that same private library on another machine.
Short tutorial:
RStudio - File - New Project - New Directory - New Project - "Do: use Path" - Create Project
Enter in the R(Studio) console:
Code:
packrat::init()
.libPaths() # test if libpath has changed
install.packages("reshape2") # installs within one of the packrat libpaths
Installing package into ‘C:/R/packRatTest/packrat/lib/x86_64-w64-mingw32/3.4.3’
Assumption would be that you can use and share RStudio Projects, but i think it would be hard to work without them anyway ;).
Try writing your shiny app as a package. You can, somewhat, control that through the description file.
Since you said you're using script take a look at: https://github.com/chasemc/electricShine
Even of you don't use it, hopefully looking at the code will help for things like setting the download repo to be a specific MRAN date.

Shiny as Stand-Alone Program

I wrote a Shiny app, and now I need to turn it into a Stand-Alone Program. The reasoning behind this is that I need to share the app but can't do this with shinyapps.io or a server as I need the app to be able to access user's folders.
So far, I found these 2 tutorials: deploying-desktop-apps and packaging-your-shiny-app. Both of them (supposedly) work on Windows, but I have a Mac, and I want to app to be available for users of all systems, or at least Mac and Linux. Any thoughts and suggestions would be appreciated!
I actually tried to follow the tutorial mentioned above, and can't even install R-portable for my Mac. So I'm looking for something different.
Running a Virtual Machine to follow Windows tutorial is an option, but in this case, the app will be Windows-specific, and I don't want this.
This thread is really old I know, but I'm also trying to find answers on creating a standalone version of R for Mac.
This would support for
https://github.com/chasemc/electricShine
which supports Windows

Is there a Protractor Reporting Tool that works with a cucumber framework? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Using protractor with cucumber and need a plug in or tool (free if possible) that will create a user friendly test report or at least a file that a test report can be generated from. Thank you!
The easiest thing to do is to compliment your current setup with the free and open-source Serenity/JS.
Serenity/JS is a next generation acceptance testing library, but in the most basic scenario, it can also act as an integration layer between Protractor and Cucumber.
This enables you to:
Run your tests in parallel and still get the aggregated, user-friendly test reports.
Enhance your test reports with screenshots of your app's UI without any additional plugins.
Fix some common problems related to Cucumber/WebDriver ControlFlow synchronisation and inaccurate reporting with just a single config change.
Try the Screenplay Pattern in some part of your project while keeping your other tests working as they used to. This way you minimise the risk of disrupting the work of your team while improving your tool set.
The below setup instructions are explained in detail in the manual, and the reports you'll get will look like this:
Setup
Install the serenity-js module from the npm and save it as a development dependency:
npm install serenity-js --save-dev
With the serenity-js module installed, you can update your Protractor configuration file to include:
exports.config = {
framework: 'custom',
frameworkPath: require.resolve('serenity-js'),
// ...
}
If you're currently using the protractor-cucumber-framework, you can simply replace it with serenity-js.
Report generation
Serenity/JS produces test execution reports in json format and to convert them to html you'll need serenity-cli (which is a node.js wrapper around the Serenity BDD CLI, which in turn is a Java program and you'll need the Java Runtime Environment 7 or newer to run it).
Install serenity-cli and save it as a development dependency:
npm install serenity-cli --save-dev
Next, add the following npm scripts to your package.json file:
"scripts": {
"prereport": "serenity update",
"report": "serenity run",
// other scripts ...
},
With the above setup complete running your protractor tests will produce test reports in the json format together with screenshots under target/site/serenity, and running npm run report will process those intermediary reports and produce the user-friendly HTML version you're after.
Hope this helps,
Jan
I'm using the cucumberjs-allure-reporter package and it provides a pretty extensive reporting capability. I've been able to create hooks that take screen shots, capture browser logs and network traffic reports after each step allowing me to track quite a bit of information for each test.
Instructions for setting it up is a bit vague, but once you find all of the info, it works like a charm.
you can try https://www.npmjs.com/package/cucumber-html-reporter, which integrates well with the Protractor
e.g. HTML Preview of Report with Pie Charts
Screenshot
https://github.com/igniteram/protractor-cucumber-allure
Use the above repo. It has two different html reports within it. you can also use the hooks to screenshot when there is a failure. I tried it and it works like a charm.

Resources