Skip to content

Isolate IPyKernel to a dedicated module / namespace#3

Closed
slippycheeze wants to merge 1 commit intobl-sdk:masterfrom
slippycheeze:isolate-ipython
Closed

Isolate IPyKernel to a dedicated module / namespace#3
slippycheeze wants to merge 1 commit intobl-sdk:masterfrom
slippycheeze:isolate-ipython

Conversation

@slippycheeze
Copy link
Copy Markdown

Create a dedicated module for IPyKernel to run code in. It defaults to using __main__, which exposes core parts of the SDK directoly to it.

Normally this wouldn't be so bad, except that various tools like the %reset magic can cause some trouble: that one resets the state of the namespace that IPyKernel is in to "default" by deleting almost everything.

Which, it turns out, includes various _... variables that are used by the SDK to do almost everything; after running it no mods worked, and in general the SDK was in a kind of broken state.

It might be nice to have access to __main__ easily, but not as nice as being protected from accidentally destroying everything. :)

Create a dedicated module for IPyKernel to run code in.  It defaults to
using `__main__`, which exposes core parts of the SDK directoly to it.

Normally this wouldn't be so bad, except that various tools like the
`%reset` magic can cause some trouble: that one resets the state of the
namespace that IPyKernel is in to "default" by deleting
almost everything.

Which, it turns out, includes various `_...` variables that are used by
the SDK to do almost everything; after running it no mods worked, and in
general the SDK was in a kind of broken state.

It might be nice to have access to `__main__` easily, but not as nice as
being protected from accidentally destroying everything. :)
@slippycheeze
Copy link
Copy Markdown
Author

thing includes the changes requested in the previous version; I ended up using a file on disk to create the module because, apparently, using ModuleType directly is disapproved of these days, and faking it was more pain than it was worth.

@apple1417
Copy link
Copy Markdown
Contributor

No idea what's happened to the gh actions (are they having an outages?), but please also fix those, you had some ruff failures.

Wdym by this

apparently, using ModuleType directly is disapproved of these days, and faking it was more pain than it was worth.

@apple1417
Copy link
Copy Markdown
Contributor

done in #4

@apple1417 apple1417 closed this Mar 7, 2026
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