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

FIX: respect wait for clear_output #969

Merged
merged 3 commits into from
Mar 21, 2019

Conversation

maartenbreddels
Copy link
Collaborator

clear_output was not respecting wait. This caused, for instance, ipywidgets' interact not to work voila-dashboards/voila#85

The follow code:

print("Hello world")
clear_output(wait=True)  # no output after this

did not output 'Hello world'. This is fixed with this PR. More complicated scenarios are tested in the notebook.

@maartenbreddels maartenbreddels changed the title FIX: respect wait for clear_output WIP: FIX: respect wait for clear_output Mar 20, 2019
@MSeal
Copy link
Contributor

MSeal commented Mar 20, 2019

This looks like a nice fix ping me when the WIP aspect is done and I'll +1 to merge.

@maartenbreddels
Copy link
Collaborator Author

@MSeal thanks. I was done but thought I missed something. There are issues with voila, but I don't think they should be solved in nbconvert. I did refactored it a bit so it's easier to reuse the run_cell. It can rebase #900 when merged, that will also be clearer to implement.

The CI failure seems similar to other PR's, I'm assuming it is unrelated.

@maartenbreddels maartenbreddels changed the title WIP: FIX: respect wait for clear_output FIX: respect wait for clear_output Mar 21, 2019
@@ -440,6 +440,7 @@ def run_cell(self, cell, cell_index=0):
exec_reply = self._wait_for_reply(msg_id, cell)

outs = cell.outputs = []
self.clear_before_next_output = False
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check if this is True before exiting (if it were the final message) and clear just before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, if nothing is outputted, it should not clear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should be covered by the notebook btw.

Copy link
Contributor

Choose a reason for hiding this comment

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

I more meant if the final line of the final cell were clear_output(wait=True) wouldn't this not apply clear before exiting run_cell? I might be missing a behavioral aspect this morning before my coffee kicks in :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it would not clear, and it should not. One of the cells in the
notebook has this. Unless you found a scenario I did not test. (apparently, reply by email does not work well with threads).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok thanks, looks good to me them. I'll get to looking at your other PRs related to widgets this next week (been super busy)

if cell_index in cell_map:
cell_map[cell_index] = []

def handle_comm_msg(self, outs, msg, cell_index):
Copy link
Contributor

Choose a reason for hiding this comment

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

good idea for extensions to overwrite :)

@maartenbreddels
Copy link
Collaborator Author

maartenbreddels commented Mar 21, 2019 via email

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.

2 participants