jofaichow commited on
Commit
94e5651
1 Parent(s): 577ab1c

parallelised download function

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. app/app.R +7 -5
Dockerfile CHANGED
@@ -9,7 +9,7 @@ RUN R -q -e "install.packages(c('shinyWidgets', 'shinycssloaders'))"
9
 
10
  # other R packages
11
  RUN R -q -e "install.packages(c('DT', 'plotly', 'scico', 'ggthemes'))"
12
- RUN R -q -e "install.packages(c('data.table', 'dtplyr', 'Rnumerai'))"
13
 
14
  # copy the app to the image
15
  WORKDIR /shinyapp
 
9
 
10
  # other R packages
11
  RUN R -q -e "install.packages(c('DT', 'plotly', 'scico', 'ggthemes'))"
12
+ RUN R -q -e "install.packages(c('data.table', 'dtplyr', 'parallel', 'Rnumerai'))"
13
 
14
  # copy the app to the image
15
  WORKDIR /shinyapp
app/app.R CHANGED
@@ -9,6 +9,7 @@ library(scico)
9
  library(ggthemes)
10
  library(data.table)
11
  library(dtplyr)
 
12
  library(Rnumerai)
13
 
14
 
@@ -53,7 +54,7 @@ reformat_data <- function(d_raw) {
53
  "fncV3", "fncV3Percentile", "payout", "roundPayoutFactor",
54
  "roundNumber", "roundResolved", "selectedStakeValue",
55
  "tc", "tcPercentile")
56
- d_munged <- as.data.table(d_raw[, col_keep])
57
 
58
  # Reformat percentile
59
  d_munged[, corrPercentile := round(corrPercentile * 100, 6)]
@@ -316,7 +317,7 @@ ui <- shinydashboardPlus::dashboardPage(
316
  markdown(
317
  "
318
  - #### **0.1.0** — First prototype with an interactive table output
319
- - #### **0.1.1** — Added a functional `Payout Summary`
320
  - #### **0.1.2** — `Payout Summary` layout updates
321
  "),
322
  br(),
@@ -378,9 +379,10 @@ server <- function(input, output) {
378
  input$button_download,
379
  {
380
 
381
- # Download dataframes one by one (may parallelise this in the future)
382
- d_raw <- c()
383
- for (item in input$model) d_raw <- rbind(d_raw, download_raw_data(item))
 
384
 
385
  # Data munging
386
  d_munged <- reformat_data(d_raw)
 
9
  library(ggthemes)
10
  library(data.table)
11
  library(dtplyr)
12
+ library(parallel)
13
  library(Rnumerai)
14
 
15
 
 
54
  "fncV3", "fncV3Percentile", "payout", "roundPayoutFactor",
55
  "roundNumber", "roundResolved", "selectedStakeValue",
56
  "tc", "tcPercentile")
57
+ d_munged <- d_raw[, col_keep, with = FALSE]
58
 
59
  # Reformat percentile
60
  d_munged[, corrPercentile := round(corrPercentile * 100, 6)]
 
317
  markdown(
318
  "
319
  - #### **0.1.0** — First prototype with an interactive table output
320
+ - #### **0.1.1** — Added a functional `Payout Summary` page
321
  - #### **0.1.2** — `Payout Summary` layout updates
322
  "),
323
  br(),
 
379
  input$button_download,
380
  {
381
 
382
+ # Parallelised download
383
+ d_raw <- rbindlist(mclapply(X = input$model,
384
+ FUN = download_raw_data,
385
+ mc.cores = detectCores()))
386
 
387
  # Data munging
388
  d_munged <- reformat_data(d_raw)