-
Notifications
You must be signed in to change notification settings - Fork 19
Add concept of block events and some design notes #1059
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1059 +/- ##
==========================================
+ Coverage 71.30% 71.46% +0.16%
==========================================
Files 63 63
Lines 4144 4213 +69
==========================================
+ Hits 2955 3011 +56
- Misses 1189 1202 +13
🚀 New features to boost your workflow:
|
datalab
|
Project |
datalab
|
Branch Review |
ml-evs/blocks
|
Run status |
|
Run duration | 05m 34s |
Commit |
|
Committer | Matthew Evans |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
3
|
|
0
|
|
0
|
|
0
|
|
144
|
View all changes introduced in this branch ↗︎ |
Tests for review
cypress/e2e/editPage.cy.js • 1 failed test • End-to-end tests (chrome)
Test | Artifacts | |
---|---|---|
Edit Page > Uploads an XRD file, makes an XRD block and checks that the plot works |
Test Replay
Screenshots
|
cypress/e2e/editPage.cy.js • 1 failed test • End-to-end tests (firefox)
Test | Artifacts | |
---|---|---|
Edit Page > Uploads an XRD file, makes an XRD block and checks that the plot works |
Screenshots
|
cypress/e2e/editPage.cy.js • 1 failed test • End-to-end tests (electron)
Test | Artifacts | |
---|---|---|
Edit Page > Uploads an XRD file, makes an XRD block and checks that the plot works |
Test Replay
Screenshots
|
2f892ca
to
f765a97
Compare
Just pinging @BenjaminCharmes and @jdbocarsly for review on this one! |
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.
LGTM 🚀 very promising!
XRD Block works perfectly fine.
@@ -27,9 +27,19 @@ class XRDBlock(DataBlock): | |||
def plot_functions(self): | |||
return (self.generate_xrd_plot,) | |||
|
|||
@classmethod | |||
@event | |||
def set_wavelength(self, wavelength: float | None): |
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.
Can you show how this gets implemented in the XRD block before we merge? That would be a good way to test that everything is working on the front end
@@ -207,6 +207,10 @@ export default { | |||
this.contentMaxHeight = "none"; | |||
} | |||
}); | |||
document.addEventListener("bokehStateUpdate", this.handleBokehEvent); |
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.
If this adds a listener to the overall document, will we have multiple listeners if we have multiple blocks on a page? This could cause the handler to be called multiple times
you should be able to add this listener to a only the relevant node by assigning the outer div ref="thisBlock", then only add the listener to:
this.$refs.thisBlock.addEventListener("bokehStateUpdate", this.handleBokehEvent);
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.
Still struggling a lot with this... following the approach with $refs, it seems that the block events bubble up to the block-list-item
defined in the EditPage
and skip the DatablockBase
.
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.
Perhaps the easiest resolution is adding a ref
to the DataBlockBase
and then directly calling:
<template>
<DataBlockBase :item_id="item_id" :block_id="block_id" ref="xrdBlockBase">
</template>
...
this.$refs.xrdBlockBase.handleBokehEvent(event);
Made some fixes post-discussion with @jdbocarsly. Known limitations still:
|
f7fc272
to
34c71dd
Compare
This PR adds the concept of "events" that can be registered on block types; essentially, server-side functions that can be triggered separately from parsing/ingestion for things like setting parameters. It also introduces the handling of particular events raised by Bokeh plots in the base data block in Vue.
This is all described in a new design document for this current version of datablocks, also committed in this PR.
I think eventually we can add several lifecycle hooks to the base block for handling certain things (remake block from scratch etc) that can be reused by derived block types, though I haven't put any effort into doing this now. I'm already using this functionality in a custom block that sets some parameters based on user feedback that requires reanalysing all block data (essentially a slider setting some offset time parameter).
For review, I recommend reading the design doc in the rtd preview at https://the-datalab--1059.org.readthedocs.build/en/1059/design/blocks/.
There's still a few open questions about how errors in events should be handled, and what methods should be triggered afterwards (mostly due to the fact we always call the
to_web()
block method in the update-block route.