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

When timing metadata changes, ensure metadata.changed fires #7576

Merged
merged 4 commits into from Dec 4, 2019

Conversation

mlucool
Copy link
Contributor

@mlucool mlucool commented Dec 2, 2019

This bug was caused by updating the object in place instead of copying before each change. With the former, metadata.changed does not signal.

This bug was caused by updating the object in place instead of
copying before each change. With the former, metadata.changed does
not signal.
@jupyterlab-dev-mode
Copy link

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

@jasongrout jasongrout added this to the 2.0 milestone Dec 3, 2019
@mlucool
Copy link
Contributor Author

mlucool commented Dec 3, 2019

Added a second commit on top which fixes another bug related to this. If we clear execution count, this implies the metadata should be removed. This fixes a bug where "Clear All Outputs" was not clearing timing data.

I considered adding a second function to ICodeModel (e.g. clearOutputs), but it seems cleaner to assume that setting an execution count to 0/null means there is no execution metadata.

@saulshanabrook
Copy link
Member

Looks good, these both work locally for me.

If we clear execution count, this implies the metadata should be removed. This fixes a bug where "Clear All Outputs" was not clearing timing data.

I changed it to just reset it in that command, instead of whenever you are setting execution count, just to be a bit more safe about when we are resetting it. What do you think?

@mlucool
Copy link
Contributor Author

mlucool commented Dec 4, 2019

I changed it to just reset it in that command, instead of whenever you are setting execution count, just to be a bit more safe about when we are resetting it. What do you think?

I coupled them as it seemed logical to clear this metadata when the execution count was cleared. My hope was this would prevent more bugs than it causes. I'll also note, I believe the timing stays until we hear back from the kernel.

For example, in the cell widget, I think we'd want to clear the metadata here as we set executionCount to null. I found a few such places in the code. Your commit fixes clearOutputs, but not clearAllOutputs is an example of how the bug creeps up too.

@saulshanabrook
Copy link
Member

saulshanabrook commented Dec 4, 2019

For example, in the cell widget, I think we'd want to clear the metadata here as we set executionCount to null. I found a few such places in the code. Your commit fixes clearOutputs, but not clearAllOutputs is an example of how the bug creeps up too.

Ah, that makes sense. I was reluctant to include clearing output timings on settings this attribute. Instead it might be better to have a method that you call that resets both of them, which we use in those places. I can try this out to see how it looks.

@mlucool
Copy link
Contributor Author

mlucool commented Dec 4, 2019

I can make that change. I'll add clearExecution() to ICodeCellModel?

@saulshanabrook
Copy link
Member

@mlucool OK cool. Yeah that sounds good, maybe does something like:

    this.outputs.clear();
    this.executionCount = null;
    this.metadata.delete('execution');

?

@mlucool
Copy link
Contributor Author

mlucool commented Dec 4, 2019

If you want to include outputs.clear(), it may not be exactly the same. Here for example, this is not coupled. I am not sure if they should have been and this is a bug or just a noop.

@mlucool
Copy link
Contributor Author

mlucool commented Dec 4, 2019

@saulshanabrook
Copy link
Member

Yeah this looks good to me. It changes some behavior, but it still seems to work locally for me and I am not sure if the old behavior was important. All tests also pass, so I am good with this.

@saulshanabrook saulshanabrook merged commit a445a8c into jupyterlab:master Dec 4, 2019
@mlucool
Copy link
Contributor Author

mlucool commented Dec 4, 2019

Can this be pulled into to 1.x as well?

@jasongrout
Copy link
Contributor

We aren't planning on releasing another 1.x minor release.

@mlucool mlucool deleted the timing-metadata-fix branch December 6, 2019 21:48
@lock lock bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Jan 6, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants