Closed kyleam closed 2 years ago
Rebased to resolve conflicts in stories/reqs.
@kyleam I'll try to take a look at this tomorrow. Is there an associated bbr
PR?
@kyleam I'll try to take a look at this tomorrow. Is there an associated bbr PR?
Yes, it's incoming. (Was holding off on requesting your review until then.)
I said:
Yes, it's incoming. (Was holding off on requesting your review until then.)
Just posted to https://github.com/metrumresearchgroup/bbr/pull/527 (though I see the ci is already red, so I might need to look into that)
Alright, this might be controversial and maybe we want to fix it in a different PR (and then maybe rebase this one?) but I've stumbled onto something unfortunate: bbi nonmem summary
still panics in some situations, specifically when given an incomplete .lst
file that it can't parse.
Easy to reproduce from the terminal with the test models like so:
cd integration/testdata/bbi_summary/
mkdir acop_incomplete
head -n 50 acop/acop.lst > acop_incomplete/acop_incomplete.lst
bbi nonmem summary acop_incomplete/acop_incomplete.lst
I get the same error with bbi v3.1.1
and bbi v3.2.0-alpha.3
, regardless of whether I pass --json
.
I also get (almost?) the same error when passing multiple models through:
bbi nonmem summary acop/acop.lst acop_incomplete/acop_incomplete.lst --json
I think it's worth fixing this and, more to the point, I think it's worth taking the time to make our best effort to ensure that bbi nonmem summary --json
always returns well-formed JSON, with a possible error message captured in the error_msg
element.
Benefits:
bbr
(and better UX, in terms of error messages that bbr
passes through). bbr::model_summaries()
will always parse all the models, even when some of them error.--json
behaviorI haven't thought as hard about bbi nonmem summary
(i.e. without --json
) because that is rarely used (and never used by bbr
). I think, in doing this ^ we'll probably land on better behavior for that too. Whatever it ends up being, it's likely better than having Go vomit those panic
errors ^ at you.
@seth127
bbi nonmem summary still panics in some situations, specifically when given an incomplete .lst file that it can't parse.
Oof, I was considering these parsing bugs/oversights within GetModelOutput
a separate issue, but you're right, that needs to be considered here because we're removing the tryCatch
handling from bbr's side.
I still need to digest your comments (here and on the bbr side), but here's my current proposal:
1) we catch panics in summarizeModel
and convert them to errors (see patch below). I know catching panics in go isn't a good look, but I think breaking from best practices here makes sense. As you say, we really want to get structured JSON output to bbr, and we have little confidence that GetModelOutput
(in its current state) won't panic when it receives unexpected input, bringing the entire call down with one bad model.
2) when we find a GetModelOutput
panic, we fix it so that at least an error is returned (i.e. we don't rely on the panic catch from the previous step). Ideally at some point the panic catching will be an unnecessary safeguard.
I like that as a temporary fix. Should we dump the full panic message in the error_msg
string? It looks from your snippet above that we only pass through "GetModelOutput: runtime error: index out of range [-1]"
.
The end user wouldn't need to see any of that mess, I'm just thinking about how we would debug a something like that. Maybe I'm missing some nuance though.
The end user wouldn't need to see any of that mess, I'm just thinking about how we would debug a something like that.
My thinking is that, to actually address it, we'll need a reproducer anyway, at which point it's easy enough temporarily comment out the panic catch. I'll look at capturing the backtrace, though, if you prefer. Let me know.
If it's easy enough to pass through the backtrace I think that will make our job easier down the road (and probably make it more likely that a user would see it and think "oooh, this doesn't look good. Maybe I should reach out..."). But I wouldn't say it's worth too much effort, if it gets complicated. Like you say, we would have to dig in anyway by the time it got to us.
@seth127 I've pushed an update that 1) catches the GetModelOutput
failure, including the backtrace and 2) resolves the failures for reproducer. The second (7c0caa76c) involves the following assumption: "return an error if, outside of the ONLYSIM context, the parameter data length and estimation method length don't match, taking that as a sign that the lst parsing is incomplete". Does that sound valid to you?
I've confirmed that, as expected, this resolves this bbi build resolves the test failure for your https://github.com/metrumresearchgroup/bbr/pull/529
"return an error if, outside of the ONLYSIM context, the parameter data length and estimation method length don't match, taking that as a sign that the lst parsing is incomplete". Does that sound valid to you?
I support this. So sick of seeing panic: runtime error: index out of range [-1]
get passed through to bbr
and knowing it's secret code for "your model hasn't finished."
I just pushed an alpha.4
tag so that I could do some easier testing on https://github.com/metrumresearchgroup/bbr/pull/529 but I think this is looking great. Thanks for the quick patch.
This series is in response to gh-264. The main change is to embed the error information in the JSON records ("summary: improve error signaling for --json", 7th commit). An earlier commit adds a test for multiple models, so the changes to the golden files give a good overview of what's changing in the subsequent commits.
A couple of notes:
gh-264 included "Can take a directory and parse summary for all models in directory" as a requirement. That's not something currently supported by the
summary
command. Discussed with @seth127 offline, and it seems that was probably just a mix up withparams --dir
, and either way isn't something we plan to bundle with this change.params
andsummary
have very similar "multiple models" handling. Most of the changes here probably make sense to add there too, but it seems safe to hold off on that now and keep this focused onsummary
. bbr is going to need to remain compatible with the previous JSON record structure anyway fro compatibility with older bbi versions.I'm marking this as a draft mainly because
Close #264.