Dash with golem: First contact

{golem} has been developed to help building big Shiny application to put in production. What if {golem} could be used to build another popular interactive web application, recently made available to R programmers: Dash ?

What if, during our Summer break, every R user decided to switch to Dash ? Would all our work with Shiny and {golem} be lost ? How would the ThinkR team react to this disaster after two weeks of sunbathing ?

To leave home in good conditions, I took an hour to look at Dash. In this blog post, I will briefly explain why I left with confidence…
Moreover {golem} finally reached the CRAN during our holiday! What a good news to enjoy with Dash!

The interesting thing is that, like any other R code, everything can be a function. And, as we use to say, as soon as you write a function, you should build a R package, so that you are forced to document and test your work. If you need to know more about this way of thinking, you can read our article “Rmd first : Quand le developpement commence par la documentation”.

Here comes {golem} to deploy Dash

{golem} has been designed to help you build, document and deploy an interactive application divided in two parts: the UI and the server. We recommend the use of Shiny modules to separate the different parts of the application and ease the development.
With Dash, it is also recommended to separate your application into multiple functions for the same reasons. Of course, this does not work exactly in the same way than Shiny, but here, only the architecture is of interest.

With option showcase = FALSE, you will have to open your browser manually: browseURL("http://localhost:8050")

🎉

I did not try to add callbacks here, but I assume that this should work with the correct app_server() function.

Deploy Dash inside a Docker

If you follow us carefully, you know that we like to deploy our applications using Docker. We also like to play with Rstudio Connect, but in the case of Dash, as it comes with its own deployment way using Fiery, there is a conflict.

To create the correct Dockerfile to be deployed, {golem} helps us with golem::add_dockerfile(). You will have to modify layers to download Dash packages and also expose the correct port. Moreover, the Dockerfile created with {golem} assumes you built your golem before building the Docker container.
The code below will guide you:

Play with Dash and {golem}…

Now, if you want to test Dash for R, you can try with {golem} to help you build the raw structure. At least, this will drive you in the direction of documented and tested deployed applications. That being said, I cannot assure you that any other {golem} function will work with Dash, as {golem} has been designed to work with Shiny. Also, I cannot promise that Dash will be fully supported by {golem}, but we will keep an eye on it and see if it needs a different package or only a few tweaks.