Show More
@@ -4,4 +4,6 b'' | |||
|
4 | 4 | autoreload |
|
5 | 5 | ========== |
|
6 | 6 | |
|
7 | .. magic:: autoreload | |
|
8 | ||
|
7 | 9 | .. automodule:: IPython.extensions.autoreload |
@@ -58,7 +58,7 b' Should behave as expected in the IPython REPL::' | |||
|
58 | 58 | |
|
59 | 59 | You can use the ``c.InteractiveShell.autoawait`` configuration option and set it |
|
60 | 60 | to :any:`False` to deactivate automatic wrapping of asynchronous code. You can |
|
61 |
also use the :magic:` |
|
|
61 | also use the :magic:`autoawait` magic to toggle the behavior at runtime:: | |
|
62 | 62 | |
|
63 | 63 | In [1]: %autoawait False |
|
64 | 64 | |
@@ -127,7 +127,7 b' Effects on IPython.embed()' | |||
|
127 | 127 | IPython core being asynchronous, the use of ``IPython.embed()`` will now require |
|
128 | 128 | a loop to run. By default IPython will use a fake coroutine runner which should |
|
129 | 129 | allow ``IPython.embed()`` to be nested. Though this will prevent usage of the |
|
130 |
|
|
|
130 | :magic:`autoawait` feature when using IPython embed. | |
|
131 | 131 | |
|
132 | 132 | You can set explicitly a coroutine runner for ``embed()`` if you desire to run |
|
133 | 133 | asynchronous code, the exact behavior is though undefined. |
@@ -230,11 +230,12 b' Update ipykernel to version 5.0 or greater::' | |||
|
230 | 230 | # or |
|
231 | 231 | conda install ipykernel ipython --upgrade |
|
232 | 232 | |
|
233 |
This should automatically enable |
|
|
234 |
IPython, all code runs on ``asyncio`` eventloop, so creating a loop by |
|
|
235 |
not work, including with magics like |
|
|
236 |
the eventloop themselves. In cases like these you can |
|
|
237 | `nest_asyncio <https://github.com/erdewit/nest_asyncio>`_ and follow `this discussion | |
|
233 | This should automatically enable :magic:`autoawait` integration. Unlike | |
|
234 | terminal IPython, all code runs on ``asyncio`` eventloop, so creating a loop by | |
|
235 | hand will not work, including with magics like :magic:`%run` or other | |
|
236 | frameworks that create the eventloop themselves. In cases like these you can | |
|
237 | try to use projects like `nest_asyncio | |
|
238 | <https://github.com/erdewit/nest_asyncio>`_ and follow `this discussion | |
|
238 | 239 | <https://github.com/jupyter/notebook/issues/3397#issuecomment-419386811>`_ |
|
239 | 240 | |
|
240 | 241 | Difference between terminal IPython and IPykernel |
@@ -242,7 +243,7 b' Difference between terminal IPython and IPykernel' | |||
|
242 | 243 | |
|
243 | 244 | The exact asynchronous code running behavior varies between Terminal IPython and |
|
244 | 245 | IPykernel. The root cause of this behavior is due to IPykernel having a |
|
245 |
*persistent* |
|
|
246 | *persistent* `asyncio` loop running, while Terminal IPython starts and stops a | |
|
246 | 247 | loop for each code block. This can lead to surprising behavior in some case if |
|
247 | 248 | you are used to manipulate asyncio loop yourself, see for example |
|
248 | 249 | :ghissue:`11303` for a longer discussion but here are some of the astonishing |
@@ -114,10 +114,10 b' Non-Asynchronous code' | |||
|
114 | 114 | ~~~~~~~~~~~~~~~~~~~~~ |
|
115 | 115 | |
|
116 | 116 | As the internal API of IPython are now asynchronous, IPython need to run under |
|
117 |
an even loop. In order to allow many workflow, (like using the |
|
|
118 |
or copy_pasting code that explicitly starts/stop event loop), when |
|
|
119 |
is detected as not being asynchronous, IPython code is advanced |
|
|
120 | pseudo-synchronous runner, and will not may not advance pending tasks. | |
|
117 | an even loop. In order to allow many workflow, (like using the :magic:`%run` | |
|
118 | magic, or copy_pasting code that explicitly starts/stop event loop), when | |
|
119 | top-level code is detected as not being asynchronous, IPython code is advanced | |
|
120 | via a pseudo-synchronous runner, and will not may not advance pending tasks. | |
|
121 | 121 | |
|
122 | 122 | Change to Nested Embed |
|
123 | 123 | ~~~~~~~~~~~~~~~~~~~~~~ |
@@ -151,11 +151,17 b' minrk, njsmith, pganssle, tacaswell, takluyver , vidartf ... And many others.' | |||
|
151 | 151 | Autoreload Improvement |
|
152 | 152 | ---------------------- |
|
153 | 153 | |
|
154 | The magic ``%autoreload 2`` now captures new methods added to classes. Earlier, only methods existing as of the initial import were being tracked and updated. | |
|
154 | The magic :magic:`%autoreload 2 <autoreload>` now captures new methods added to | |
|
155 | classes. Earlier, only methods existing as of the initial import were being | |
|
156 | tracked and updated. | |
|
155 | 157 | |
|
156 |
This new feature helps dual environment development - Jupyter+IDE - where the |
|
|
158 | This new feature helps dual environment development - Jupyter+IDE - where the | |
|
159 | code gradually moves from notebook cells to package files, as it gets | |
|
160 | structured. | |
|
157 | 161 | |
|
158 |
**Example**: An instance of the class `MyClass` will be able to access the |
|
|
162 | **Example**: An instance of the class ``MyClass`` will be able to access the | |
|
163 | method ``cube()`` after it is uncommented and the file ``file1.py`` saved on | |
|
164 | disk. | |
|
159 | 165 | |
|
160 | 166 | |
|
161 | 167 | ..code:: |
@@ -191,13 +197,14 b' Misc' | |||
|
191 | 197 | The autoindent feature that was deprecated in 5.x was re-enabled and |
|
192 | 198 | un-deprecated in :ghpull:`11257` |
|
193 | 199 | |
|
194 | Make ``%run -n -i ...`` work correctly. Earlier, if ``%run`` was passed both arguments, ``-n`` would be silently ignored. See :ghpull:`10308` | |
|
200 | Make :magic:`%run -n -i ... <run>` work correctly. Earlier, if :magic:`%run` was | |
|
201 | passed both arguments, ``-n`` would be silently ignored. See :ghpull:`10308` | |
|
195 | 202 | |
|
196 | 203 | |
|
197 | The ``%%script`` (as well as ``%%bash``, ``ruby``... ) cell magics now raise | |
|
198 | by default if the return code of the given code is non-zero (thus halting | |
|
199 | execution of further cells in a notebook). The behavior can be disable by | |
|
200 | passing the ``--no-raise-error`` flag. | |
|
204 | The :cellmagic:`%%script`` (as well as :cellmagic:`%%bash``, | |
|
205 | :cellmagic:`%%ruby``... ) cell magics now raise by default if the return code of | |
|
206 | the given code is non-zero (thus halting execution of further cells in a | |
|
207 | notebook). The behavior can be disable by passing the ``--no-raise-error`` flag. | |
|
201 | 208 | |
|
202 | 209 | |
|
203 | 210 | Deprecations |
@@ -19,6 +19,9 b' Authors' | |||
|
19 | 19 | |
|
20 | 20 | from docutils import nodes, utils |
|
21 | 21 | from docutils.parsers.rst.roles import set_classes |
|
22 | from sphinx.util.logging import getLogger | |
|
23 | ||
|
24 | info = getLogger(__name__).info | |
|
22 | 25 | |
|
23 | 26 | def make_link_node(rawtext, app, type, slug, options): |
|
24 | 27 | """Create a link to a github resource. |
@@ -75,7 +78,7 b' def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):' | |||
|
75 | 78 | prb = inliner.problematic(rawtext, rawtext, msg) |
|
76 | 79 | return [prb], [msg] |
|
77 | 80 | app = inliner.document.settings.env.app |
|
78 |
# |
|
|
81 | #info('issue %r' % text) | |
|
79 | 82 | if 'pull' in name.lower(): |
|
80 | 83 | category = 'pull' |
|
81 | 84 | elif 'issue' in name.lower(): |
@@ -105,7 +108,7 b' def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):' | |||
|
105 | 108 | :param content: The directive content for customization. |
|
106 | 109 | """ |
|
107 | 110 | app = inliner.document.settings.env.app |
|
108 |
# |
|
|
111 | #info('user link %r' % text) | |
|
109 | 112 | ref = 'https://www.github.com/' + text |
|
110 | 113 | node = nodes.reference(rawtext, text, refuri=ref, **options) |
|
111 | 114 | return [node], [] |
@@ -126,7 +129,7 b' def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):' | |||
|
126 | 129 | :param content: The directive content for customization. |
|
127 | 130 | """ |
|
128 | 131 | app = inliner.document.settings.env.app |
|
129 |
# |
|
|
132 | #info('user link %r' % text) | |
|
130 | 133 | try: |
|
131 | 134 | base = app.config.github_project_url |
|
132 | 135 | if not base: |
@@ -146,7 +149,7 b' def setup(app):' | |||
|
146 | 149 | |
|
147 | 150 | :param app: Sphinx application context. |
|
148 | 151 | """ |
|
149 |
|
|
|
152 | info('Initializing GitHub plugin') | |
|
150 | 153 | app.add_role('ghissue', ghissue_role) |
|
151 | 154 | app.add_role('ghpull', ghissue_role) |
|
152 | 155 | app.add_role('ghuser', ghuser_role) |
@@ -37,9 +37,10 b' class CellMagicRole(LineMagicRole):' | |||
|
37 | 37 | |
|
38 | 38 | def setup(app): |
|
39 | 39 | app.add_object_type('magic', 'magic', 'pair: %s; magic command', parse_magic) |
|
40 | StandardDomain.roles['magic'] = LineMagicRole() | |
|
40 | app.add_role_to_domain('std', 'magic', LineMagicRole(), override=True) | |
|
41 | ||
|
41 | 42 | app.add_object_type('cellmagic', 'cellmagic', 'pair: %s; cell magic', parse_cell_magic) |
|
42 | StandardDomain.roles['cellmagic'] = CellMagicRole() | |
|
43 | app.add_role_to_domain('std', 'cellmagic', CellMagicRole(), override=True) | |
|
43 | 44 | |
|
44 | 45 | metadata = {'parallel_read_safe': True, 'parallel_write_safe': True} |
|
45 | 46 | return metadata |
General Comments 0
You need to be logged in to leave comments.
Login now