Drake: include an easy way to set debug after a failure?

Created on 6 Oct 2018  路  15Comments  路  Source: ropensci/drake

A common workflow I have is:

  • error occurs
  • run diagnose(<target_name>)
  • fish out the command from the plan
  • run debug(<that_command>)
  • run make

I wonder if there's a nice way to run all the last 3 steps at once automatically? Like as simple as drake_debug() and then it starts trying to build that target under debug mode.

new feature use case

All 15 comments

I think it's a great idea, though I think make() may be a bit heavy. What about a drake_debug(target, config) that acts like drake_build() but with debug(<command>)?

That's kind of what I had in mind - but when the target errors out couldn't you get it to store something temporary that indicates which target failed? Is using config necessary as well? Why not just the plan? It would also have to wrap the command in a function as commands aren't always functions.

Good questions.

That's kind of what I had in mind - but when the target errors out couldn't you get it to store something temporary that indicates which target failed?

Failures are logged to a "progress" storr namespace. Have you tried failed() or progress()? Failed targets are also colored red in vis_drake_graph() and friends.

Is using config necessary as well? Why not just the plan?

Because we want to load all the dependencies before running the command (loadd(deps = TRUE)). drake_build() does this relatively quickly using pre-calculated information in config, and reliance on config is a consistent design pattern in drake.

It would also have to wrap the command in a function as commands aren't always functions.

That's not so hard.

The most recent config is alwayed cached by make, yeah? Is it possible to make the config argument optional?

Yeah, let's make drake::read_drake_config() the default value of the config arg. And please feel free to submit PRs for other functions if I have forgotten to do that elsewhere.

Just used drake_debug() today at work. What a great idea, Kendon!

Is it possible to use the output of failed as the default for target?

You mean make(plan, targets = failed())?

No, I meant something like drake_debug(target = failed()[1])

Sure, we can use failed()[1] as the default value of target.

Added in 8ec01c25b302e0870e7337007672104de1ef609f. If a single target failed in the last make(), drake_debug() with no arguments will run it in debug mode.

Why not use the first failure in the case when more than one target fails? Perhaps with a warning that there are more failures?

I suppose that might be useful for parallel targets. But this is just a default value, so it seems oddly elaborate to grab the timestamps from get_cache()$get(target, namespace = "meta") and sort the failed targets by time stamp. I would be happy to review a pull request on this.

I completely agree with you. By "the first" I really just meant "any one". I've been using it many times in the last few days and it's been very nice not copy pasting a target name in there.

Glad to hear it's been working out for you. From re-reading https://github.com/ropensci/drake/issues/534#issuecomment-428025183, I realize I was not clear in https://github.com/ropensci/drake/issues/534#issuecomment-428024100. If multiple targets fail, drake does just take the first element of failed().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rsangole picture rsangole  路  3Comments

boshek picture boshek  路  6Comments

htlin picture htlin  路  4Comments

wlandau picture wlandau  路  8Comments

maelle picture maelle  路  8Comments