Debian Codegraph @

docs/source/whatsnew/version1.0.rst

raw
1 ============
2 1.0 Series
3 ============
4
5 Release 1.0.0: An Afternoon Hack
6 ================================
7
8
9 IPython 1.0 requires Python ≥ 2.6.5 or ≥ 3.2.1.
10 It does not support Python 3.0, 3.1, or 2.5.
11
12 This is a big release. The principal milestone is the addition of :mod:`IPython.nbconvert`,
13 but there has been a great deal of work improving all parts of IPython as well.
14
15 The previous version (0.13) was released on June 30, 2012,
16 and in this development cycle we had:
17
18 - ~12 months of work.
19 - ~700 pull requests merged.
20 - ~600 issues closed (non-pull requests).
21 - contributions from ~150 authors.
22 - ~4000 commits.
23
24 The amount of work included in this release is so large that we can only cover
25 here the main highlights; please see our :ref:`detailed release statistics
26 <issues_list_100>` for links to every issue and pull request closed on GitHub
27 as well as a full list of individual contributors.
28 It includes
29
30 Reorganization
31 --------------
32
33 There have been two major reorganizations in IPython 1.0:
34
35 - Added :mod:`IPython.kernel` for all kernel-related code.
36 This means that :mod:`IPython.zmq` has been removed,
37 and much of it is now in :mod:`IPython.kernel.zmq`,
38 some of it being in the top-level :mod:`IPython.kernel`.
39 - We have removed the `frontend` subpackage,
40 as it caused unnecessary depth. So what was :mod:`IPython.frontend.qt`
41 is now :mod:`IPython.qt`, and so on. The one difference is that
42 the notebook has been further flattened, so that
43 :mod:`IPython.frontend.html.notebook` is now just `IPython.html`.
44 There is a shim module, so :mod:`IPython.frontend` is still
45 importable in 1.0, but there will be a warning.
46 - The IPython sphinx directives are now installed in :mod:`IPython.sphinx`,
47 so they can be imported by other projects.
48
49
50 Public APIs
51 -----------
52
53 For the first time since 0.10 (sorry, everyone),
54 there is an official public API for starting IPython:
55
56 .. sourcecode:: python
57
58 from IPython import start_ipython
59 start_ipython()
60
61 This is what packages should use that start their own IPython session,
62 but don't actually want embedded IPython (most cases).
63 :func:`IPython.embed()` is used for embedding IPython into the calling namespace,
64 similar to calling :func:`Pdb.set_trace`, whereas :func:`start_ipython`
65 will start a plain IPython session, loading config and startup files as normal.
66
67 We also have added:
68
69 .. sourcecode:: python
70
71 from IPython import get_ipython
72
73
74 Which is a *library* function for getting the current IPython instance,
75 and will return :py:data:`None` if no IPython instance is running.
76 This is the official way to check whether your code is called from inside an IPython session.
77 If you want to check for IPython without unnecessarily importing IPython,
78 use this function:
79
80 .. sourcecode:: python
81
82 def get_ipython():
83 """return IPython instance if there is one, None otherwise"""
84 import sys
85 if "IPython" in sys.modules:
86 import IPython
87 return IPython.get_ipython()
88
89 Core
90 ----
91
92 - The input transformation framework has been reworked. This fixes some corner
93 cases, and adds more flexibility for projects which use IPython, like SymPy &
94 SAGE. For more details, see :doc:`/config/inputtransforms`.
95 - Exception types can now be displayed with a custom traceback, by defining a
96 ``_render_traceback_()`` method which returns a list of strings, each
97 containing one line of the traceback.
98 - A new command, ``ipython history trim`` can be used to delete everything but
99 the last 1000 entries in the history database.
100 - ``__file__`` is defined in both config files at load time,
101 and ``.ipy`` files executed with ``%run``.
102 - ``%logstart`` and ``%logappend`` are no longer broken.
103 - Add glob expansion for ``%run``, e.g. ``%run -g script.py *.txt``.
104 - Expand variables (``$foo``) in Cell Magic argument line.
105 - By default, :command:`iptest` will exclude various slow tests.
106 All tests can be run with :command:`iptest --all`.
107 - SQLite history can be disabled in the various cases that it does not behave well.
108 - ``%edit`` works on interactively defined variables.
109 - editor hooks have been restored from quarantine, enabling TextMate as editor,
110 etc.
111 - The env variable PYTHONSTARTUP is respected by IPython.
112 - The ``%matplotlib`` magic was added, which is like the old ``%pylab`` magic,
113 but it does not import anything to the interactive namespace.
114 It is recommended that users switch to ``%matplotlib`` and explicit imports.
115 - The ``--matplotlib`` command line flag was also added. It invokes the new
116 ``%matplotlib`` magic and can be used in the same way as the old ``--pylab``
117 flag. You can either use it by itself as a flag (``--matplotlib``), or you
118 can also pass a backend explicitly (``--matplotlib qt`` or
119 ``--matplotlib=wx``, etc).
120
121
122 Backwards incompatible changes
123 ******************************
124
125 - Calling :meth:`InteractiveShell.prefilter` will no longer perform static
126 transformations - the processing of escaped commands such as ``%magic`` and
127 ``!system``, and stripping input prompts from code blocks. This functionality
128 was duplicated in :mod:`IPython.core.inputsplitter`, and the latter version
129 was already what IPython relied on. A new API to transform input will be ready
130 before release.
131 - Functions from :mod:`IPython.lib.inputhook` to control integration with GUI
132 event loops are no longer exposed in the top level of :mod:`IPython.lib`.
133 Code calling these should make sure to import them from
134 :mod:`IPython.lib.inputhook`.
135 - For all kernel managers, the ``sub_channel`` attribute has been renamed to
136 ``iopub_channel``.
137 - Users on Python versions before 2.6.6, 2.7.1 or 3.2 will now need to call
138 :func:`IPython.utils.doctestreload.doctest_reload` to make doctests run
139 correctly inside IPython. Python releases since those versions are unaffected.
140 For details, see :ghpull:`3068` and `Python issue 8048 <http://bugs.python.org/issue8048>`_.
141 - The ``InteractiveShell.cache_main_mod()`` method has been removed, and
142 :meth:`~IPython.core.interactiveshell.InteractiveShell.new_main_mod` has a
143 different signature, expecting a filename where earlier versions expected
144 a namespace. See :ghpull:`3555` for details.
145 - The short-lived plugin system has been removed. Extensions are the way to go.
146
147
148 .. _nbconvert1:
149
150 NbConvert
151 ---------
152
153 The major milestone for IPython 1.0 is the addition of :mod:`IPython.nbconvert` - tools for converting
154 IPython notebooks to various other formats.
155
156 .. warning::
157
158 nbconvert is α-level preview code in 1.0
159
160 To use nbconvert to convert various file formats::
161
162 ipython nbconvert --to html *.ipynb
163
164 See ``ipython nbconvert --help`` for more information.
165 nbconvert depends on `pandoc`_ for many of the translations to and from various formats.
166
167 .. _pandoc: http://johnmacfarlane.net/pandoc/
168
169 Notebook
170 --------
171
172 Major changes to the IPython Notebook in 1.0:
173
174 - The notebook is now autosaved, by default at an interval of two minutes.
175 When you press 'save' or Ctrl-S, a *checkpoint* is made, in a hidden folder.
176 This checkpoint can be restored, so that the autosave model is strictly safer
177 than traditional save. If you change nothing about your save habits,
178 you will always have a checkpoint that you have written,
179 and an autosaved file that is kept up to date.
180 - The notebook supports :func:`raw_input` / :func:`input`, and thus also ``%debug``,
181 and many other Python calls that expect user input.
182 - You can load custom javascript and CSS in the notebook by editing the files
183 :file:`$(ipython locate profile)/static/custom/custom.{js,css}`.
184 - Add ``%%html``, ``%%svg``, ``%%javascript``, and ``%%latex`` cell magics
185 for writing raw output in notebook cells.
186 - add a redirect handler and anchors on heading cells, so you can link
187 across notebooks, directly to heading cells in other notebooks.
188 - Images support width and height metadata,
189 and thereby 2x scaling (retina support).
190 - ``_repr_foo_`` methods can return a tuple of (data, metadata),
191 where metadata is a dict containing metadata about the displayed object.
192 This is used to set size, etc. for retina graphics. To enable retina matplotlib figures,
193 simply set ``InlineBackend.figure_format = 'retina'`` for 2x PNG figures,
194 in your :ref:`IPython config file <config_overview>` or via the ``%config`` magic.
195 - Add display.FileLink and FileLinks for quickly displaying HTML links to local files.
196 - Cells have metadata, which can be edited via cell toolbars.
197 This metadata can be used by external code (e.g. reveal.js or exporters),
198 when examining the notebook.
199 - Fix an issue parsing LaTeX in markdown cells, which required users to type ``\\\``,
200 instead of ``\\``.
201 - Notebook templates are rendered with Jinja instead of Tornado.
202 - ``%%file`` has been renamed ``%%writefile`` (``%%file`` is deprecated).
203 - ANSI (and VT100) color parsing has been improved in both performance and
204 supported values.
205 - The static files path can be found as ``IPython.html.DEFAULT_STATIC_FILES_PATH``,
206 which may be changed by package managers.
207 - IPython's CSS is installed in :file:`static/css/style.min.css`
208 (all style, including bootstrap), and :file:`static/css/ipython.min.css`,
209 which only has IPython's own CSS. The latter file should be useful for embedding
210 IPython notebooks in other pages, blogs, etc.
211 - The Print View has been removed. Users are encouraged to test :ref:`ipython
212 nbconvert <nbconvert1>` to generate a static view.
213
214 Javascript Components
215 *********************
216
217 The javascript components used in the notebook have been updated significantly.
218
219 - updates to jQuery (2.0) and jQueryUI (1.10)
220 - Update CodeMirror to 3.14
221 - Twitter Bootstrap (2.3) for layout
222 - Font-Awesome (3.1) for icons
223 - highlight.js (7.3) for syntax highlighting
224 - marked (0.2.8) for markdown rendering
225 - require.js (2.1) for loading javascript
226
227 Some relevant changes that are results of this:
228
229 - Markdown cells now support GitHub-flavored Markdown (GFM),
230 which includes `````python`` code blocks and tables.
231 - Notebook UI behaves better on more screen sizes.
232 - Various code cell input issues have been fixed.
233
234
235 Kernel
236 ------
237
238 The kernel code has been substantially reorganized.
239
240 New features in the kernel:
241
242 - Kernels support ZeroMQ IPC transport, not just TCP
243 - The message protocol has added a top-level metadata field,
244 used for information about messages.
245 - Add a `data_pub` message that functions much like `display_pub`,
246 but publishes raw (usually pickled) data, rather than representations.
247 - Ensure that ``sys.stdout.encoding`` is defined in Kernels.
248 - Stdout from forked subprocesses should be forwarded to frontends (instead of crashing).
249
250 IPEP 13
251 *******
252
253 The KernelManager has been split into a :class:`~.KernelManager` and a :class:`~.KernelClient`.
254 The Manager owns a kernel and starts / signals / restarts it. There is always zero or one
255 KernelManager per Kernel. Clients communicate with Kernels via zmq channels,
256 and there can be zero-to-many Clients connected to a Kernel at any given time.
257
258 The KernelManager now automatically restarts the kernel when it dies,
259 rather than requiring user input at the notebook or QtConsole UI
260 (which may or may not exist at restart time).
261
262 In-process kernels
263 ******************
264
265 The Python-language frontends, particularly the Qt console, may now communicate
266 with in-process kernels, in addition to the traditional out-of-process
267 kernels. An in-process kernel permits direct access to the kernel namespace,
268 which is necessary in some applications. It should be understood, however, that
269 the in-process kernel is not robust to bad user input and will block the main
270 (GUI) thread while executing. Developers must decide on a case-by-case basis
271 whether this tradeoff is appropriate for their application.
272
273
274
275 Parallel
276 --------
277
278 IPython.parallel has had some refactoring as well.
279 There are many improvements and fixes, but these are the major changes:
280
281 - Connections have been simplified. All ports and the serialization in use
282 are written to the connection file, rather than the initial two-stage system.
283 - Serialization has been rewritten, fixing many bugs and dramatically improving
284 performance serializing large containers.
285 - Load-balancing scheduler performance with large numbers of tasks has been dramatically improved.
286 - There should be fewer (hopefully zero) false-positives for engine failures.
287 - Increased compatibility with various use cases that produced serialization / argument errors
288 with map, etc.
289 - The controller can attempt to resume operation if it has crashed,
290 by passing ``ipcontroller --restore``.
291 - Engines can monitor the Hub heartbeat, and shutdown if the Hub disappears for too long.
292 - add HTCondor support in launchers
293
294
295 QtConsole
296 ---------
297
298 Various fixes, including improved performance with lots of text output,
299 and better drag and drop support.
300 The initial window size of the qtconsole is now configurable via ``IPythonWidget.width``
301 and ``IPythonWidget.height``.
302