Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#16996 closed enhancement (fixed)

IPython notebook with Sage Extensions

Reported by: vbraun Owned by:
Priority: major Milestone: sage-6.4
Component: interfaces Keywords:
Cc: jondo, vdelecroix Merged in:
Authors: Volker Braun Reviewers: Karl-Dieter Crisman, Sébastien Labbé, John Palmieri, Eric Gourgoulhon, Steve Singleton
Report Upstream: N/A Work issues:
Branch: c54edb5 (Commits, GitHub, GitLab) Commit:
Dependencies: #16746 Stopgaps:

Status badges

Description (last modified by vbraun)

Make the IPython html-based notebook work just like the sage command line.

In particular: make zeromq and pyzmq standard packages.

Screenshots: https://plus.google.com/photos/113188225509686176367/albums/6061181433704732017

Change History (57)

comment:1 Changed 6 years ago by vbraun

  • Branch set to u/vbraun/sage_ipynb

comment:2 Changed 6 years ago by vbraun

  • Commit set to 3c422083161c46d22eeb1005b785953651bc4a3d

The first commit containts the anything-text-mode integration. Graphics still launches in a separate graphics viewer process.


New commits:

58ff710Add a sage -ipynb option
3c42208IPython notebook with Sage extensions

comment:4 Changed 6 years ago by vbraun

  • Dependencies set to #16746
  • Description modified (diff)

comment:5 Changed 6 years ago by kcrisman

Aww, but sage -ipynb seems so cute. After all, it's the Ipython notebook, not the Notebook Ipython. Maybe both?

comment:6 Changed 6 years ago by vbraun

Its cute. I also wanted to call the Parent object that owns the Singular ring "Frodo". Sometimes, you have to resist being cute ;-)

Since there is bound to be more than one notebook, I think its best to go with sage --notebook-foo or --notebook=foo. With just sage --notebook being some suitable default.

comment:7 Changed 6 years ago by kcrisman

Such as sage --notebook-cloud, for example.

Well, it might still be good to make it more easily discoverable with an alias or something, just because of the English syntax order.

comment:8 Changed 6 years ago by vbraun

  • Description modified (diff)

comment:9 Changed 6 years ago by vbraun

Also, you can lanuch the plain IPython notebook with sage -ipython notebook. The commandline switch for the Sage-enhanced IPython notebook should have more than one character difference ;-)

comment:10 Changed 6 years ago by git

  • Commit changed from 3c422083161c46d22eeb1005b785953651bc4a3d to 95a4ea418c3eae890dc0ae4c50da4420ee0b10ab

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

48a2320Also call graphics.show() in doctest mode
fbf83ebShow output of the lonely generic_graph doctest
a9271f0Fix doctests that have dictionary keys without stable order
3922ed5Reduce doctest precision
b362aa6Display trailing newline in __repr__() output
7de159aFix more random test failures
b02f820Merge #16746 (Improvements to the Sage displayhook)
7db4081Make zeromq and pyzmq standard packages
e7e7f9cAdd 2d graphics to the ipython notebook
95a4ea4Extend IPython notebook templates

comment:11 follow-up: Changed 6 years ago by vbraun

  • Status changed from new to needs_review

2d graphics works, 3d graphics will be displayed as 2d render. IMHO this is good enough for a first stab at it.

I've extended the magic _graphics_() method hook that we already had in Sage so that you can specify a list of file formats that are acceptable as output. The _graphics_() hook then can pick the best choice amongst these possibilities. This works fine for the problem of finding a suitable graphics file format.

The same idea should be extended to text/html/latex output as well. The user specifies which formats he wants (or his frontend can display), and Sage then picks the best representation. I'll work on refactoring the _graphics_() hook into a more general solution (probably called _repr_rich()) on a followup ticket. Once we have this it would be easy to make html/tex output work in a configurable way.

comment:12 in reply to: ↑ 11 Changed 6 years ago by was

Replying to vbraun:

2d graphics works, 3d graphics will be displayed as 2d render. IMHO this is good enough for a first stab at it.

I've extended the magic _graphics_() method hook that we already had in Sage so that you can specify a list of file formats that are acceptable as output. The _graphics_() hook then can pick the best choice amongst these possibilities. This works fine for the problem of finding a suitable graphics file format.

The same idea should be extended to text/html/latex output as well. The user specifies which formats he wants (or his frontend can display), and Sage then picks the best representation. I'll work on refactoring the _graphics_() hook into a more general solution (probably called _repr_rich()) on a followup ticket. Once we have this it would be easy to make html/tex output work in a configurable way.

I'm glad you're working on this, since I've been meaning to do something like this for Sage for a long time, since it is needed for SageMathCloud. Unfortunately, I'm concerned that this approach will cause me more trouble than help, at least for me. With SageMathCloud I have to customize all of the outputs you mention above, and I think the above approach (and what you've implemented in this patch), does not provide a way for me to do it. I would have to directly edit the source code of Sage, which I don't want to do (since it breaks people's custom installs). Right now, SMC monkey patches *all* of the show methods, except for 3d graphics, which can't be monkey patched, due to being in Cython. The idea that "show" can be implemented by saving to a file format, then calling some other function is insufficient, since in some cases one wants to query an object in various ways as part of show. What is really needed is a hook so that users can *replace* the show method altogether at runtime if they want.

So if you can do all of the above, but *also* provide a hook for replacing every show method by one of the user's choosing, especially supporting 3d graphics which can't be monkey patched, then I'm on board.

comment:13 follow-up: Changed 6 years ago by vbraun

Monkey patching stuff left and right isn't going to be maintainable in the long run anyways, so sooner or later you'll have to implement a proper solution. And that means a compute kernel starting with a custom displayhook or piggy-backing on the Sage-IPython ZMQ kernel. I can't see the SMC code so I can't really help with that, but I do intend to write the necessary framework to make implementing the displayhook easy. And powerful enough to include graphics, latex, and html output if desired.

comment:14 in reply to: ↑ 13 Changed 6 years ago by was

Replying to vbraun:

Monkey patching stuff left and right isn't going to be maintainable in the long run anyways,

so sooner or later you'll have to implement a proper solution.

It's actually been very easy to maintain for almost two years now, since Sage's 2d and 3d graphics, etc., are all VERY stable code for the last 3 years. However, I don't like doing it. Amusingly, what you're doing now is the first situation that could make it harder.

And that means a compute kernel starting with a custom displayhook or piggy-backing on the Sage-IPython ZMQ kernel. I can't see the SMC code so I can't really help with that,

All relevant Python code is BSD or GPL'd licensed. The latest versions are always the Python files in ~/.sagemathcloud in any SageMathCloud? project. If you want me to post a snapshot somewhere else I can.

SageMathCloud? makes absolutely no use of ZMQ or IPython. However, it uses a custom displayhook.

but I do intend to write the necessary framework to make implementing the displayhook easy. And powerful enough to include graphics, latex, and html output if desired.

Cool -- that's exactly what I want -- I way to make the necessary framework for implementing the displayhook easy, instead of just replacing show methods.

Anyway, I'm thrilled you're working on this, and I hope you'll keep SMC in mind for your design, so that I can rewrite my code to use your framework instead of monkey patching.

comment:15 Changed 6 years ago by jondo

  • Cc jondo added

comment:16 Changed 6 years ago by slabbe

  • Status changed from needs_review to needs_work
  1. [needs work] The sage -ipython notebook works OK for me. But the command sage -notebook-ipy is broken. There is a tab that opens in the browser but it stays empty. In the command line, it says templates tree.html and error.html and maybe others are missing :
$ sage -notebook-ipy
2014-09-30 23:29:19.288 [SageNotebookApp] Using existing profile dir: u'/Users/slabbe/.sage/ipython-2.2.0/profile_default'
2014-09-30 23:29:19.302 [SageNotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-09-30 23:29:19.345 [SageNotebookApp] Serving notebooks from local directory: /Users/slabbe/.sage/notebooks_ipy
2014-09-30 23:29:19.345 [SageNotebookApp] 0 active kernels 
2014-09-30 23:29:19.345 [SageNotebookApp] The IPython Notebook is running at: http://localhost:8888/
2014-09-30 23:29:19.345 [SageNotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
2014-09-30 23:29:20.051 [tornado.application] ERROR | Uncaught exception GET /tree (::1)
HTTPRequest(protocol='http', host='localhost:8888', method='GET', uri='/tree', version='HTTP/1.1', remote_ip='::1', headers={'Connection': 'keep-alive', 'Accept-Language': 'fr-ca,fr;q=0.8,fr-fr;q=0.6,en-us;q=0.4,en;q=0.2', 'Accept-Encoding': 'gzip, deflate', 'If-None-Match': '"5a5567e3b37b9ccb8e61737610c32e684f6090d4"', 'Host': 'localhost:8888', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:16.0) Gecko/20100101 Firefox/16.0'})
Traceback (most recent call last):
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/tornado-3.1.1-py2.7.egg/tornado/web.py", line 1141, in _when_complete
    callback()
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/tornado-3.1.1-py2.7.egg/tornado/web.py", line 1162, in _execute_method
    self._when_complete(method(*self.path_args, **self.path_kwargs),
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/tornado-3.1.1-py2.7.egg/tornado/web.py", line 2297, in wrapper
    return method(self, *args, **kwargs)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/IPython/html/tree/handlers.py", line 77, in get
    breadcrumbs=breadcrumbs
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/IPython/html/base/handlers.py", line 221, in render_template
    template = self.get_template(name)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/IPython/html/base/handlers.py", line 217, in get_template
    return self.settings['jinja2_env'].get_template(name)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/Jinja2-2.5.5-py2.7.egg/jinja2/environment.py", line 716, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/Jinja2-2.5.5-py2.7.egg/jinja2/environment.py", line 690, in _load_template
    template = self.loader.load(self, name, globals)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/Jinja2-2.5.5-py2.7.egg/jinja2/loaders.py", line 115, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/Jinja2-2.5.5-py2.7.egg/jinja2/loaders.py", line 180, in get_source
    raise TemplateNotFound(template)
TemplateNotFound: tree.html
2014-09-30 23:29:20.060 [tornado.application] ERROR | Uncaught exception in write_error
Traceback (most recent call last):
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/tornado-3.1.1-py2.7.egg/tornado/web.py", line 794, in send_error
    self.write_error(status_code, **kwargs)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/tornado-3.1.1-py2.7.egg/tornado/web.py", line 827, in write_error
    self.finish(self.get_error_html(status_code, **kwargs))
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/IPython/html/base/handlers.py", line 277, in get_error_html
    html = self.render_template('error.html', **ns)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/IPython/html/base/handlers.py", line 221, in render_template
    template = self.get_template(name)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/IPython/html/base/handlers.py", line 217, in get_template
    return self.settings['jinja2_env'].get_template(name)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/Jinja2-2.5.5-py2.7.egg/jinja2/environment.py", line 716, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/Jinja2-2.5.5-py2.7.egg/jinja2/environment.py", line 690, in _load_template
    template = self.loader.load(self, name, globals)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/Jinja2-2.5.5-py2.7.egg/jinja2/loaders.py", line 115, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/Jinja2-2.5.5-py2.7.egg/jinja2/loaders.py", line 180, in get_source
    raise TemplateNotFound(template)
TemplateNotFound: error.html
2014-09-30 23:29:20.063 [tornado.access] ERROR | {
  "Accept-Language": "fr-ca,fr;q=0.8,fr-fr;q=0.6,en-us;q=0.4,en;q=0.2", 
  "Accept-Encoding": "gzip, deflate", 
  "Connection": "keep-alive", 
  "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", 
  "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:16.0) Gecko/20100101 Firefox/16.0", 
  "Host": "localhost:8888", 
  "If-None-Match": "\"5a5567e3b37b9ccb8e61737610c32e684f6090d4\""
}
2014-09-30 23:29:20.064 [tornado.access] ERROR | 500 GET /tree (::1) 16.67ms referer=None

  1. [needs info] When using the sage -ipython notebook which works for me. The Download as > rst throws me the following error:
500 : Internal Server Error
The error was: nbconvert failed: template file "rst" could not be found
  1. [suggestion] I do like sage -ipynb. I do not like sage -notebook-ipy because the part ipy is not natural. I feel I will need to check the doc of sage -advanced each time to confirm the name of the command. If you want the prefix notebook, I would rather suggest :
    sage -notebook-ipython
    
Last edited 6 years ago by slabbe (previous) (diff)

comment:17 Changed 6 years ago by vbraun

You need to run "make" to install the templates

comment:18 Changed 6 years ago by slabbe

You are right. Running "make" fixed the problem. I can now open it and continue the review.

I do not know what goes in this ticket and what doesn't. For instance, as of now I believe the description of the ticket as been fulfilled ("IPython html-based notebook work just like the sage command line", "make zeromq and pyzmq standard packages"). And it could get a positive review.

But it would be nice if output like images would appear in the notebook as it is suggested in the screeshot. Also, I have some problems viewing the documentation. More precisely,

  1. Graphics shows just below the cell which is great: plot(x^2,0,10) but using plot(x^2,0,10).show() opens in an outside window. Is this a bug, or intended?
  1. Animate opens in a outside window as well:
sage: t = var('t')
sage: a = animate((cos(c*pi*t) for c in sxrange(1,2,.2)))
sage: a.show()
  1. 3d Graphics objects plots shows also below the cell as a Tachyon image and running .show opens in a outside window.
  1. I saw you added some links in the Help Menu. Unfortunately, I get 404: Not Found on the six links where one of them is http://localhost:8888/static/a_tour_of_sage/index.html.

comment:19 Changed 6 years ago by vbraun

At least for now, it is intentional that show() opens external programs. For example that is currently the only way to see jmol 3d.

In the long run I think show() should just be removed. Really, it only serves two purposes: easier forkbombing while True: sphere().show() and functions that show plots while not playing nice with the rest of the graphics infrastructure. The only difference between def f(): return plot() and def f(): plot().show() is that the latter can't be combined/superimposed with other plots, a user can't change axis options, you can't reasonably call it in your own code, ...

The other reason is that there is no "stdout for graphics", so to my knowledge the IPython notebook doesn't have a separate output channel for graphics either. Other than returning an image via the displayhook, that is.

Of course the old notebook is entangled with the show() methods, e.g. 3d plots show() is a whole mess of spaghetti code. Fun fact: you can't save a jmol script to a file, you can only generate it on-the-fly inside show(). So my plan would be first to implement _rich_repr_() and then transition other code over.

comment:20 Changed 6 years ago by vbraun

PS: For the documentation to work you need to build it: "make doc"

comment:21 Changed 6 years ago by vbraun

I guess there is IPython.display to display graphics outside of the display hook, will look into that.

comment:22 Changed 6 years ago by git

  • Commit changed from 95a4ea418c3eae890dc0ae4c50da4420ee0b10ab to 487807cdaaa32f8cf8090fa2271d8c5ac762252e

Branch pushed to git repo; I updated commit sha1. New commits:

487807cConsolidate notebook launchers and use argparse

comment:23 Changed 6 years ago by vbraun

The command line option is now --notebook=ipython or --notebook=sagenb (default). This is more consistent / extensible than --notebook-ipython.

Also, switch the notebook argument handling to Python argparse.

comment:24 Changed 6 years ago by vbraun

  • Status changed from needs_work to needs_review

comment:25 Changed 6 years ago by ssinglet

Is there a way to render output cells using Mathjax in the ipython notebook? Basically an equivalent for the "Typeset" toggle button in the sagenb or typeset_mode() in smc. If not, should there be? It seems important to maintain parity in notebooks for some things like formatted expressions.

Last edited 6 years ago by ssinglet (previous) (diff)

comment:26 Changed 6 years ago by ssinglet

Unexpected behavior: 'bang' shell commands send output to terminal rather than ipython notebook output cell. Eg: In [2]: !pwd has no output cell, but it's echoed to STDOUT. Is this intentional?

comment:27 Changed 6 years ago by ssinglet

[Sorry if I'm violating sage-trac etiquette; is it preferable to add several comments, each with a single topic/question, or keep several things together in a single comment? Also, my comments could be considered feature requests or enhancements and therefore inappropriate after a review is requested. Please let me know...]

I've been using %load sage in the standard ipython notebook for some time and have several existing .ipynb notebooks. Currently, it seems these must be moved to the ~/.sage/notebooks_ipy directory (or maybe a tmp directory if --nodotsage is given). I think this should either be documented or (preferably) sage --notebook=ipython should include .ipynb files found in the working directory at runtime (similar to the standard ipython notebook localhost:8888/tree).

EDIT: Actually the directory is documented in the startup message.

Last edited 6 years ago by ssinglet (previous) (diff)

comment:28 Changed 6 years ago by vbraun

  • Typeset output will be in the next iteration.
  • The standard IPython notebook command line options work, so you can run
    ./sage --notebook=ipython --notebook-dir=~/MyNotebooks
    
    if you want a different one.

comment:29 Changed 6 years ago by git

  • Commit changed from 487807cdaaa32f8cf8090fa2271d8c5ac762252e to 282f4fab75cdad040af03705be15fce58a31f1f9

Branch pushed to git repo; I updated commit sha1. New commits:

f248f20Switch ipy -> ipython everywhere
282f4faSplit the SageInteractiveShell into terminal and notebook versions

comment:30 Changed 6 years ago by vbraun

Bang specials (!ls) work now.

comment:31 Changed 6 years ago by vdelecroix

  • Cc vdelecroix added

comment:32 Changed 6 years ago by egourgoulhon

Hi, I've just tried it (building it by "make" after a merge of the ticket branch into Sage 6.4-beta4). It works very nicely! Just missing the MathJax typeset output, but I understand this is for the next step. In my opinion (but I am not a IPython notebook expert), it should get a positive review.

Last edited 6 years ago by egourgoulhon (previous) (diff)

comment:33 follow-up: Changed 6 years ago by slabbe

The buildbot says the following tests fails:

sage -t src/sage/crypto/mq/sr.py  # 5 doctests failed
sage -t src/sage/modular/modform/numerical.py  # 2 doctests failed
sage -t src/sage/repl/notebook_ipython.py  # 9 doctests failed
sage -t src/sage/rings/polynomial/multi_polynomial_sequence.py  # 9 doctests failed
sage -t src/sage/rings/polynomial/pbori.pyx  # Killed due to segmentation fault
sage -t src/sage/rings/polynomial/polynomial_element.pyx  # 2 doctests failed
sage -t src/sage/rings/real_double.pyx  # 2 doctests failed

I tested the same files on my machine and I get:

sage -t src/sage/crypto/mq/sr.py  # Killed due to bus error
sage -t src/sage/repl/notebook_ipython.py  # 1 doctest failed
sage -t src/sage/rings/polynomial/multi_polynomial_sequence.py  # 9 doctests failed
sage -t src/sage/rings/polynomial/pbori.pyx  # Killed due to bus error
sage -t src/sage/rings/polynomial/polynomial_element.pyx  # 6 doctests failed
sage -t src/sage/rings/real_double.pyx  # 2 doctests failed

Full log is available here: http://boxen.math.washington.edu/home/slabbe/trac_16996.log

Note: the link is broken. I don't know why. I scp the file on my account on the server sage.math.washington.edu as before. What is the url of it then?

comment:34 in reply to: ↑ 33 Changed 6 years ago by egourgoulhon

Replying to slabbe:

Hi Sébastien,

On my machine, with branch u/vbraun/sage_ipynb merged into sage 6.4 beta4, all the above tests passed. Which version of Sage are you using ?

Last edited 6 years ago by egourgoulhon (previous) (diff)

comment:35 Changed 6 years ago by vbraun

We don't serve all home directories any more. Contact William if you want yours to be whitelisted.

comment:36 Changed 6 years ago by vbraun

PS: The branch doesn't include the SAGE_UPGRADING fix so you probably have to make distclean && make to compile it correctly.

comment:37 Changed 6 years ago by jhpalmieri

  • The example in cmdline2argspec is kind of ridiculous. I would just delete it.
  • Should the usage string produced by sage --notebook -h actually say what the default notebook is? I think so: the default should be clearly documented without reading the source code.
  • It seems odd that sage --notebook --notebook sagenb is valid syntax, but I don't really care.
  • Do we need to deprecate the "insecure" notebook? Again, I don't really care, but I thought I would ask.

I don't know enough about the graphics/plotting interface to know if the changes here are sensible. Anyone else? My only impression is that the graphics_file module should have more documentation: I don't know at a glance why or how to use it. The doctest coverage for that file is bad, also. Everything else looks okay, although I haven't looked in great detail at all of it.

comment:38 Changed 6 years ago by git

  • Commit changed from 282f4fab75cdad040af03705be15fce58a31f1f9 to 75bc4551aa2cbe49fedac881f560248292185364

Branch pushed to git repo; I updated commit sha1. New commits:

9f4b1c8Remove left-over attempt at doctests
75bc455Mention the default notebook in the help

comment:39 follow-up: Changed 6 years ago by vbraun

  • Removed the example, that was from when I was trying to doctest it (turns out src/bin scripts are not doctested, but thats another issue)
  • Added the default to the help string.
  • ls --color=never --color=always is valid as well. This is how argparse operates.
  • Nothing changed with the insecure notebook, I just consolidated all launcher scripts into one. That doesn't change the fact that sage -notebook and sage -inotebook launch the same thing, secure=False is the default.
  • The graphics_file needs to be refactored to support more than just raster graphics anyways (see discussion), so I didn't document it all. In any case its a displayhook internal.

comment:40 Changed 6 years ago by git

  • Commit changed from 75bc4551aa2cbe49fedac881f560248292185364 to ec42cdfb5710225b820f58e242d05326a1a3a494

Branch pushed to git repo; I updated commit sha1. New commits:

ec42cdfdeprecate the -inotebook option

comment:41 Changed 6 years ago by vbraun

I've added a (deprecated) to the inotebook option, hopefully we can get rid of it in the future.

comment:42 in reply to: ↑ 39 Changed 6 years ago by slabbe

Replying to vbraun:

  • Added the default to the help string.

Can the default (sagenb vs ipython) be changed by the user? If yes, how?

Last edited 6 years ago by slabbe (previous) (diff)

comment:43 Changed 6 years ago by slabbe

It seems there is a space missing in the usage line :sage-notebook instead of sage -notebook.

$ sage -notebook -h
usage: sage-notebook [-h] [--log LOG] [--notebook [NOTEBOOK]]
$ sage -docbuild -h
Usage: sage -docbuild [OPTIONS] DOCUMENT (FORMAT | COMMAND)

I also wonder why -n is not listed first on the line (compare with sage -docbuild -h):

  --notebook [NOTEBOOK], -n [NOTEBOOK], -notebook [NOTEBOOK]

To me it is an important feature that sage -ipython notebook directly lands in the present working directory. And I will be disappointed if sage -notebook=ipython does not. What is the opinion of other users about this?

I am sory to say this, but to me if we default to --notebook-dir=DOT_SAGE/notebooks_ipython we follow stupidly a bad design choice of the previous notebook.

The standard IPython notebook command line options work

In any case, should we document in sage -notebook -h that the long list of options of sage -ipython notebook -h can be used?

Last edited 6 years ago by slabbe (previous) (diff)

comment:44 Changed 6 years ago by slabbe

If DOT_SAGE/notebooks_ipython dir exists, sage -t src/sage/repl/notebook_ipython.py returns All tests passed!. But if the dir does not exist, then one test is failing:

sage -t src/sage/repl/notebook_ipython.py  # 1 doctest failed   
**********************************************************************                     
File "src/sage/repl/notebook_ipython.py", line 63, in sage.repl.notebook_ipython.SageNotebookApp.load_config_file
Failed example:
    app.load_config_file()    # random output                                                           
Exception raised:
    Traceback (most recent call last):
    ...
    TraitError: No such notebook dir: u'/Users/slabbe/.sage/notebooks_ipython' 

comment:45 Changed 6 years ago by vbraun

The default can't be changed without editing the source. You can always make an alias if its too much effort to type out.

The notebook launch script is sage-notebook, so this is the name that appears in the usage: help. We could override it but IMHO that would be even more confusing. Can't really be fixed without #21.

comment:46 Changed 6 years ago by git

  • Commit changed from ec42cdfb5710225b820f58e242d05326a1a3a494 to 11326b6283478ebf366fed9abc868434ee9f88c8

Branch pushed to git repo; I updated commit sha1. New commits:

9d034ccMore command line help description
11326b6Make doctests work even if you never ran the ipython notebook before

comment:47 follow-up: Changed 6 years ago by vbraun

  • The order of --notebook [NOTEBOOK], -n [NOTEBOOK] is fixed in sage-notebook and I prefer it that way (most descriptive first).
  • I also think its unproductive to start a discussion about whether or not we should start in a particular directory. This is what the old notebook does, if you don't like it then open a ticket or post on sage-devel. I don't really care either way, but the behavior has to match.
  • I fixed the doctest error when you never ran the ipython notebook before.

comment:48 in reply to: ↑ 47 Changed 6 years ago by slabbe

  • I also think its unproductive to start a discussion about whether or not we should start in a particular directory.

Ok I agree. This should be discussed on sage-devel.

I agree with John Palmieri about the doctest coverage in the graphics_file class. I think it should be 100% doctested and should not be too long to do so. Other than that, to me the ticket can get a positive review. (Note: I will not have much internet time in the next few days.)

comment:49 Changed 6 years ago by vbraun

I said already that the graphics_file module needs to be rewritten to also allow for other forms of rich output. I'm not going to document it and then erase it in the next ticket.

comment:50 Changed 6 years ago by git

  • Commit changed from 11326b6283478ebf366fed9abc868434ee9f88c8 to c54edb59a9c46c15dbe8a529efafe9c0cb2b17c9

Branch pushed to git repo; I updated commit sha1. New commits:

c54edb5Better notebook-specific help

comment:51 follow-up: Changed 6 years ago by slabbe

  • Reviewers set to Karl-Dieter Crisman, Sébastien Labbé, John Palmieri, Eric Gourgoulhon, ssinglet
  • Status changed from needs_review to positive_review

I give this a positive review.

Unfinished discussions (reported later) concerns:

  • the default directory for sage -notebook=ipython to be discussed on sage-devel
  • A new ticket should be created for the graphics_file module to be rewritten

comment:52 Changed 6 years ago by vbraun

  • Reviewers changed from Karl-Dieter Crisman, Sébastien Labbé, John Palmieri, Eric Gourgoulhon, ssinglet to Karl-Dieter Crisman, Sébastien Labbé, John Palmieri, Eric Gourgoulhon, Steve Singleton

comment:53 Changed 6 years ago by vbraun

  • Branch changed from u/vbraun/sage_ipynb to c54edb59a9c46c15dbe8a529efafe9c0cb2b17c9
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:54 in reply to: ↑ 51 Changed 6 years ago by slabbe

  • Commit c54edb59a9c46c15dbe8a529efafe9c0cb2b17c9 deleted

Unfinished discussions (reported later) concerns:

  • the default directory for sage -notebook=ipython to be discussed on sage-devel

This is now #17203.

Volker I am sure you can fix #17203 much quicklier than me since you put your hands in those files recently. Will you have time to work on #17203 in the next days?

Sébastien

comment:55 follow-up: Changed 6 years ago by kcrisman

See https://groups.google.com/d/msg/sage-release/xgmJ3nAcUOY/d9-MZLTyowYJ for some regressions/incompatible changes in the syntax for command line launch of sagenb, presumably introduced in this ticket.

comment:56 in reply to: ↑ 55 Changed 6 years ago by slabbe

Replying to kcrisman:

some regressions/incompatible changes in the syntax for command line launch of sagenb, presumably introduced in this ticket.

Should that be considered as a blocker ?

See also #17281 for another (easy) follow up ticket.

comment:57 Changed 6 years ago by vbraun

this ticket is closed. Followup is #17280

Note: See TracTickets for help on using tickets.