-
Notifications
You must be signed in to change notification settings - Fork 97
Classes from Modules Not Loading Correctly #130
Comments
Just tested with Autoreload is part of IPython; what version of IPython do you have? If it's not the latest, try upgrading. |
Will do - I'll post back with results.
…On Wed, Feb 1, 2017 at 10:32 AM Thomas Kluyver ***@***.***> wrote:
Just tested with class-test-fail-II, and it worked for me with both
Python 3 and 2.
Autoreload is part of IPython; what version of IPython do you have? If
it's not the latest, try upgrading.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#130 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAPUh7VqEU-pGwohYKVRKPO2Or0OlUI3ks5rYMG8gaJpZM4L0IQa>
.
|
Sorry, I didn't save the project file prior to zipping with class-test-fail-II. I have updated ipython and can still recreate the error with this case (see new attached zip). The notebook should have this code in it: (cell 1) (cell 2) sorry for screwing up the first submission there. Also, this does fail in ipython too; should I submit the report there? |
Aha, yes, I can reproduce it too now. I should have compared the issue description with the sample notebook. It will be in IPython, because that's where the autoreload code is, and it will be that that's going wrong. |
I think I see roughly what's happening: the classes inside the module are being updated when it is reloaded, but the class B that you brought into the main namespace is still a reference to the old class B before the module was reloaded. To be honest, when I look at autoreload, I'm amazed that it works as well as it does. |
haha!
I'll post this over to the ipython folks. Ya'll can close if you want, no
probs on my end.
…On Wed, Feb 1, 2017 at 2:57 PM Thomas Kluyver ***@***.***> wrote:
I think I see roughly what's happening: the classes inside the module are
being updated when it is reloaded, but the class B that you brought into
the main namespace is still a reference to the old class B before the
module was reloaded.
To be honest, when I look at autoreload, I'm amazed that it works as well
as it does.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#130 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAPUh-Aoa0h8dlqsMzmUMmGDg5Jz25XWks5rYP_dgaJpZM4L0IQa>
.
|
The IPython folks look a lot like us. ;-) There's a good chance it's me debugging it either way. |
tl;dr: from import causes a TypeError when classes are autoreloaded
Okay, so whenever I try to use 'from import ' notation in a notebook I get this error:
TypeError: super(type, obj): obj must be an instance or subtype of type
Now, interestingly, when I attempt to re-execute the reloaded file, isinstance(self, ) returns false, causing this error.
I've been able to recreate this in a couple of ways. The first way involves using a package and importing classes from that package.
I've attached three testcases to this issue. The first, class-test-works.zip, shows an example that works in a notebook. You'll note that I'm importing from a file (package.py) and I'm using full package import notation (i.e. 'import package as p'). Autoreloading works here - make changes to the package.py file, and re-run the second cell. Everything is fine.
The second, class-test-fail-I.zip, uses python directory modules with an init.py in the package directory. Here, the init.py file imports the public classes via class-specific notation (i.e. 'from package import A, B, C'). Run the packaged notebook. The first time, everything is fine. Now make a change to the package/package.py file, and save it. Then re-run the second cell. You'll get a TypeError on the call to super(...) in the emit(.) method in B.
The third, clas-test-fail-II.zip, uses a file instead of a directory, and loads the file into the notebook with class-specific notation (i.e. 'from package import B'). Repeat the steps from above - load and run, make a change to package.py and save, then rerun the second cell. You'll see the TypeError failure.
class-test-works.zip
class-test-fail-II.zip
class-test-fail-I.zip
The text was updated successfully, but these errors were encountered: