Closed Bug 1116601 Opened 11 years ago Closed 11 years ago

Too difficult to determine what option_collection_hash values mean

Categories

(Tree Management :: Treeherder: API, defect, P4)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wlach, Assigned: wlach)

Details

Attachments

(3 files)

So each performance signature currently contains something called an "option_collection_hash", from which you should be able to determine whether that signature corresponds to opt, debug, asan, or pgo builds. The procedure for finding out what the values mean are: 1. Hit the https://treeherder.mozilla.org/api/optioncollection/ endpoint to get the possible hash values. Current output: [ { "id": 3, "option": 3, "option_collection_hash": "03abd064e50ec12b8c7309950268531d78c63f60" }, { "id": 1, "option": 1, "option_collection_hash": "102210fe594ee9b33d82058545b1ed14f4c8206e" }, { "id": 4, "option": 2, "option_collection_hash": "32faaecac742100f7753f0c1d0aa0add01b4046b" }, { "id": 2, "option": 4, "option_collection_hash": "f69e1b00908837bf0550250abb1645014317e8ec" } ] 2. One-by-one, look up the option id values via this endpoint: https://treeherder.mozilla.org/api/option/<option id>/ Example output for https://treeherder.mozilla.org/api/option/3/ { "active_status": "active", "description": "fill me", "id": 3, "name": "asan" } -- This is pretty overly complicated, especially since there are only 4 possible values. Let's simplify things a little bit. It should be fairly inexpensive to produce an endpoint that gives this kind of output: { "03abd064e50ec12b8c7309950268531d78c63f60": [ { "active_status": "active", "description": "fill me", "name": "asan" } ], "102210fe594ee9b33d82058545b1ed14f4c8206e": [ { "active_status": "active", "description": "fill me", "name": "opt" } ] } That is to say, a dictionary where the keys are option_collection_hash, and the values are options associated with the hash. Yes, this involves multiple database queries but it should be pretty cheap since we only have 4 hashes with one option each associated with them. If the option collection hash ever gets bigger we can always memcache the return value here, but I suspect that won't be necessary anytime soon.
Component: Treeherder: Perfherder → Treeherder: API
We may consider using this to address this issue: http://drf-toolbox.readthedocs.org/en/latest/nested.html
Priority: -- → P2
Priority: P2 → P3
I noticed that option!=id : { "id": 4, "option": 2, "option_collection_hash": "32faaecac742100f7753f0c1d0aa0add01b4046b" }, { "id": 2, "option": 4, "option_collection_hash": "f69e1b00908837bf0550250abb1645014317e8ec" } When I call https://treeherder.mozilla.org/api/option/4/ I believe I am getting the former. But what is the "option" property? Is that in use?
(In reply to Kyle Lahnakoski [:ekyle] from comment #2) > I noticed that option!=id : > > { > "id": 4, > "option": 2, > "option_collection_hash": "32faaecac742100f7753f0c1d0aa0add01b4046b" > }, > { > "id": 2, > "option": 4, > "option_collection_hash": "f69e1b00908837bf0550250abb1645014317e8ec" > } > > When I call https://treeherder.mozilla.org/api/option/4/ I believe I am > getting the former. But what is the "option" property? Is that in use? Yes, this is quite confusing, I had to look at the source again to figure out the answer to your question. The "option" property refers to a key in the option table. So in fact you are getting the former, not the latter in your example. The "id" in each element returned by `https://treeherder.mozilla.org/api/optioncollection/` is just the primary integer key in the option collection table. It doesn't refer to anything and isn't used anywhere.
Oh dear, now I am more confused! For clarity, what is the name of the option with the hash "32faaecac742100f7753f0c1d0aa0add01b4046b"? Thanks!
Flags: needinfo?(wlachance)
(In reply to Kyle Lahnakoski [:ekyle] from comment #4) > Oh dear, now I am more confused! > > For clarity, what is the name of the option with the hash > "32faaecac742100f7753f0c1d0aa0add01b4046b"? > > Thanks! That would be option 2 (as listed), aka "debug": https://treeherder.mozilla.org/api/option/2/
Flags: needinfo?(wlachance)
I think we genuinely need to fix this, it seems to be confusing people quite a bit. I'll take it.
Assignee: nobody → wlachance
The root cause of such a confusion is probably the (not ideal) design of that part of the schema. At the moment it's something like +--------+ +-----------------------+ |option | |option_collection | |--------+ +-----------------------+ | id | | id | | name | | option_id | +--------+ | option_collection_hash| +-----------------------+ with a unique(option_id,option_collection_hash) constraint There's a 1-N relationship between option and option_collection Further normalizing option_collection, we obtain a N-N relationship, let's call it option_collection_option +--------+ +-----------------------+ +-------------------------+ |option | |option_collection | |option_collection_option | |--------+ +-----------------------+ +-------------------------+ | id | | option_collection_hash| | option_collection_id | | name | +-----------------------+ | option_id | +--------+ +-------------------------+ So now we have a N-N relationship between a collection and its options. option_collection_hash is now primary key of option collection and there's a unique(option_collection_id, option_id) constraint on option_collection_option. :wlach what do you think about this?
(In reply to Mauro Doglio [:mdoglio] from comment #7) > Further normalizing option_collection, we obtain a N-N relationship, let's > call it option_collection_option > > +--------+ +-----------------------+ +-------------------------+ > |option | |option_collection | |option_collection_option | > |--------+ +-----------------------+ +-------------------------+ > | id | | option_collection_hash| | option_collection_id | > | name | +-----------------------+ | option_id | > +--------+ +-------------------------+ > So now we have a N-N relationship between a collection and its options. > option_collection_hash is now primary key of option collection and there's a > unique(option_collection_id, option_id) constraint on > option_collection_option. > > :wlach what do you think about this? Yes, this makes sense to me. However I don't think we strictly need to do this in order to fix this bug?
This new API returns results like this: { "03abd064e50ec12b8c7309950268531d78c63f60": { "options": [ { "name": "asan" } ] }, "102210fe594ee9b33d82058545b1ed14f4c8206e": { "options": [ { "name": "opt" } ] }, "32faaecac742100f7753f0c1d0aa0add01b4046b": { "options": [ { "name": "debug" } ] } } (I could have just included the names since only those are really unique/interesting at this point, but decided to keep things open in the interests of future extensibility)
Attachment #8558166 - Flags: review?(mdoglio)
For consistency with the other endpoints, it would be nice if this list method returned a list of objects: [ { "option_collection_hash": "03abd064e50ec12b8c7309950268531d78c63f60", "options": [ {"name": "asan"} ] }, { "option_collection_hash": "102210fe594ee9b33d82058545b1ed14f4c8206e", "options": [ {"name": "opt"} ] }, { "option_collection_hash": "32faaecac742100f7753f0c1d0aa0add01b4046b", "options": [ {"name": "debug"} ] } ] I also find this structure to be more explicit, which is good for a (still) undocumented api :-)
Is it possible to have the service perform the option_collection_hash lookup and return a list of named options instead of returning an option_collection_hash? This would be clearer to the service consumers, and save them from performing (?inevitable?) joins on the client side.
(In reply to Kyle Lahnakoski [:ekyle] from comment #11) > Is it possible to have the service perform the option_collection_hash lookup > and return a list of named options instead of returning an > option_collection_hash? This would be clearer to the service consumers, and > save them from performing (?inevitable?) joins on the client side. I'm not sure what you mean, both my original implementation and Mauro's suggested modifications to the option collection hash endpoint do exactly this as far as I can tell? There should be no reason to do a "join" on the client side after this goes in: all the relevant data will be returned by the server in an easy-to-digest form. Let me know if I'm missing something...
Sorry, I did not mean to be specific, I meant in general: For example, [1] exposes an option_collection_hash. Instead I suggest replacing that key/value with the options list it really represents. I do not know where else hash is exposed, but I suggest it be replaced there also. Even more generally, I suggest hashes and keys referencing the dimension tables (the arms in a star/snowflake schema) be automatically expanded by the web service to their full form. This will make the response clearer, reduce the join logic on the client side, and reduce the number of calls required to gather this meta-data. [1] https://treeherder.mozilla.org/api/project/mozilla-inbound/performance_artifact/?id__gte=4000000&id__lte=4000000&count=1
(In reply to Kyle Lahnakoski [:ekyle] from comment #13) > Sorry, I did not mean to be specific, I meant in general: > > For example, [1] exposes an option_collection_hash. Instead I suggest > replacing that key/value with the options list it really represents. I do > not know where else hash is exposed, but I suggest it be replaced there > also. > > Even more generally, I suggest hashes and keys referencing the dimension > tables (the arms in a star/snowflake schema) be automatically expanded by > the web service to their full form. This will make the response clearer, > reduce the join logic on the client side, and reduce the number of calls > required to gather this meta-data. > > [1] > https://treeherder.mozilla.org/api/project/mozilla-inbound/ > performance_artifact/?id__gte=4000000&id__lte=4000000&count=1 Ah, I see. Yes, I generally agree with you there. Feel free to file a follow-up bug re: the performance artifacts if you like.
(In reply to Mauro Doglio [:mdoglio] from comment #10) > For consistency with the other endpoints, it would be nice if this list > method returned a list of objects: > ... > > I also find this structure to be more explicit, which is good for a (still) > undocumented api :-) I updated the API as such. I also rejiggered things so that this api is an addition to what we already have, rather than a replacement. This will ensure that existing consumers of the old API (i.e. Kyle) won't have their code suddenly break on them. Once they've had a chance to move over, we can remove the old /optioncollection and /option endpoints.
Attachment #8558166 - Flags: review?(mdoglio) → review+
Priority: P3 → P4
(In reply to William Lachance (:wlach) from comment #15) > I updated the API as such. I also rejiggered things so that this api is an > addition to what we already have, rather than a replacement. This will > ensure that existing consumers of the old API (i.e. Kyle) won't have their > code suddenly break on them. Once they've had a chance to move over, we can > remove the old /optioncollection and /option endpoints. Kyle could you let us know when we're good to remove the old endpoint? :-)
Flags: needinfo?(klahnakoski)
Status: NEW → ASSIGNED
OS: Linux → All
Hardware: x86_64 → All
Please remove it. Technically my code uses this endpoint, but it is not running right now, and will be easy to replace when I get back to dzAlerts code. When I do move dzAlerts it will be easier for me to identify a disabled endpoint than determining which (working) endpoint to use. Thanks
Flags: needinfo?(klahnakoski)
Great, thank you :-) Will, are you ok doing that in this bug, or would you like me to file another?
Yeah, sorry, I meant to follow up with Kyle myself. Thanks for getting to this before me. :) I'll remove the endpoints as part of this bug.
Np; I was just going through bugs that had bot commit comments but were still open, to see if there were some easy wins for reducing bug count :-)
Attachment #8572116 - Flags: review?(emorley)
Comment on attachment 8572116 [details] [review] Remove obsolete option, optioncollection APIs ty :-)
Attachment #8572116 - Flags: review?(emorley) → review+
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Looks like the sheriffing panel used the old API. Oops. We can simplify the code with the new stuff though, so hooray for that.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Update UI frontend to use optioncollectionhash api's instead of deprecated option, optioncollection apis Tested locally with a copy hacked up to use the sherriff panel, seems to work ok. :)
Attachment #8573516 - Flags: review?(emorley)
Attachment #8573516 - Flags: review?(emorley) → review+
Patch was applied and this is really fixed now.
Status: REOPENED → RESOLVED
Closed: 11 years ago11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: