Comments (2)
To create IPyflow variants of all the various subclasses of InteractiveShell
, it seems like the cleanest way (but definitely not the easiest to understand) is to do fancy metaclass stuff to patch IPyflowInteractiveShell
into the mro. Toy example:
from IPython.terminal.embed import InteractiveShellEmbed
from IPython.terminal.interactiveshell import InteractiveShell
from traitlets import MetaHasTraits
def make_mro_inserter_metaclass(old_class, new_class):
class MetaMroInserter(MetaHasTraits):
def mro(cls):
ret = []
for clazz in super().mro():
if clazz is old_class:
ret.append(new_class)
ret.append(clazz)
return ret
return MetaMroInserter
class MyInteractiveShell(InteractiveShell):
def run_cell(self, *args, **kwargs):
print("run cell")
return super().run_cell(*args, **kwargs)
class MyInteractiveShellEmbed(InteractiveShellEmbed, metaclass=make_mro_inserter_metaclass(InteractiveShell, MyInteractiveShell)):
pass
ipshell = MyInteractiveShellEmbed()
ipshell.run_cell("x = 0") # prints 'run cell' before running the cell
from ipyflow.
This would more readily unblock use cases like #134.
from ipyflow.
Related Issues (20)
- register comm target on frontend for allowing non-ipyflow kernels to broadcast capabilities HOT 1
- add to conda-forge HOT 1
- Execute in reverse: Execute cells required for a cell to execute HOT 10
- Creating Cell Flow Graph Without Ipython HOT 11
- add kernel hook for after execute_reply sent
- add batch reactivity mode
- improve %load_ext to work with other kernels that wrap IPythonKernel
- [lab] enable reactive execution for "run selected"
- allow tracing to resume during function execution HOT 2
- persist dependencies in notebook metadata and apply after notebook restarts HOT 1
- certain cell executions produce "file changed on disk" popup HOT 1
- add button or hotkey for fusing all cells in forward / backward / full slice into one cell
- ipyflow kernel incompatible with google colab HOT 5
- Explore using sys.monitoring for instrumentation on 3.12
- Don't use persisted dag in ipynb metadata if another kernel was used
- Add %%memoize cell magic or equivalent HOT 3
- improve pdb compatibility
- upsert symbols for starred imports
- use argparsers that don't exit on parse error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipyflow.