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

%run_viz line magic requires session.close first #811

Closed
antonymilne opened this issue Apr 5, 2022 · 4 comments
Closed

%run_viz line magic requires session.close first #811

antonymilne opened this issue Apr 5, 2022 · 4 comments

Comments

@antonymilne
Copy link
Contributor

antonymilne commented Apr 5, 2022

Description

Running %run_viz from within a kedro ipython or jupyter instance will raise an exception "Cannot activate the session as another active session already exists".

After some sleuthing and testing I decided that this bug has existed since kedro-viz 4.0.0 (26 Oct 2021) and was caused by PR #603, which was itself trying to fix some error with no active session. _activate_session is called only when using the kedro session as a context manager (which is why this wasn't a problem in older kedro-viz versions) and raises the error.

Workaround

Call session.close() in your ipython instance before doing %run_viz.

Possible solutions

If we get rid of the _active_session stuff like @idanov suggests then this would be fixed straight away by a change on the kedro framework side. If we don't then we can probably fix on the viz side somehow (go back to not using the context manager I guess).

Should we remove %run_viz altogether?

I was already questioning in kedro-org/kedro#1355 whether anyone used %run_viz. The fact that it's had this major bug for nearly 6 months and no one said anything is quite a strong piece of evidence... If we do want to keep it then we should at some point also consider the (very small) bug that I mentioned there though:

Removed idle_timeout argument for kedro jupyter notebook/lab. This was a tricky one to decide on because it was originally introduced for a good reason: to fix a bug in which the %run_viz line magic creates a process that blocks port 4141 even after Jupyter is killed. However, (a) the fix does not seem to work for me [i.e. %run_viz still blocks port 4141 even with the fix], (b) this fix can't ever work on managed jupyter instances so is incompatible with our goal of "one consistent workflow", (c) does anyone use %run_viz anyway? So overall I decided to remove the fix and then later let's work out whether it's really an issue and if so come up with a different fix (probably on the viz side, a %kill_viz command or something).

@tynandebold
Copy link
Member

If no one has complained for that long than yeah, let's remove it and deprecate the feature.

@antonymilne
Copy link
Contributor Author

antonymilne commented Apr 13, 2022

Interesting internal slack thread showing that some people try to use %run_viz on databricks: https://quantumblack.slack.com/archives/C7JTFSFUY/p1649809899788009. This made me realise what this feature was (presumably) originally added for, which I had never really understood before: in order to use kedro-viz when you only have access to a jupyter notebook and can't launch kedro viz from the server or expose a port for it.

It looks like on databricks %run_viz may no longer be required thanks to a hack using shiny, but possibly on other platforms it is still needed.

@rashidakanchwala
Copy link
Contributor

This issue is also mentioned here #737

@antonymilne
Copy link
Contributor Author

The original bug is fixed in Kedro 0.18.1. The other bugs and question of whether to keep %run_viz at all are still open though. I've started a new issue for that: #855

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants