Skip to content

Commit

Permalink
Update conda environment description
Browse files Browse the repository at this point in the history
Add evaluate_debugger.py to help test for debugger behavior
register an atexit handler in run_notebook_in_subprocess to cleanup in case user never invokes the closure
  • Loading branch information
breathe committed Apr 13, 2019
1 parent b2a6522 commit 9a36da8
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 160 deletions.
9 changes: 9 additions & 0 deletions NotebookScripter/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ def run_notebook_in_process(
"""

import multiprocessing as mp
import atexit

context = mp.get_context("spawn")
child_to_parent_queue = context.Queue()
Expand All @@ -362,6 +363,12 @@ def run_notebook_in_process(
p = context.Process(target=worker, args=(parent_to_child_queue, child_to_parent_queue, path_to_notebook, __notebookscripter_injected__), kwargs=hooks)
p.start()

def _terminate_when_parent_process_ends():
p.terminate()
p.join()

atexit.register(_terminate_when_parent_process_ends)

def _block_and_receive_results(*return_values):
"""
Block until the notebook execution has completed. Then retrieve return_values from the subprocess's module scope and return
Expand All @@ -372,6 +379,8 @@ def _block_and_receive_results(*return_values):
return_values: Optional list of strings to pass back from subprocess -- values matching these names in the module created by invoking the notebook in a subprocess will be serialized passed across process boundaries back to this process, deserialized and made part of the returned module
"""

atexit.unregister(_terminate_when_parent_process_ends)

parent_to_child_queue.put(return_values)

module_identity = "loaded_notebook_from_subprocess"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ See [DEVELOPMENT_README.md](DEVELOPMENT_README.md)

### 5.1.0

- Add new method: run_notebook_in_jupyter. Runs
- Add new method: run_notebook_in_jupyter. Runs notebook's/.py files in a jupyter kernel - supports rendering jupyter notebook files with populated output cells.

### 5.0.0

Expand Down
173 changes: 101 additions & 72 deletions conda_dev.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,115 @@
name: nbs-dev
name: NotebookScripter
channels:
- defaults
dependencies:
- ca-certificates=2018.03.07=0
- certifi=2018.10.15=py37_0
- appnope=0.1.0=py37_0
- astroid=2.2.5=py37_0
- atomicwrites=1.3.0=py37_1
- attrs=19.1.0=py37_1
- backcall=0.1.0=py37_0
- blas=1.0=mkl
- bleach=3.1.0=py37_0
- ca-certificates=2019.1.23=0
- certifi=2019.3.9=py37_0
- coverage=4.5.3=py37h1de35cc_0
- cycler=0.10.0=py37_0
- dbus=1.13.6=h90a0687_0
- decorator=4.4.0=py37_1
- defusedxml=0.5.0=py37_1
- entrypoints=0.3=py37_0
- expat=2.2.6=h0a44026_0
- flake8=3.7.7=py37_0
- freetype=2.9.1=hb4e5f40_0
- gettext=0.19.8.1=h15daf44_3
- glib=2.56.2=hd9629dc_0
- icu=58.2=h4b95b61_1
- intel-openmp=2019.3=199
- ipykernel=5.1.0=py37h39e3cac_0
- ipython=7.4.0=py37h39e3cac_0
- ipython_genutils=0.2.0=py37_0
- ipywidgets=7.4.2=py37_0
- isort=4.3.16=py37_0
- jedi=0.13.3=py37_0
- jinja2=2.10.1=py37_0
- jpeg=9b=he5867d9_2
- jsonschema=3.0.1=py37_0
- jupyter=1.0.0=py37_7
- jupyter_client=5.2.4=py37_0
- jupyter_console=6.0.0=py37_0
- jupyter_core=4.4.0=py37_0
- kiwisolver=1.0.1=py37h0a44026_0
- lazy-object-proxy=1.3.1=py37h1de35cc_2
- libcxx=4.0.1=hcfea43d_1
- libcxxabi=4.0.1=hcfea43d_1
- libedit=3.1.20170329=hb402a30_2
- libedit=3.1.20181209=hb402a30_0
- libffi=3.2.1=h475c297_4
- ncurses=6.1=h0a44026_0
- openssl=1.1.1a=h1de35cc_0
- pip=18.1=py37_0
- python=3.7.1=haf84260_3
- libgfortran=3.0.1=h93005f0_2
- libiconv=1.15=hdd342a3_7
- libpng=1.6.36=ha441bb4_0
- libsodium=1.0.16=h3efe00b_0
- markupsafe=1.1.1=py37h1de35cc_0
- matplotlib=3.0.3=py37h54f8f79_0
- mccabe=0.6.1=py37_1
- mistune=0.8.4=py37h1de35cc_0
- mkl=2019.3=199
- mkl_fft=1.0.10=py37h5e564d8_0
- mkl_random=1.0.2=py37h27c97d8_0
- more-itertools=6.0.0=py37_0
- nbconvert=5.4.1=py37_3
- nbformat=4.4.0=py37_0
- ncurses=6.1=h0a44026_1
- notebook=5.7.8=py37_0
- numpy=1.16.2=py37hacdab7b_0
- numpy-base=1.16.2=py37h6575580_0
- openssl=1.1.1b=h1de35cc_1
- pandoc=2.2.3.2=0
- pandocfilters=1.4.2=py37_1
- parso=0.3.4=py37_0
- pcre=8.43=h0a44026_0
- pexpect=4.6.0=py37_0
- pickleshare=0.7.5=py37_0
- pip=19.0.3=py37_0
- pluggy=0.9.0=py37_0
- prometheus_client=0.6.0=py37_0
- prompt_toolkit=2.0.9=py37_0
- ptyprocess=0.6.0=py37_0
- py=1.8.0=py37_0
- pycodestyle=2.5.0=py37_0
- pyflakes=2.1.1=py37_0
- pygments=2.3.1=py37_0
- pylint=2.3.1=py37_0
- pyparsing=2.4.0=py_0
- pyqt=5.9.2=py37h655552a_2
- pyrsistent=0.14.11=py37h1de35cc_0
- pytest=4.4.0=py37_1
- pytest-cov=2.6.1=py37_0
- python=3.7.3=h359304d_0
- python-dateutil=2.8.0=py37_0
- pytz=2018.9=py37_0
- pyzmq=18.0.0=py37h0a44026_0
- qt=5.9.7=h468cd18_1
- qtconsole=4.4.3=py37_0
- readline=7.0=h1de35cc_5
- setuptools=40.6.2=py37_0
- sqlite=3.25.3=ha441bb4_0
- send2trash=1.5.0=py37_0
- setuptools=41.0.0=py37_0
- sip=4.19.8=py37h0a44026_0
- six=1.12.0=py37_0
- sqlite=3.27.2=ha441bb4_0
- terminado=0.8.1=py37_1
- testpath=0.4.2=py37_0
- tk=8.6.8=ha441bb4_0
- wheel=0.32.3=py37_0
- tornado=6.0.2=py37h1de35cc_0
- traitlets=4.3.2=py37_0
- wcwidth=0.1.7=py37_0
- webencodings=0.5.1=py37_1
- wheel=0.33.1=py37_0
- widgetsnbextension=3.4.2=py37_0
- wrapt=1.11.1=py37h1de35cc_0
- xz=5.2.4=h1de35cc_4
- zeromq=4.3.1=h0a44026_3
- zlib=1.2.11=h1de35cc_3
- pip:
- appnope==0.1.0
- astroid==2.0.4
- autopep8==1.4.3
- backcall==0.1.0
- bleach==3.0.2
- coverage==4.5.2
- cycler==0.10.0
- decorator==4.3.0
- defusedxml==0.5.0
- docutils==0.12
- entrypoints==0.2.3
- flake8==3.6.0
- ipykernel==5.1.0
- ipython==7.1.1
- ipython-genutils==0.2.0
- ipywidgets==7.4.2
- isort==4.3.4
- jedi==0.13.1
- jinja2==2.10
- jsonschema==2.6.0
- jupyter==1.0.0
- jupyter-client==5.2.3
- jupyter-console==6.0.0
- jupyter-core==4.4.0
- kiwisolver==1.0.1
- lazy-object-proxy==1.3.1
- markupsafe==1.1.0
- matplotlib==3.0.2
- mccabe==0.6.1
- mistune==0.8.4
- nbconvert==5.4.0
- nbformat==4.4.0
- nose==1.3.7
- notebook==5.7.2
- numpy==1.15.4
- pandocfilters==1.4.2
- parso==0.3.1
- pexpect==4.6.0
- pickleshare==0.7.5
- prometheus-client==0.4.2
- prompt-toolkit==2.0.7
- ptyprocess==0.6.0
- pycodestyle==2.4.0
- pyflakes==2.0.0
- pygments==2.0.2
- pylint==2.1.1
- pyparsing==2.3.0
- python-dateutil==2.7.5
- pyzmq==17.1.2
- qtconsole==4.4.3
- send2trash==1.5.0
- six==1.11.0
- snapshottest==0.5.0
- termcolor==1.1.0
- terminado==0.8.1
- testpath==0.4.2
- tornado==5.1.1
- traitlets==4.3.2
- wcwidth==0.1.7
- webencodings==0.5.1
- widgetsnbextension==3.4.2
- wrapt==1.10.11
prefix: /Users/ncohen/anaconda3/envs/nbs-dev
prefix: /Users/ncohen/anaconda3/envs/NotebookScripter

87 changes: 0 additions & 87 deletions conda_with_nbscripter.yml

This file was deleted.

4 changes: 4 additions & 0 deletions evaluate_debugger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from NotebookScripter import run_notebook_in_process

if __name__ == "__main__":
run_notebook_in_process("./tests/SearchParents_1.pynotebook", a="grandparent_a")()

0 comments on commit 9a36da8

Please sign in to comment.