diff --git a/materials/d1-9002-async/assets/img/lego_line_pay.jpg b/materials/d1-9002-async/assets/img/lego_line_pay.jpg new file mode 100644 index 0000000..2f9df28 Binary files /dev/null and b/materials/d1-9002-async/assets/img/lego_line_pay.jpg differ diff --git a/materials/d1-9002-async/assets/img/shiny.png b/materials/d1-9002-async/assets/img/shiny.png new file mode 100644 index 0000000..281845f Binary files /dev/null and b/materials/d1-9002-async/assets/img/shiny.png differ diff --git a/materials/d1-9002-async/index.qmd b/materials/d1-9002-async/index.qmd new file mode 100644 index 0000000..4d05c6e --- /dev/null +++ b/materials/d1-9002-async/index.qmd @@ -0,0 +1,84 @@ +--- +title: "Asynchronous Processing" +subtitle: "posit::conf(2023)
Shiny in Production: Tools & Techniques" +author: "TBD" +footer: "[{{< var workshop_short_url >}}]({{< var workshop_full_url >}})" +format: + revealjs: + theme: [default, ../slides.scss] # moon= teal bg | dark + scrollable: true + incremental: false + slide-number: c/t # c/t | c | h/v | h.v + slide-tone: false #true + code-line-numbers: true + history: false +revealjs-plugins: + - codewindow +--- + +## Single (threaded) Line {background-image="assets/img/lego_line_pay.jpg" background-size="cover"} + +* A single R process managing the different tasks in a Shiny application +* Executed one-by-one + +# Should I care? + +## It Depends ... + +If you are the __only__ user for a quick and efficient app: Likely not + +::: {.notes} +TODO: Find a way to center the sentence vertically in the slide +::: + +## Crowd Pleaser + +Multiple users accessing the app __concurrently__: + +* Single-threaded R process serving multiple users in typical deployments + +## Asynchronous Processing (circa 2018) + +:::: {.columns} + +::: {.column width="50%"} + +### 📦 [`{promises}`](https://rstudio.github.io/promises/index.html) + +Handle objects representing the (eventual) result of an async operation + +::: + +::: {.column width="50%"} + +### 📦 [`{future}`](https://future.futureverse.org/) + +Launch tasks without blocking current R session + +::: + +:::: + +::: footer +[Using promises with Shiny](https://rstudio.github.io/promises/articles/promises_06_shiny.html) +::: + +## Introducing [`{crew}`](https://wlandau.github.io/crew/) + +> A distributed worker launcher for asynchronous tasks + +* Extends use of the [mirai](https://github.com/shikokuchuo/mirai) task scheduler to multiple computing backends +* Central controller object manages tasks (scales on fly) +* Supports multiple [controller groups](https://wlandau.github.io/crew/articles/controller_groups.html) for specialized worker types +* Fits nicely with [`{targets}`](https://docs.ropensci.org/targets/) and ... + +. . . + +![](assets/img/shiny.png){.absolute top=0 left=200} + +## Setting up for Success + +1. Create functions for long-running tasks +1. Create multiple [`reactiveVal`](https://shiny.posit.co/r/reference/shiny/latest/reactiveval) objects for bookkeeping +1. Set up a `{crew}` controller +1. Establish an event-driven push of task to the controller with monitoring of worker status diff --git a/units/d1-9002-async.qmd b/units/d1-9002-async.qmd new file mode 100644 index 0000000..52dc6bf --- /dev/null +++ b/units/d1-9002-async.qmd @@ -0,0 +1,32 @@ +--- +title: "Async Processing" +subtitle: "TBD" +author: "Eric Nantz & Michael Thomas" +date: "2023-09-18" +listing: + - id: exercises + contents: + - ../materials/d1-9002-async/ex-*.qmd + type: table + fields: [subtitle, title] + field-display-names: + subtitle: "Exercise" + sort: [filename] + sort-ui: false + filter-ui: false + image-placeholder: assets/img/placeholder.png +tbl-colwidths: [5,20,75] +--- + +## Slides + +::: callout-warning +These slides are under construction and will be finalized prior to the workshop date. +::: + +[View slides in full screen](../materials/d1-9002-async/index.html) + +```{=html} + +``` +