boomer

Debugging Tools to Inspect the Intermediate Steps of a Call

https://github.com/moodymudskipper/boomer

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.4%) to scientific vocabulary

Keywords from Contributors

visualisation standardization tidy-data data-model data-warehousing datawarehousing dbi dbplyr relational-databases latex
Last synced: 10 months ago · JSON representation

Repository

Debugging Tools to Inspect the Intermediate Steps of a Call

Basic Info
Statistics
  • Stars: 137
  • Watchers: 4
  • Forks: 3
  • Open Issues: 23
  • Releases: 1
Created over 5 years ago · Last pushed 12 months ago
Metadata Files
Readme Changelog

README.Rmd

---
output: github_document
---


[![R-CMD-check](https://github.com/moodymudskipper/boomer/workflows/R-CMD-check/badge.svg)](https://github.com/moodymudskipper/boomer/actions)


```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# boomer 

The *{boomer}* package provides debugging tools that let you inspect the
intermediate results of a call. The output looks as if we explode a call
into its parts hence the name.

* `boom()` prints the intermediate results of a call or a code chunk.
* `rig()` creates a copy of a function which will display the intermediate
  results of all the calls of it body.
* `rig_in_namespace()` rigs a namespaced function in place, so its always
  verbose even when called by other existing functions. It is especially handy
  for package development.

## Installation

Install CRAN version with:

``` r
install.packages("boomer")
```


Or development version with:

``` r
remotes::install_github("moodymudskipper/boomer")
```

## `boom()`

```{r, eval = FALSE}
library(boomer)
boom(1 + !1 * 2)
```

![](man/figures/README-1.png)

```r
boom(subset(head(mtcars, 2), qsec > 17))
```

![](man/figures/README-2.png)

You can use `boom()` with *{magrittr}* pipes or base R pipes: just pipe to `boom()` at the end of a pipe chain.

```{r, eval = FALSE}
library(magrittr)
mtcars %>%
  head(2) %>%
  subset(qsec > 17) %>%
  boom()
```

![](man/figures/README-3.png)

If a call fails, *{boomer}* will print intermediate outputs up to the occurrence of the error,
it can help with debugging: 

```{r, eval = FALSE}
"tomato" %>%
  substr(1, 3) %>%
  toupper() %>%
  sqrt() %>%
  boom()
```

![](man/figures/README-4.png)

`boom()` features optional arguments : 

* `clock`: set to `TRUE` to see how long each step (in isolation!) took to run.

* `print`: set to a function such as `str` to change what is printed (see `?boom` to see how to print differently depending on class). Useful alternatives would be `dplyr::glimpse` of `invisible` (to print nothing).

One use case is when the output is too long.

```{r, eval = FALSE}
boom(lapply(head(cars), sqrt), clock = TRUE, print = str)
```

![](man/figures/README-5.png)

`boom()` also works works on loops and multi-line expression.

```r
 boom(for(i in 1:3) paste0(i, "!"))
```

![](man/figures/README-6.png)

## `rig()`

`rig()` a function in order to `boom()` its body, its arguments are printed
by default when they're evaluated.

```{r, eval = FALSE}
hello <- function(x) {
  if(!is.character(x) | length(x) != 1) {
    stop("`x` should be a string")
  }
  paste0("Hello ", x, "!")
}
rig(hello)("world")
```

![](man/figures/README-7.png)

## `rig_in_namespace()`

`rig()` creates a copy of a function, but when developing a package we might
want to rig a function in place so it has a verbose output when called by other
functions. For this we can use `rig_in_namespace()`.

For instance you might have these functions in a package :


```{r}
cylinder_vol <- function(r, h) {
  h * disk_area(r)
}

disk_area <- function(r) {
  pi * r^2
}
```

`cylinder_vol` depends on `disk_area`, call `devtools::load_all()` then `rig_in_namespace()` on both
and enjoy the detailed output:

```{r, eval = FALSE}
devtools::load_all()
rig_in_namespace(cylinder_vol, disk_area)
cylinder_vol(3,10)
```

![](man/figures/README-9.png)

## `boom_on()` and `boom_off()`

While debugging a function, call `boom_on()` and all subsequent calls will be boomed,
call `boom_off()` to return to standard debugging.

![](man/figures/README-10.gif)

## `boom_shinyApp()`

A very experimental feature that allows you to rig the reactives of a shiny app. See `vignette("shiny", "boomer")` for more information.

For the following app, saved in a proper project/package:

```{r, eval = FALSE}
histogramUI <- function(id) {
  tagList(
    selectInput(NS(id, "var"), "Variable", choices = names(mtcars)),
    numericInput(NS(id, "bins"), "bins", value = 10, min = 1),
    plotOutput(NS(id, "hist"))
  )
}

histogramServer <- function(id) {
  moduleServer(id, function(input, output, session) {
    data <- reactive(mtcars[[input$var]])
    output$hist <- renderPlot({
      hist(data(), breaks = input$bins, main = input$var)
    }, res = 96)
  })
}

ui <- fluidPage(
  histogramUI("hist1")
)
server <- function(input, output, session) {
  histogramServer("hist1")
}
```

The output of `boom_shinyApp(ui, server)` will look like:

![](man/figures/README-11.gif)

There will be issues, please report!


## Addin

To avoid typing `boom()` all the time you can use the provided addin named *"Explode a call with `boom()`"*:
just attribute a key combination to it (I use ctrl+shift+alt+B on windows), select the
call you'd like to explode and fire away!

## Options

Several options are proposed to weak he printed output of {boomer}'s functions
and addin, see `?boomer` to learn about them.

In particular on some operating systems *{boomer}*'s functions' output might 
not always look good in markdown report or reprexes. 
It's due to how he system handles UTF-8 characters. In this case
one can use `options(boomer.safe_print = TRUE)` for a more satisfactory input. 

## Notes

*{boomer}* prints the output of intermediate steps as they are executed, and 
thus doesn't say anything about what isn't executed, it is in contrast with
functions like `lobstr::ast()` which return the parse tree. 

Thanks to @data_question for suggesting the name *{boomer}* on [twitter](https://twitter.com/data_question/status/1356615026988179464).

Owner

  • Name: Antoine Fabri
  • Login: moodymudskipper
  • Kind: user
  • Location: Brussels

GitHub Events

Total
  • Issues event: 1
  • Watch event: 2
  • Issue comment event: 3
  • Push event: 76
  • Pull request event: 44
Last Year
  • Issues event: 1
  • Watch event: 2
  • Issue comment event: 3
  • Push event: 76
  • Pull request event: 44

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 269
  • Total Committers: 4
  • Avg Commits per committer: 67.25
  • Development Distribution Score (DDS): 0.361
Past Year
  • Commits: 58
  • Committers: 3
  • Avg Commits per committer: 19.333
  • Development Distribution Score (DDS): 0.328
Top Committers
Name Email Commits
Antoine Fabri a****i@g****m 172
Kirill Müller k****r 86
Indrajeet Patil p****e@g****m 9
olivroy o****1@h****m 2

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 70
  • Total pull requests: 74
  • Average time to close issues: 3 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 7
  • Total pull request authors: 5
  • Average comments per issue: 2.93
  • Average comments per pull request: 0.24
  • Merged pull requests: 59
  • Bot issues: 0
  • Bot pull requests: 8
Past Year
  • Issues: 1
  • Pull requests: 40
  • Average time to close issues: N/A
  • Average time to close pull requests: less than a minute
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 37
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • moodymudskipper (43)
  • krlmlr (22)
  • nischalshrestha (1)
  • Andrzej-Andrzej (1)
  • daattali (1)
  • gsmolinski (1)
  • amrrs (1)
Pull Request Authors
  • krlmlr (50)
  • moodymudskipper (11)
  • github-actions[bot] (8)
  • olivroy (4)
  • IndrajeetPatil (1)
Top Labels
Issue Labels
wontfix (1)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • cran 236 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 4
  • Total maintainers: 1
proxy.golang.org: github.com/moodymudskipper/boomer
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.7%
Dependent repos count: 5.9%
Last synced: 11 months ago
cran.r-project.org: boomer

Debugging Tools to Inspect the Intermediate Steps of a Call

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 236 Last month
Rankings
Stargazers count: 3.3%
Forks count: 12.8%
Average: 17.9%
Dependent repos count: 25.5%
Dependent packages count: 29.8%
Maintainers (1)
Last synced: 11 months ago

Dependencies

DESCRIPTION cran
  • crayon * imports
  • methods * imports
  • pryr * imports
  • rlang * imports
  • rstudioapi * imports
  • styler * imports
  • withr * imports
  • lobstr * suggests
  • magrittr * suggests
  • testthat >= 3.0.0 suggests
.github/workflows/R-CMD-check-dev.yaml actions
  • ./.github/workflows/check * composite
  • ./.github/workflows/custom/after-install * composite
  • ./.github/workflows/custom/before-install * composite
  • ./.github/workflows/dep-matrix * composite
  • ./.github/workflows/install * composite
  • ./.github/workflows/rate-limit * composite
  • ./.github/workflows/update-snapshots * composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-r v2 composite
.github/workflows/R-CMD-check.yaml actions
  • ./.github/workflows/check * composite
  • ./.github/workflows/commit * composite
  • ./.github/workflows/custom/after-install * composite
  • ./.github/workflows/custom/before-install * composite
  • ./.github/workflows/git-identity * composite
  • ./.github/workflows/install * composite
  • ./.github/workflows/pkgdown-build * composite
  • ./.github/workflows/pkgdown-deploy * composite
  • ./.github/workflows/rate-limit * composite
  • ./.github/workflows/roxygenize * composite
  • ./.github/workflows/style * composite
  • ./.github/workflows/update-snapshots * composite
  • actions/checkout v3 composite
.github/workflows/check/action.yml actions
  • actions/upload-artifact main composite
  • r-lib/actions/check-r-package v2 composite
.github/workflows/install/action.yml actions
  • ./.github/workflows/get-extra * composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/lock.yaml actions
  • dessant/lock-threads v2 composite
.github/workflows/pkgdown-deploy/action.yml actions
  • nick-fields/retry v2 composite
.github/workflows/pkgdown.yaml actions
  • ./.github/workflows/custom/after-install * composite
  • ./.github/workflows/custom/before-install * composite
  • ./.github/workflows/git-identity * composite
  • ./.github/workflows/install * composite
  • ./.github/workflows/pkgdown-build * composite
  • ./.github/workflows/pkgdown-deploy * composite
  • ./.github/workflows/rate-limit * composite
  • actions/checkout v3 composite
.github/workflows/pr-commands.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/pr-fetch master composite
  • r-lib/actions/pr-push master composite
  • r-lib/actions/setup-r master composite
.github/workflows/revdep.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact main composite
  • r-lib/actions/setup-pandoc v2 composite
.github/workflows/style/action.yml actions
  • actions/cache v3 composite
.github/workflows/update-snapshots/action.yml actions
  • peter-evans/create-pull-request v4 composite