Skip to content

Abrosimov-a-a/jupyter_pstate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

jupyter-pstate

Save Jupyter state inside the function and open it in other Jupyter tab.

parent.ipynb:

from jupyter_pstate import pstate
STATE = pstate('./test.tmp')

a = ''
def func1():
  global a
  a = 'imported'
  STATE.ImportBreak() # <- Stop importing as module.
  b = 'saved'
  STATE.save(locals()) # <- Save local() via pickle and stop execution.
  c = 'not executed' 
func1()
# Execution stoped.

child.ipynb:

from jupyter_pstate import pstate
STATE = pstate('./test.tmp')
from parent import *
print(a)
# OUT: imported
print(b)
# Traceback
locals().update(STATE.load()[0])
print(b)
# OUT: saved
# We are inisde the function: parent.func1
print(c)
# Traceback. This is never executed.

About

Save Jupyter state inside the function and open it in other Jupyter tab.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages