-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: replace rawValue with numericValue in audit result #8385
Conversation
// Drop raw values. https://github.com/GoogleChrome/lighthouse/issues/6199 | ||
if (!keepRawValues && 'rawValue' in audit) { | ||
delete audit.rawValue; | ||
// Drop numeric values until we decide what to do with the optional type in proto. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
punting on the question of DoubleValue
/Value
/whatever in proto by maintaining the deleting by default behavior of rawValue
. We can change it to whatever later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is going to have to be Value
but this is something that we can punt 🏈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(replying to this thread)
On the other hand.. this seems a great time to not punt on the proto typing for this prop. :) All our PSI API users currently don't get rawValue because we're punting and thus have to parse strings like "3,241ms" in order to get some metric values.
.numericValue
being typed as the mega-generic proto Value
seems real bad.
What are the challenges to typing .numericValue
as DoubleValue
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I misunderstood but we are punting on adding the property at all to the proto right, not proposing to start with it as Value
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaik DoubleValue doesn't support a difference between 'null' or 'undefined' and '0' since it is the default. I can do some more testing around that, but thats the crux. BUT if we don't care about undefined = 0, then we can for sure use a more typical and better proto type!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hold up - DoubleValue is nullable. double
and float
are the ones that can't distinguish between 0 and not provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I misunderstood but we are punting on adding the property at all to the proto right, not proposing to start with it as Value?
yeah, that's what I was proposing, not changing the status quo on proto, but we can do this for real
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@exterkamp and I just tested a few possibilities and, yeah, DoubleValue
will work well for us. 0
comes through, and then any audit with it not set will come back with no numericValue
in JSON, which works just fine for us.
delete audit.rawValue; | ||
// Drop numeric values until we decide what to do with the optional type in proto. | ||
// https://github.com/GoogleChrome/lighthouse/issues/6199 | ||
if (!keepRawValues && 'numericValue' in audit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how flexible we are in changing the keepRawValues
parameter name in the lr entry point, but happy to rename if it's not a big deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can def change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can def change it.
do you want me to change it now and LR will just have to remember to update on the next roll?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, if we are happy with numericValue now shouldn't we just always include it. remove the option entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, if we are happy with numericValue now shouldn't we just always include it. remove the option entirely.
removed :)
@@ -347,7 +347,6 @@ describe('Manifest Parser', function() { | |||
const display = parsedManifest.value.display; | |||
assert.ok(!display.warning); | |||
assert.equal(display.value, 'browser'); | |||
assert.equal(display.rawValue, undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this made no sense, not a thing
I'm a little unclear on what the purpose of this PR is, are we planning on exposing an audit-level property called If we are, then I think I was confused about what killing If we aren't and this is all temporary, then I have absolutely no preference on the name so merge away 😆 |
That's what's this PR does but it's not necessarily the plan :) I don't think we ever actually settled on a plan, so this is bikeshedding on property name and object structure. Fun for everyone! I'll try to make a better case tomorrow, but basically I think a large portion of our programmatic users just need something like this, a single numeric value that's a companion to the score, and don't want (or need) to dig into details to do it. They're also not all ms numbers, so it's hard to name the value. I also realize that this doesn't really differentiate the property from |
(I am curious how many of these remaining rawValues are actually already covered by things in their |
👬 Strong upvote from me on that @brendankenny |
This is the concept. While I've been trying to analyze variance this has come up a lot. RawValue is not suitable since it is non-numeric and has a lot of legacy baggage. So we wanted a numeric only value that could be used for analysis. e.g. TTFB score: 0.7, numericValue: 1159 (1159ms) | DOM size score: 0.9, numericValue: 14 (14 nodes). |
// Drop raw values. https://github.com/GoogleChrome/lighthouse/issues/6199 | ||
if (!keepRawValues && 'rawValue' in audit) { | ||
delete audit.rawValue; | ||
// Drop numeric values until we decide what to do with the optional type in proto. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is going to have to be Value
but this is something that we can punt 🏈
As one of those programmatic users I also strongly upvote this :) SGTM! |
// Drop raw values. https://github.com/GoogleChrome/lighthouse/issues/6199 | ||
if (!keepRawValues && 'rawValue' in audit) { | ||
delete audit.rawValue; | ||
// Drop numeric values until we decide what to do with the optional type in proto. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(replying to this thread)
On the other hand.. this seems a great time to not punt on the proto typing for this prop. :) All our PSI API users currently don't get rawValue because we're punting and thus have to parse strings like "3,241ms" in order to get some metric values.
.numericValue
being typed as the mega-generic proto Value
seems real bad.
What are the challenges to typing .numericValue
as DoubleValue
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numericValue
as a name has my 🙏 👍
should be minimal effort to migrate too :D
@@ -35,7 +35,7 @@ describe('ReportScoring', () => { | |||
describe('#scoreAllCategories', () => { | |||
it('should score the categories', () => { | |||
const resultsByAuditId = { | |||
'my-audit': {rawValue: 'you passed', score: 0}, | |||
'my-audit': {score: 0}, | |||
'my-boolean-audit': {score: 1, extendedInfo: {}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
man, never thought I'd see the day where extendedInfo outlives rawValue 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
man, never thought I'd see the day where extendedInfo outlives rawValue 😆
hahaha, maybe it's time to do the final purge on that
part 2 of apparently 3 for #6199
Following #8343, this now renames the public
rawValue
onLH.Audit.Result
tonumericValue
. We have very few places we rely on this except the smoke tests, so it's an easy change and a better place to bikeshed onnumericValue
and the public interface than the next PR :)The last PR will be renaming the variable internal to audits/audit tests.