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

Getting rid of Jupyter global #170

Open
Carreau opened this issue Jun 25, 2015 · 20 comments
Open

Getting rid of Jupyter global #170

Carreau opened this issue Jun 25, 2015 · 20 comments

Comments

@Carreau
Copy link
Member

Carreau commented Jun 25, 2015

Main usage of global is for extensions to access things right ?

Idea : pass the relevant local object in ipython_load_extension() which extension should define.

Thoughts ?

@takluyver
Copy link
Member

There needs to be some way for users to open a JS console and poke around the JS interfaces. How would we do that without a global of some kind?

@ellisonbg
Copy link
Contributor

Is there a way that we can grab a handle to the things that require has
imported for a page?

I am all for getting rid of the global, but agree with @takluyver about
needing a handle for debugging things

On Thu, Jun 25, 2015 at 11:30 AM, Thomas Kluyver [email protected]
wrote:

There needs to be some way for users to open a JS console and poke around
the JS interfaces. How would we do that without a global of some kind?


Reply to this email directly or view it on GitHub
#170 (comment).

Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]

@Carreau
Copy link
Member Author

Carreau commented Jun 25, 2015

Well, modules are still available by foo = require('path'), I have no issues having user poking around, but what if you want many notebook per page ? What about many extensions requiring the global IPython ?

We need a way for it to work even without globals, and we can have global injection to be done only if user click a checkbox or set an option. Though it forces extensions and code to be clean of global only, and get convenience of global only in explicit case. e

@ellisonbg
Copy link
Contributor

I should clarify - I am fine completely getting rid of the global - I think
we just want to have some way for users to dig around and get access to the
objects for debugging

On Thu, Jun 25, 2015 at 1:51 PM, Matthias Bussonnier <
[email protected]> wrote:

Well, modules are still available by foo = require('path'), I have no
issues having user poking around, but what if you want many notebook per
page ? What about many extensions requiring the global IPython ?

We need a way for it to work even without globals, and we can have global
injection to be done only if user click a checkbox or set an option. Though
it forces extensions and code to be clean of global only, and get
convenience of global only in explicit case. e


Reply to this email directly or view it on GitHub
#170 (comment).

Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]

@takluyver
Copy link
Member

The important bit is the instances, which you can't get with require. I don't think poking around should only be possible if you set some special option. And we're still a long way from having multiple notebooks on a page, so we've got time to work out a good solution to the problem that doesn't make the notebook less capable.

@ellisonbg
Copy link
Contributor

Yes, it is definitely the instances. phosphor may help with this - Chris
actually has a very powerful system that takes care of instantiating
objects that implements various interfaces and tracking their lifetimes and
interactions.

On Thu, Jun 25, 2015 at 1:59 PM, Thomas Kluyver [email protected]
wrote:

The important bit is the instances, which you can't get with require. I
don't think poking around should only be possible if you set some special
option. And we're still a long way from having multiple notebooks on a
page, so we've got time to work out a good solution to the problem that
doesn't make the notebook less capable.


Reply to this email directly or view it on GitHub
#170 (comment).

Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]

@Carreau
Copy link
Member Author

Carreau commented Jun 25, 2015

The point is not to cripple the notebook, it is to make hard to access the global in places where you should not, like

define(['forget_namespace'],function(){
    // Use global without realizing. 
})

> Yes, it is definitely the instances. phosphor may help with this - Chris
> actually has a very powerful system that takes care of instantiating
> objects that implements various interfaces and tracking their lifetimes and
> interactions.

For that it would be nice to push typescript and notebook rewriting forward... it nice to say that it's a powerful things, it would be nice to use it.

@minrk
Copy link
Member

minrk commented Jun 25, 2015

Yup, I think it's just the instances, adn I think it's really just IPython.notebook, the outermost instance, that's needed to be attached to something global. We could attach it directly to window, I suppose. I'm fully in support of removing all of the IPython.Classes, etc. from the IPython namespace, and removing any reference/use of the IPython namespace outside the main.js files.

@Carreau
Copy link
Member Author

Carreau commented Jun 25, 2015

keyboard_manager too need to be somewhere. Wether IPython or notebook is top level is the same problem, it is just a global. It would be nice to have something explicit like a function call à la get_ipython()

@takluyver
Copy link
Member

But then you need to make the function global, and it needs to be a closure over a reference to IPython or notebook, or something. It doesn't avoid having a global, it just makes it slightly harder to use.

The only way I can think of to avoid making it a global is to attach it to an element on the page, so you have to do e.g. $('#notebook').data('notebook') to get it. That seems inelegant, and unnecessary until we actually have multiple notebooks on a page.

@Carreau
Copy link
Member Author

Carreau commented Jun 25, 2015

The problem is that the global IPython and the requirement: require(['base/js/namespace'], function(IPython){}) in the end expose the same thing: IPython. Which make the distinction for users impossible.

$('#notebook').data('notebook') or get_ipython() make it obvious there is a difference. Even injecting the name differently global 250ms after notebook ready would at least prevent user from using it in extensions.

@takluyver takluyver added this to the wishlist milestone Jun 25, 2015
@JamiesHQ
Copy link
Member

Can this issue be closed? Any additional steps to take?

@ellisonbg
Copy link
Contributor

I think so, but @Carreau should confirm.

@Carreau
Copy link
Member Author

Carreau commented Apr 25, 2017

It's not really addressed it's probably better in JupyterLab, but depending on how long the classic notebook lives I would still like to have a better story for that.

@JamiesHQ
Copy link
Member

cc'ing @blink1073 and @gnestor so the work can get added to the appropriate queue

@ellisonbg
Copy link
Contributor

While I remain fine with removing the global, I think it will cause more pain for users and ourselves (debugging) than it is worth. If we do keep this, it should be very low on the backlog of the classic notebook.

@Carreau
Copy link
Member Author

Carreau commented Apr 25, 2017

While I remain fine with removing the global, I think it will cause more pain for users and ourselves (debugging) than it is worth. If we do keep this, it should be very low on the backlog of the classic notebook.

But extension that want to be compatible JupyterLab and classic notebook cannot make the assumption that notebook is a global. Passing notebook as a parameter to the extension seem the right thing to do and push for good habits to make the transition easier.

@gnestor
Copy link
Contributor

gnestor commented Apr 25, 2017

Not sure what next steps should be, but taking @ellisonbg's advice and marking as backlog and low priority...

@ellisonbg
Copy link
Contributor

ellisonbg commented Apr 25, 2017 via email

@gnestor
Copy link
Contributor

gnestor commented Apr 25, 2017

@ellisonbg I'm happy to comment but I'm not 100% clear on the problem here...

@gnestor gnestor changed the title Getting rid of IPython global. Getting rid of Jupyter global Dec 2, 2017
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

6 participants