-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execute a cell decorator #5
Comments
Hey, I'm looking into this. So are we looking at some functionality like.. @execute_cell(3)
def test_foo():
pass If yes, Also, I'm guessing that it should actually be |
Yes something like this would be good.
I see two ways we can support which notebook to be executing. First is to require a separate decorator first (e.g. |
Alright, I'll go ahead with adding an optional argument for now.
I'm not sure what you meant by this? 😅 |
So when you load (or execute) a notebook you get this nbformat object which is basically a dict holding the v4 notebook schema. This contains things like tags, cells, outputs, metadata, etc. In our testbook case we want to expose the values therein so people can make assertions against the fields. But we likely will want to add additional functions like |
So I tried to use # assume that the following is inside a decorator
with open(notebook_filename) as f:
nb = nbformat.read(f, as_version=4)
client = NotebookClient(nb)
client.execute_cell(nb['cells'][cell_index], cell_index)
@execute_cell('../testbook_example.ipynb', 2)
def foo():
pass
foo() It throws an
I looked into the code in I'm not sure if this a bug or not. @MSeal |
Thanks for the explanation. It makes perfect sense now 😄 |
We're refactoring that code a bit -- make sure to use the released 0.1 code for now -- we'll be keeping that contract as best we can before 0.2 releases. For now I would look at how papermill extends it to prep/wrap nbclient: https://github.com/nteract/papermill/blob/master/papermill/clientwrap.py#L30-L70. We can also update nbclient to have better extension interfaces in the future as we progress. |
I'll create a `TestbookNotebookClient` that extends `NotebookClient` then.
Thanks.
…On Thu, 19 Mar 2020, 01:33 Matthew Seal, ***@***.***> wrote:
I looked into the code in client.py and found that setup_kernel is not
being used in execute_cell and hence in async_execute_cell.
I'm not sure if this a bug or not. @MSeal <https://github.com/MSeal>
We're refactoring that code a bit -- make sure to use the released 0.1
code for now -- we'll be keeping that contract as best we can before 0.2
releases.
For now I would look at how papermill extends it to prep/wrap nbclient:
https://github.com/nteract/papermill/blob/master/papermill/clientwrap.py#L30-L70.
We can also update nbclient to have better extension interfaces in the
future as we progress.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJK24DXCSBUXNUZVDA45LPTRIESHXANCNFSM4LLX4VFA>
.
|
Add the most basic "execute indicated cell" before unittest runs decorator. This will be used to prep a test case for evaluation.
The text was updated successfully, but these errors were encountered: