ThinkR-open / golem

A Framework for Building Robust Shiny Apps
https://thinkr-open.github.io/golem/
Other
904 stars 132 forks source link

Profiling a golem app with profvis #146

Closed fmmattioni closed 4 years ago

fmmattioni commented 5 years ago

I have asked a question to @ColinFay on twitter regarding how I could run profvis in a golem app (twitter discussion may be accessed here).

The problem is that if we try to wrap profvis::profvis() into golemapp::run_app() (let's imagine here the golemappis the name of our app) as in:

profvis::profvis({
     golemapp::run_app()
})

We get the following error:

Error in parse_rprof(prof_output, expr_source) : No parsing data available. Maybe your function was too fast?

According to @ColinFay, the current workaround is to wrap golemapp::run_app() into print() and then wrap in in profvis::profvis() as in:

profvis::profvis({
  print(
    golemapp::run_app()
  )
})

Thank you all!

ColinFay commented 5 years ago

Thanks @fmmattioni!

As said on Twitter, that's because run_app() returns the App objet but doesn't actually run it.

The print S3 for shiny app object is responsible for launching the app.

Reminder to myself: talk about this profvis() / {golem} interaction somewhere.

dwhdai commented 4 years ago

Thanks! Another potential work-around that I have found is using the profvis_ui() and profvis_server() module. There is an example of this at the bottom of this page: https://rdrr.io/github/rstudio/profvis/man/profvis_ui.html#heading-4

ColinFay commented 4 years ago

Given #496, it's now possible to do profvis::profvis(run_app()) by default, no need for explicitly printing anymore :)

fmmattioni commented 3 years ago

Does anyone know if something changed with profvis?

Doing profvis::profvis(run_app()), I get the following:

Error in parse_rprof(prof_output, expr_source) : 
  No parsing data available. Maybe your function was too fast?
ColinFay commented 3 years ago

@fmmattioni the print arg turned to TRUE by default used to make shiny apps io and connect crash, so now you need to explicitly set the print argument to TRUE if you need to :)

fmmattioni commented 3 years ago

Hey, @ColinFay! Do you mean profvis(run_app(print = TRUE))? If so, I get the same error as above ☹️

MallerBeach commented 3 years ago

Hey, @ColinFay same error occurs for me.

rescalante-lilly commented 3 years ago

In case it's helpful the solution to this problem is documented here profvis(print(run_app()))