-
Notifications
You must be signed in to change notification settings - Fork 153
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
Avoid double messaging on subset creation #2515
base: main
Are you sure you want to change the base?
Conversation
… followed by an update message, instead just broadcast a create subset message with the correct subset state
f96f365
to
7608a6c
Compare
@dhomeier - would you like to review this? I've had confirmation from the jdaviz side that it works for them. |
Actually, maybe hold off on merging - I think we might need a small PR in Jdaviz, I'm seeing spectral extraction fail to extract when a spatial subset is created. Hopefully a quick fix on our end. |
But nothing needed on this side, is that right? |
I'm pretty sure that's correct, still investigating the fix on our end. |
@astrofrog It seems like at the point we get the
with the error
It seems like this is a timing conflict, would it be possible to send the |
The setter is already calling |
assert isinstance(message.subset.subset_state, InequalitySubsetState) | ||
assert message.subset.subset_state.left is data.id['x'] | ||
assert message.subset.subset_state.operator is operator.ge | ||
assert message.subset.subset_state.right == 3 |
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.
assert message.subset.subset_state.right == 3 | |
assert message.subset.subset_state.right == 3 | |
def test_broadcast_to_collection(): | |
"""A data collection input works on each data component""" | |
handler = MagicMock() | |
app = Application() | |
class Listener(HubListener): | |
pass | |
listener = Listener() | |
app.session.hub.subscribe(listener, SubsetCreateMessage, handler=handler) | |
app.session.hub.subscribe(listener, SubsetUpdateMessage, handler=handler) | |
data = Data(x=[1, 2, 3, 4, 5]) | |
data2 = Data(x=[2, 3, 4, 5, 6]) | |
app.data_collection.append(data) | |
app.data_collection.append(data2) | |
cmd = ApplySubsetState(data_collection=app.data_collection, | |
subset_state=data.id['x'] >= 3, | |
override_mode=ReplaceMode) | |
app.session.command_stack.do(cmd) | |
assert len(data2.subsets) == 1 | |
assert data2.subsets[0].label == 'Subset 1' | |
# fails with `IncompatibleAttribute` exception | |
# assert data2.get_subset_object(subset_id='Subset 1', cls=NDDataArray) | |
assert handler.call_count == 2 | |
assert data2.subsets[0].subset_state.left is data.id['x'] | |
assert data2.subsets[0].subset_state.operator is operator.ge | |
assert data2.subsets[0].subset_state.right == 3 |
basic test to check that subset is broadcast to a second component in the dataset.
Avoid broadcasting a create subset message with an empty subset state followed by an update message, instead just broadcast a create subset message with the correct subset state