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

[WIP] TASK-1270, TASK-1271 Update Output cell mechanism #1214

Merged
merged 30 commits into from
Apr 4, 2018

Conversation

briehl
Copy link
Member

@briehl briehl commented Nov 18, 2017

The first stage here is to update the output/viewer cells for some consistency. Before merging, these cells should (see checklist below):

(see here for some details on requirements, etc.: https://docs.google.com/document/d/1Ie7qb8rEvnxXi_jrgYu2TIWmhNIuHjqaYA4J3AFCof8/edit )

Note that this work might get separated into multiple PRs, I'm just making a checklist here of the broad strokes.

  • Have code that calls to biokbase.narrative.widgetmanager to make the viewer.
  • Update WidgetManager.show_data_cell to just generate a kbaseNarrativeOutputCell with the directly requested viewer widget, NOT a kbaseNarrativeDataCell widget.
  • Tests for above.
  • Include an UPA field in all generated JS code.
  • Cleanup functional (but sloppy) WidgetManager.infer_upas function.
  • kbaseNarrativeOutputCell should serialize/deserialize UPAs automatically before running the viewer.

These will be worked on in another PR.

  • Include an auto-updater for older widgets (or maybe just flag those cells to be executed again if the Narrative was last saved before some date).
  • Every last freaking viewer needs to be updated to take one (or more) UPAs as input. That'll be later.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0008%) to 12.454% when pulling 24486c8 on briehl:copy-sharing-problem into 9e21318 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+4.6%) to 12.478% when pulling 53579ce on briehl:copy-sharing-problem into ff03122 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+4.7%) to 12.548% when pulling fa459d3 on briehl:copy-sharing-problem into ff03122 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-4.6%) to 7.899% when pulling b83459f on briehl:copy-sharing-problem into ad74fc5 on kbase:develop.

@briehl briehl changed the title [WIP] Update Output cell mechanism [WIP] TASK-1270, TASK-1271 Update Output cell mechanism Nov 29, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 12.547% when pulling e00a945 on briehl:copy-sharing-problem into ad74fc5 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 12.642% when pulling 9402012 on briehl:copy-sharing-problem into ad74fc5 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 12.652% when pulling 11f25f5 on briehl:copy-sharing-problem into ad74fc5 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 12.655% when pulling 209397d on briehl:copy-sharing-problem into ad74fc5 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 12.663% when pulling 5069e69 on briehl:copy-sharing-problem into ad74fc5 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 12.664% when pulling c85cfa5 on briehl:copy-sharing-problem into ad74fc5 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 12.66% when pulling 5b93ddb on briehl:copy-sharing-problem into ad74fc5 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 12.646% when pulling 4f336ca on briehl:copy-sharing-problem into ad74fc5 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 12.643% when pulling 51c0ff5 on briehl:copy-sharing-problem into ad74fc5 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 12.871% when pulling 8e95d84 on briehl:copy-sharing-problem into 2935f95 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 12.869% when pulling 3d8212d on briehl:copy-sharing-problem into d15c17a on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 12.878% when pulling fd4bda4 on briehl:copy-sharing-problem into d15c17a on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 12.928% when pulling 810f733 on briehl:copy-sharing-problem into d15c17a on kbase:develop.

@briehl
Copy link
Member Author

briehl commented Jan 4, 2018

Okay, some other work crept in here, but here's the main list of architectural changes. I think all the creep is below, too. The core target - update the viewer cell instantiation mechanism while leaving it backward-compatible - is still the same.

  1. Update backend calls that create viewer widgets to only make kbaseNarrativeOutputCells. (e.g. remove the kbaseNarrativeViewer or kbaseNarrativeDataCell constructs that just wrapped around kbaseNarrativeOutputCell).
  2. Update backend calls to automatically do all the mapping from an object type -> viewer widget and the parameters for it (deprecates kbaseNarrativeDataCell and narrativeViewers JS modules). This means adding a mapping for all current widgets so we know the semantics of each parameter (see src/widget_param_mapping.json). Hopefully, future widgets will just have an UPA field.
  3. Change kbaseNarrativeOutputCell to serialize/deserialize UPAs that are passed in to it.
  4. Change kbaseNarrativeOutputCell to automatically inject all UPAs into the viewer widget it wraps.
  5. (as a test) update kbaseRNASeqPieNew.js to handle upas as input. (the rest will come later)
  6. A bunch of tests for the above.

extra feature creep

  1. Adds the first pass at a general information header for all data cells. From here, the user can toggle which version of the object is being seen. This gets serialized as part of the UPA, so it should be restored on page load.
  2. Remove the (essentially redundant) bootstrapAlert module. Adds a 'alertOnly' option to bootstrapDialog - set that option to be true gives the same functionality as the other module.
  3. A bunch of code cleanup from seemingly random places - remove commented out code, boilerplate comments, x'd out css classes, etc.
  4. There was a piece of rarely used code in the backend that would try to parse user ids from the current auth token. It does the right thing now.
  5. Fell down a rabbit hole of adding a number of other tests to modules with holes in them.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 12.929% when pulling 993d0c4 on briehl:copy-sharing-problem into d15c17a on kbase:develop.

serialArr.push(serialize(upa));
});
return serialArr;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never remember what's available...do we have map in our environment? If so, this could just be:

return upas.map( function(upa) { return serialize(upa) } );

Not actually necessary to fix, just a little prettier. Even better when we could have

return upas.map( upa => serialize(upa) )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, map's available. Not sure why I never think of it. I'll switch that out.

serialSt[key] = serializeAll(upas[key]);
});
return serialSt;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above, could be:
return upas.reduce( function(acc, key) { acc[key] = serializeAll(upas[key]); return acc }, {} );

...but doesn't need to be.

Object.keys(upas).forEach(function(key) {
deserialSt[key] = deserializeAll(upas[key]);
});
return deserialSt;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same commentary on 145...156 - could be a map and a reduce, but not urgent. It's such a big pull I feel obligated to add notes. :-)

// handle where options.widget == null.
options.widget = options.widget || this.options.widget;
// handle where options.widget == 'null' string. I know. It happens.
options.widget = options.widget === 'null' ? this.options.widget : options.widget;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before coming to CSHL, I worked at Edison Schools and we imported school data from their SIS systems into our servers every night. One night, it broke at a school. I dug into it. Turns out they had a new kid whose name was "Brandon Null", and our importer failed because it said that his last name was a required field.

So our CSR called up the school and said he was missing his last name. They replied, "What are you talking about? His name is Brandon Null. That didn't go through? Why not?" Poor kid. He's gonna have all sorts of problems in life.

The quick fix was when I realized that the importer only failed on insert, not update - so I just change his name to "Brandon NotNull", imported it, and then went into the database to manually change back to "Brandon Null". After that, his record would update without issue.

We never encountered that specific bug again during my tenure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! Well, all over the place in various app specs, there's the JSON value null mixed in with the string "null".

Makes for some fun trickiness there, too.

Copy link
Contributor

@thomasoniii thomasoniii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the famous words of Donald Knuth, beware of bugs in the above code; I have only proved it correct, not tried it.

i.e., so far I've just read through it for syntactic/logic things and not tried executing anything. I contributed a couple of minor syntax suggestions (which can be ignored) and an anecdote. But otherwise it looks fine to me, keeping in mind that I've just eyeballed it atm.

@coveralls
Copy link

coveralls commented Jan 9, 2018

Coverage Status

Coverage increased (+0.5%) to 13.227% when pulling 18fda1f on briehl:copy-sharing-problem into e13f72c on kbase:develop.

@briehl
Copy link
Member Author

briehl commented Jan 9, 2018

This is great so far. Thanks for the feedback! Added the suggestions (and twiddled some tests around, too). I keep forgetting that reduce is just built in to Javascript...

@briehl
Copy link
Member Author

briehl commented Mar 23, 2018

Ok, after some conversation, I think this'll get frozen for now and merged next week, after staging up a new release.

@thomasoniii thomasoniii merged commit 3b4ea0e into kbase:develop Apr 4, 2018
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.

None yet

3 participants