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 the --ip and --port post processors for the --post serve #102

Closed
mertzjames opened this issue Sep 14, 2015 · 16 comments
Closed

Add the --ip and --port post processors for the --post serve #102

mertzjames opened this issue Sep 14, 2015 · 16 comments
Milestone

Comments

@mertzjames
Copy link

Instead of serving to the localhost ip address, I would like to configure the ip address and port served for viewing the slide shows. This could be done by adding another post-processor to the nbconvert command:

jupyter nbconvert --to slides --post serve --ip X.X.X.X --port XXXX <notebook.ipynb

The default value would continue to be 127.0.0.0 but this would allow the usage of 0.0.0.0 or any other custom IP address for serving the slide show on the local or public network. This would also allow for custom port incase the default 8000 is already used.

@Carreau
Copy link
Member

Carreau commented Sep 14, 2015

If you want to serve on another port I would suggest just converting to slides and then firering a real http server (python -m http.server <port>) IIRC listen on all interfaces.

The post --server is really just for convenience, and building extra config option is a slippery slope that will becomme too complex./

@mertzjames
Copy link
Author

Problem with that is that it doesn't render the slides correctly. It renders like a flat HTML file.

@Carreau
Copy link
Member

Carreau commented Sep 14, 2015

Problem with that is that it doesn't render the slides correctly. It renders like a flat HTML file.

Hum indeed. apparently it does not work anymore, the code use a tornado proxy to map reveal.js location.

Fortunately the flags are already there (we all learn things everyday) !

$ jupyter nbconvert --to slides  --ServePostProcessor.port=8910 --ServerPostProcessor.ip='*' --post serve <mynotebook.ipynb>
# [Edit, extra r read ServerPostProcessor above]

Maybe --help-all should list the flags of all pre/post-processors ? @damianavila

@mertzjames
Copy link
Author

I ran this:

jupyter nbconvert "notebook.ipynb" --to slides --post serve --ServerPostProcessor.ip="0.0.0.0"

and got this error:

Traceback (most recent call last):
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\Scripts\jupyter-nbconvert-script.py", line 5, in <module>
    main()
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\lib\site-packages\jupyter_core\application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\lib\site-packages\traitlets\config\application.py", line 592, in launch_instance
    app.start()
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 286, in start
    self.convert_notebooks()
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 409, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 382, in convert_single_notebook
    self.postprocess_single_notebook(write_results)
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 367, in postprocess_single_notebook
    self.postprocessor(write_results)
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\postprocessors\base.py", line 28, in __call__
    self.postprocess(input)
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\postprocessors\serve.py", line 87, in postprocess
    http_server.listen(self.port, address=self.ip)
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\lib\site-packages\tornado\tcpserver.py", line 126, in listen
    sockets = bind_sockets(port, address=address)
File "C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3\lib\site-packages\tornado\netutil.py", line 187, in bind_sockets
    sock.bind(sockaddr)
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted

Using and ip address of '*' still only serves the pages on the local host ip address.

@Carreau
Copy link
Member

Carreau commented Sep 14, 2015

Hum. works for me but I'm on master. We might have had a recent bugfix to fix that. What if you use another port ?

@damianavila
Copy link
Member

Working for me with latest released nbconvert..

@mertzjames
Copy link
Author

I'm using Anaconda. Here's is the output of conda info jupyter:

jupyter 1.0.0 py34_0
--------------------
file name   : jupyter-1.0.0-py34_0.tar.bz2
name        : jupyter
version     : 1.0.0
build number: 0
build string: py34_0
channel     : defaults
size        : 2 KB
date        : 2015-08-13
license     : BSD
md5         : 5db5a3d83d2440686158466e6bbd4ce5
installed environments:
    C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3
dependencies:
    ipykernel 4.0.3
    ipywidgets 4.0.2
    jupyter_console
    nbconvert
    notebook
    python 3.4*
    qtconsole

I was able to finally resolve my issue by editing the serve.py file in nbconvert to have the ip address of 0.0.0.0. It's a temporary fix.

Here is what I was able to get from running conda info nbconvert:

nbconvert 4.0.0 py34_0
----------------------
file name   : nbconvert-4.0.0-py34_0.tar.bz2
name        : nbconvert
version     : 4.0.0
build number: 0
build string: py34_0
channel     : defaults
size        : 307 KB
date        : 2015-08-13
license     : BSD
md5         : 54a272cad6289ec1e03b2dd04c9497ec
installed environments:
    C:\Users\KronoSKoderS\AppData\Local\Continuum\Anaconda3
dependencies:
    ipython
    jinja2
    jupyter_core
    mistune
    nbformat
    pygments
    python 3.4*
    traitlets

@mertzjames
Copy link
Author

I should also note, that running:

ipython nbconvert "notebook.ipynb" --to slides --post serve --ServerPostProcessor.ip="0.0.0.0"

works, but doesn't do anything with changing the ip address.

@damianavila
Copy link
Member

I think this is related with this: #103 (comment)

Maybe something win-specific??

@damianavila
Copy link
Member

@KronoSKoderS can you test if jupyter/jupyter_core#54 fix this issue as well?

@mertzjames
Copy link
Author

I spoke a little too soon and tested in an unclean environment. I had made a custom change to serve.py in nbconvert/postprocessors like so:

class ServePostProcessor(PostProcessorBase):
    """Post processor designed to serve files

    Proxies reveal.js requests to a CDN if no local reveal.js is present
    """


    open_in_browser = Bool(True, config=True,
        help="""Should the browser be opened automatically?"""
    )
    reveal_cdn = Unicode("https://cdn.jsdelivr.net/reveal.js/2.6.2", config=True,
        help="""URL for reveal.js CDN."""
    )
    reveal_prefix = Unicode("reveal.js", config=True, help="URL prefix for reveal.js")
    ip = Unicode("0.0.0.0", config=True, help="The IP address to listen on.")  #CHANGED SOMETHING HERE!!!!
    port = Int(8000, config=True, help="port for the server to listen on.")

Running the following command:

jupyter nbconvert --to slides  --ServePostProcessor.port=8910 --ServerPostProcessor.ip='*' --post serve <mynotebook.ipynb>

get's us half way there. The IP address does not change, however the port does.

@damianavila
Copy link
Member

@Carreau @minrk ideas? maybe some trailets related issue? mmm...

@Carreau
Copy link
Member

Carreau commented Sep 17, 2015

Yep, remember that there is no error if there is a typo.

--ServerPostProcessor.ip='*'   # wrong
--ServePostProcessor.ip='*'  #right

you wrote an extra r :-)

@Carreau
Copy link
Member

Carreau commented Sep 17, 2015

Well technically I did by bad copy pasting.

@damianavila
Copy link
Member

Well technically I did by bad copy pasting.

My bad too... OK let's close it again...

@minrk minrk added this to the no action milestone Oct 5, 2015
@williamstein
Copy link

OK let's close it again...

Perhaps we could add some docs here about how to change the port:
http://nbconvert.readthedocs.io/en/latest/usage.html#convert-revealjs

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

No branches or pull requests

5 participants