1

I've set up a drake pipeline that generates a report at the end of the pipeline. I would like to trigger a slack notification every time a new report is created. For the report part of my plan I use the following:

report_plan <- drake::drake_plan(
  report = rmarkdown::render(
    knitr_in("alerts.Rmd"),
    output_file = file_out("report.html"),
    quiet = TRUE),
  notification = target(slackr::slackr("A new vaccine report is ready"),   trigger = trigger(change = file.info("report.html")$ctime)),
  strings_in_dots = "literals"
)

The trigger on the notification target works, but in my dependency graph the notification target is just hanging out by itself:

enter image description here

Is there a better way to make the notification dependent on a new report being generated? Thanks!

Richard Telford
  • 9,558
  • 6
  • 38
  • 51
Jenna Allen
  • 454
  • 3
  • 11

1 Answers1

2

That's clever, I like it! What about a file_in() statement in the trigger? Maybe trigger = trigger(change = file.info(file_in("report.html"))$ctime If that triggers too often, maybe a knitr_in() statement on the source: trigger = trigger(change = file.info(knitr_in("report.html"))$ctime. I personally like the second of these options better.

Sorry I was so late in getting to this thread!

landau
  • 5,636
  • 1
  • 22
  • 50
  • I noticed that even with the file_in() call vis_drake_graph(drake_config(report_plan)) still shows a disconnected graph, but that bug is only in the visualization. plot(drake_config(report_plan)$graph) show that the notification actually does depend on the report when you use file_in("report.html") in the trigger. – landau Sep 28 '18 at 12:05
  • Okay, in the GitHub development version (via https://github.com/ropensci/drake/commit/96d57fab0cfa4f9e99978d954298318e75bb5247) the graph visualization should show `"report.html"` as a dependency of `notification` if you use `file_in("report.html")`. But even before that patch to the visualization, your workflow should work as expected. – landau Sep 28 '18 at 12:44
  • 1
    Awesome! Thanks for your help on this! I'll check out the development version. Also thanks for such a cool package. I'm just getting going with it and look forward to using it more. – Jenna Allen Oct 07 '18 at 20:56