Skip to content

Commit

Permalink
add first draft of async slides
Browse files Browse the repository at this point in the history
  • Loading branch information
rpodcast committed Sep 14, 2023
1 parent 1d8c680 commit 0aaaa57
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added materials/d1-9002-async/assets/img/shiny.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions materials/d1-9002-async/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: "Asynchronous Processing"
subtitle: "posit::conf(2023) <br> 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
32 changes: 32 additions & 0 deletions units/d1-9002-async.qmd
Original file line number Diff line number Diff line change
@@ -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}
<iframe class="slide-deck" src="../materials/d1-9002-async/" height="420" width="747" style="border: 1px solid #2e3846;"></iframe>
```

0 comments on commit 0aaaa57

Please sign in to comment.