Skip to content
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

Add templating for Jupyter notebooks. #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add templating for Jupyter notebooks. #13

wants to merge 4 commits into from

Conversation

wisygig
Copy link

@wisygig wisygig commented Jul 26, 2017

Motivation

Add templates for jupyter notebooks. Examples are available in the README.md file.

API changes

None.

Implementation Notes

Anything that could be helpful to the reviewer. Especially if it not obvious from looking at the diffs.

Functional Tests

see nb_util/tests/test_jupyter_template.py.

@rdvelazquez
Copy link
Member

FYI - I got this to work on my computer on my own dummy example. When I first ran it I got the following error:

jupyter_template.py in <module>()
     17     'code': nbformat.v4.new_code_cell,
     18     'markdown': nbformat.v4.new_markdown_cell,
---> 19     'raw': nbformat.v4.new_raw_cell,
     20 }
     21 

AttributeError: module 'nbformat.v4' has no attribute 'new_raw_cell'

When I commented out the 'raw': nbformat.v4.new_raw_cell, line in jupyter_template.py it worked fine....

I may use this for some other applications soon and I'll let you know how that works out.

@wisygig and @dcgoss let me know if you want any review of the code in this PR.

Nice work Jason!

@wisygig
Copy link
Author

wisygig commented Jul 27, 2017

@rdvelazquez Interesting! Can you run a pip list | grep 'nbformat' in your terminal?

@rdvelazquez
Copy link
Member

when I run pip list | grep 'nbformat' I get a fairly long output. It starts with:

grep is not recognized as an internal or external command, operable program or batch file

Here's a snippet of the output for reference (I couldn't really make sense of it):

pip\_vendor\colorama\ansitowin32.py", line 169, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "C:\Users\rvelazquez\AppData\Local\Continuum\Anaconda3\lib\site-packages\
pip\_vendor\colorama\ansitowin32.py", line 175, in write_plain_text
    self.wrapped.flush()
OSError: [Errno 22] Invalid argument
Call stack:
  File "C:\Users\rvelazquez\AppData\Local\Continuum\Anaconda3\Scripts\pip-script
.py", line 5, in <module>
    sys.exit(pip.main())
  File "C:\Users\rvelazquez\AppData\Local\Continuum\Anaconda3\lib\site-packages\
pip\__init__.py", line 249, in main
    return command.main(cmd_args)
  File "C:\Users\rvelazquez\AppData\Local\Continuum\Anaconda3\lib\site-packages\
pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\rvelazquez\AppData\Local\Continuum\Anaconda3\lib\site-packages\
pip\commands\list.py", line 164, in run
    self.output_package_listing(packages, options)

The output ends with:

Message: 'zict (0.1.2)'
Arguments: ()
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='cp12
52'>
OSError: [Errno 22] Invalid argument

I have version 4.2.0 of nbformat installed (both when I list via conda and via pip).

@wisygig
Copy link
Author

wisygig commented Jul 27, 2017

Ah, that explains it! I was working with nbformat 4.3.0. It should be in the requirements.txt file.

@rdvelazquez
Copy link
Member

That was it. I updated to nbformat 4.3.0, uncommented the 'raw': nbformat.v4.new_raw_cell line and it ran just fine. Thanks @wisygig!

@dcgoss
Copy link
Member

dcgoss commented Jul 29, 2017

Hey! I’ve been on vacation since last Friday, so I’ll take a look at this when I return on Monday.

@dcgoss
Copy link
Member

dcgoss commented Jul 31, 2017

Wow, this is an amazing package! @wisygig you should really consider making this into a standalone package, something seems wrong about keeping it embedded into ml-workers.
Can it substitute an array value in for a key?

@rdvelazquez
Copy link
Member

I'll second the standalone package comment!

@wisygig
Copy link
Author

wisygig commented Aug 2, 2017

@dcgoss Yes, but only as a string. For example, {'value': "['gene1', 'gene2', 'gene3']"}.

@dhimmel
Copy link
Member

dhimmel commented Aug 10, 2017

@wisygig thanks for this cool PR. It's definitely a useful utility. I agree with @dcgoss and @rdvelazquez that it makes sense as a package.

We have two options:

  1. merge this PR and you can make this a package in the future
  2. you make a standalone package now that we add as a dependency.

@dcgoss mentioned that we need some additional changes ml_task_runner.py for this to become operable. I want to make sure this PR goes somewhere, since it contains lot's of great work!

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.

4 participants