Skip to content
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

Merged
merged 2 commits into from
Apr 19, 2019
Merged

Conversation

brendankenny
Copy link
Member

part 2 of apparently 3 for #6199

Following #8343, this now renames the public rawValue on LH.Audit.Result to numericValue. 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 on numericValue and the public interface than the next PR :)

The last PR will be renaming the variable internal to audits/audit tests.

// 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.
Copy link
Member Author

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.

Copy link
Member

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 🏈

Copy link
Member

@paulirish paulirish Apr 18, 2019

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?

Copy link
Collaborator

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?

Copy link
Member

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!

Copy link
Collaborator

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.

Copy link
Member Author

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

Copy link
Member Author

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) {
Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Collaborator

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.

Copy link
Member Author

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);
Copy link
Member Author

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

@patrickhulce
Copy link
Collaborator

patrickhulce commented Apr 18, 2019

I'm a little unclear on what the purpose of this PR is, are we planning on exposing an audit-level property called numericValue/whatever we decide on that has the numbers here and not the details.timingMs route or whatever?

If we are, then I think I was confused about what killing rawValue meant since this doesn't seem fundamentally different :)

If we aren't and this is all temporary, then I have absolutely no preference on the name so merge away 😆

@brendankenny
Copy link
Member Author

are we planning on exposing an audit-level property called numericValue/whatever we decide on that has the numbers here and not the details.timingMs route or whatever?

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 rawValue except for the (already removed) primacy and booleaness of the property in the audit product :)

@brendankenny
Copy link
Member Author

(I am curious how many of these remaining rawValues are actually already covered by things in their details...)

@benschwarz
Copy link
Contributor

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.

👬 Strong upvote from me on that @brendankenny

@exterkamp
Copy link
Member

a single numeric value that's a companion to the score

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.
Copy link
Member

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 🏈

@patrickhulce
Copy link
Collaborator

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.

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.
Copy link
Member

@paulirish paulirish Apr 18, 2019

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?

Copy link
Collaborator

@patrickhulce patrickhulce left a 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: {}},
Copy link
Collaborator

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 😆

Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants