Show More
@@ -174,7 +174,7 b' class Application(SingletonConfigurable):' | |||||
174 | _log_handler.setFormatter(_log_formatter) |
|
174 | _log_handler.setFormatter(_log_formatter) | |
175 |
|
175 | |||
176 |
|
176 | |||
177 | log = Instance(logging.Logger) |
|
177 | log = Instance(logging.Logger, allow_none=True) | |
178 | def _log_default(self): |
|
178 | def _log_default(self): | |
179 | """Start logging for this application. |
|
179 | """Start logging for this application. | |
180 |
|
180 |
@@ -34,7 +34,7 b' class MultipleInstanceError(ConfigurableError):' | |||||
34 | class Configurable(HasTraits): |
|
34 | class Configurable(HasTraits): | |
35 |
|
35 | |||
36 | config = Instance(Config, (), {}) |
|
36 | config = Instance(Config, (), {}) | |
37 | parent = Instance('IPython.config.configurable.Configurable') |
|
37 | parent = Instance('IPython.config.configurable.Configurable', allow_none=True) | |
38 |
|
38 | |||
39 | def __init__(self, **kwargs): |
|
39 | def __init__(self, **kwargs): | |
40 | """Create a configurable given a config config. |
|
40 | """Create a configurable given a config config. | |
@@ -372,7 +372,7 b' class LoggingConfigurable(Configurable):' | |||||
372 | is to get the logger from the currently running Application. |
|
372 | is to get the logger from the currently running Application. | |
373 | """ |
|
373 | """ | |
374 |
|
374 | |||
375 | log = Instance('logging.Logger') |
|
375 | log = Instance('logging.Logger', allow_none=True) | |
376 | def _log_default(self): |
|
376 | def _log_default(self): | |
377 | from IPython.utils import log |
|
377 | from IPython.utils import log | |
378 | return log.get_logger() |
|
378 | return log.get_logger() |
@@ -193,7 +193,7 b' class AliasManager(Configurable):' | |||||
193 |
|
193 | |||
194 | default_aliases = List(default_aliases(), config=True) |
|
194 | default_aliases = List(default_aliases(), config=True) | |
195 | user_aliases = List(default_value=[], config=True) |
|
195 | user_aliases = List(default_value=[], config=True) | |
196 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') |
|
196 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) | |
197 |
|
197 | |||
198 | def __init__(self, shell=None, **kwargs): |
|
198 | def __init__(self, shell=None, **kwargs): | |
199 | super(AliasManager, self).__init__(shell=shell, **kwargs) |
|
199 | super(AliasManager, self).__init__(shell=shell, **kwargs) |
@@ -146,7 +146,7 b' class BaseIPythonApplication(Application):' | |||||
146 | return d |
|
146 | return d | |
147 |
|
147 | |||
148 | _in_init_profile_dir = False |
|
148 | _in_init_profile_dir = False | |
149 | profile_dir = Instance(ProfileDir) |
|
149 | profile_dir = Instance(ProfileDir, allow_none=True) | |
150 | def _profile_dir_default(self): |
|
150 | def _profile_dir_default(self): | |
151 | # avoid recursion |
|
151 | # avoid recursion | |
152 | if self._in_init_profile_dir: |
|
152 | if self._in_init_profile_dir: |
@@ -36,7 +36,8 b' HideBuiltin = __HideBuiltin()' | |||||
36 |
|
36 | |||
37 | class BuiltinTrap(Configurable): |
|
37 | class BuiltinTrap(Configurable): | |
38 |
|
38 | |||
39 |
shell = Instance('IPython.core.interactiveshell.InteractiveShellABC' |
|
39 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | |
|
40 | allow_none=True) | |||
40 |
|
41 | |||
41 | def __init__(self, shell=None): |
|
42 | def __init__(self, shell=None): | |
42 | super(BuiltinTrap, self).__init__(shell=shell, config=None) |
|
43 | super(BuiltinTrap, self).__init__(shell=shell, config=None) |
@@ -29,7 +29,8 b' class DisplayHook(Configurable):' | |||||
29 | that gets called anytime user code returns a value. |
|
29 | that gets called anytime user code returns a value. | |
30 | """ |
|
30 | """ | |
31 |
|
31 | |||
32 |
shell = Instance('IPython.core.interactiveshell.InteractiveShellABC' |
|
32 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | |
|
33 | allow_none=True) | |||
33 | exec_result = Instance('IPython.core.interactiveshell.ExecutionResult', |
|
34 | exec_result = Instance('IPython.core.interactiveshell.ExecutionResult', | |
34 | allow_none=True) |
|
35 | allow_none=True) | |
35 | cull_fraction = Float(0.2) |
|
36 | cull_fraction = Float(0.2) |
@@ -46,7 +46,8 b' class ExtensionManager(Configurable):' | |||||
46 | is added to ``sys.path`` automatically. |
|
46 | is added to ``sys.path`` automatically. | |
47 | """ |
|
47 | """ | |
48 |
|
48 | |||
49 |
shell = Instance('IPython.core.interactiveshell.InteractiveShellABC' |
|
49 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | |
|
50 | allow_none=True) | |||
50 |
|
51 | |||
51 | def __init__(self, shell=None, **kwargs): |
|
52 | def __init__(self, shell=None, **kwargs): | |
52 | super(ExtensionManager, self).__init__(shell=shell, **kwargs) |
|
53 | super(ExtensionManager, self).__init__(shell=shell, **kwargs) |
@@ -443,7 +443,8 b' class HistoryManager(HistoryAccessor):' | |||||
443 | # Public interface |
|
443 | # Public interface | |
444 |
|
444 | |||
445 | # An instance of the IPython shell we are attached to |
|
445 | # An instance of the IPython shell we are attached to | |
446 |
shell = Instance('IPython.core.interactiveshell.InteractiveShellABC' |
|
446 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | |
|
447 | allow_none=True) | |||
447 | # Lists to hold processed and raw history. These start with a blank entry |
|
448 | # Lists to hold processed and raw history. These start with a blank entry | |
448 | # so that we can index them starting from 1 |
|
449 | # so that we can index them starting from 1 | |
449 | input_hist_parsed = List([""]) |
|
450 | input_hist_parsed = List([""]) | |
@@ -477,11 +478,12 b' class HistoryManager(HistoryAccessor):' | |||||
477 | db_output_cache = List() |
|
478 | db_output_cache = List() | |
478 |
|
479 | |||
479 | # History saving in separate thread |
|
480 | # History saving in separate thread | |
480 |
save_thread = Instance('IPython.core.history.HistorySavingThread' |
|
481 | save_thread = Instance('IPython.core.history.HistorySavingThread', | |
|
482 | allow_none=True) | |||
481 | try: # Event is a function returning an instance of _Event... |
|
483 | try: # Event is a function returning an instance of _Event... | |
482 | save_flag = Instance(threading._Event) |
|
484 | save_flag = Instance(threading._Event, allow_none=True) | |
483 | except AttributeError: # ...until Python 3.3, when it's a class. |
|
485 | except AttributeError: # ...until Python 3.3, when it's a class. | |
484 | save_flag = Instance(threading.Event) |
|
486 | save_flag = Instance(threading.Event, allow_none=True) | |
485 |
|
487 | |||
486 | # Private interface |
|
488 | # Private interface | |
487 | # Variables used to store the three last inputs from the user. On each new |
|
489 | # Variables used to store the three last inputs from the user. On each new |
@@ -295,13 +295,13 b' class InteractiveShell(SingletonConfigurable):' | |||||
295 | disable_failing_post_execute = CBool(False, config=True, |
|
295 | disable_failing_post_execute = CBool(False, config=True, | |
296 | help="Don't call post-execute functions that have failed in the past." |
|
296 | help="Don't call post-execute functions that have failed in the past." | |
297 | ) |
|
297 | ) | |
298 | display_formatter = Instance(DisplayFormatter) |
|
298 | display_formatter = Instance(DisplayFormatter, allow_none=True) | |
299 | displayhook_class = Type(DisplayHook) |
|
299 | displayhook_class = Type(DisplayHook, allow_none=True) | |
300 | display_pub_class = Type(DisplayPublisher) |
|
300 | display_pub_class = Type(DisplayPublisher, allow_none=True) | |
301 | data_pub_class = None |
|
301 | data_pub_class = None | |
302 |
|
302 | |||
303 | exit_now = CBool(False) |
|
303 | exit_now = CBool(False) | |
304 | exiter = Instance(ExitAutocall) |
|
304 | exiter = Instance(ExitAutocall, allow_none=True) | |
305 | def _exiter_default(self): |
|
305 | def _exiter_default(self): | |
306 | return ExitAutocall(self) |
|
306 | return ExitAutocall(self) | |
307 | # Monotonically increasing execution counter |
|
307 | # Monotonically increasing execution counter | |
@@ -435,16 +435,16 b' class InteractiveShell(SingletonConfigurable):' | |||||
435 | default_value='Context', config=True) |
|
435 | default_value='Context', config=True) | |
436 |
|
436 | |||
437 | # Subcomponents of InteractiveShell |
|
437 | # Subcomponents of InteractiveShell | |
438 | alias_manager = Instance('IPython.core.alias.AliasManager') |
|
438 | alias_manager = Instance('IPython.core.alias.AliasManager', allow_none=True) | |
439 | prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager') |
|
439 | prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager', allow_none=True) | |
440 | builtin_trap = Instance('IPython.core.builtin_trap.BuiltinTrap') |
|
440 | builtin_trap = Instance('IPython.core.builtin_trap.BuiltinTrap', allow_none=True) | |
441 | display_trap = Instance('IPython.core.display_trap.DisplayTrap') |
|
441 | display_trap = Instance('IPython.core.display_trap.DisplayTrap', allow_none=True) | |
442 | extension_manager = Instance('IPython.core.extensions.ExtensionManager') |
|
442 | extension_manager = Instance('IPython.core.extensions.ExtensionManager', allow_none=True) | |
443 | payload_manager = Instance('IPython.core.payload.PayloadManager') |
|
443 | payload_manager = Instance('IPython.core.payload.PayloadManager', allow_none=True) | |
444 | history_manager = Instance('IPython.core.history.HistoryAccessorBase') |
|
444 | history_manager = Instance('IPython.core.history.HistoryAccessorBase', allow_none=True) | |
445 | magics_manager = Instance('IPython.core.magic.MagicsManager') |
|
445 | magics_manager = Instance('IPython.core.magic.MagicsManager', allow_none=True) | |
446 |
|
446 | |||
447 | profile_dir = Instance('IPython.core.application.ProfileDir') |
|
447 | profile_dir = Instance('IPython.core.application.ProfileDir', allow_none=True) | |
448 | @property |
|
448 | @property | |
449 | def profile(self): |
|
449 | def profile(self): | |
450 | if self.profile_dir is not None: |
|
450 | if self.profile_dir is not None: | |
@@ -453,7 +453,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
453 |
|
453 | |||
454 |
|
454 | |||
455 | # Private interface |
|
455 | # Private interface | |
456 | _post_execute = Instance(dict) |
|
456 | _post_execute = Instance(dict, allow_none=True) | |
457 |
|
457 | |||
458 | # Tracks any GUI loop loaded for pylab |
|
458 | # Tracks any GUI loop loaded for pylab | |
459 | pylab_gui_select = None |
|
459 | pylab_gui_select = None |
@@ -301,7 +301,7 b' class MagicsManager(Configurable):' | |||||
301 | # A registry of the original objects that we've been given holding magics. |
|
301 | # A registry of the original objects that we've been given holding magics. | |
302 | registry = Dict |
|
302 | registry = Dict | |
303 |
|
303 | |||
304 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') |
|
304 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) | |
305 |
|
305 | |||
306 | auto_magic = Bool(True, config=True, help= |
|
306 | auto_magic = Bool(True, config=True, help= | |
307 | "Automatically call line magics without requiring explicit % prefix") |
|
307 | "Automatically call line magics without requiring explicit % prefix") | |
@@ -313,7 +313,7 b' class MagicsManager(Configurable):' | |||||
313 | 'Automagic is OFF, % prefix IS needed for line magics.', |
|
313 | 'Automagic is OFF, % prefix IS needed for line magics.', | |
314 | 'Automagic is ON, % prefix IS NOT needed for line magics.'] |
|
314 | 'Automagic is ON, % prefix IS NOT needed for line magics.'] | |
315 |
|
315 | |||
316 | user_magics = Instance('IPython.core.magics.UserMagics') |
|
316 | user_magics = Instance('IPython.core.magics.UserMagics', allow_none=True) | |
317 |
|
317 | |||
318 | def __init__(self, shell=None, config=None, user_magics=None, **traits): |
|
318 | def __init__(self, shell=None, config=None, user_magics=None, **traits): | |
319 |
|
319 |
@@ -130,7 +130,7 b' class PrefilterManager(Configurable):' | |||||
130 | """ |
|
130 | """ | |
131 |
|
131 | |||
132 | multi_line_specials = CBool(True, config=True) |
|
132 | multi_line_specials = CBool(True, config=True) | |
133 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') |
|
133 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) | |
134 |
|
134 | |||
135 | def __init__(self, shell=None, **kwargs): |
|
135 | def __init__(self, shell=None, **kwargs): | |
136 | super(PrefilterManager, self).__init__(shell=shell, **kwargs) |
|
136 | super(PrefilterManager, self).__init__(shell=shell, **kwargs) | |
@@ -362,8 +362,8 b' class PrefilterTransformer(Configurable):' | |||||
362 | priority = Integer(100, config=True) |
|
362 | priority = Integer(100, config=True) | |
363 | # Transformers don't currently use shell or prefilter_manager, but as we |
|
363 | # Transformers don't currently use shell or prefilter_manager, but as we | |
364 | # move away from checkers and handlers, they will need them. |
|
364 | # move away from checkers and handlers, they will need them. | |
365 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') |
|
365 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) | |
366 | prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager') |
|
366 | prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager', allow_none=True) | |
367 | enabled = Bool(True, config=True) |
|
367 | enabled = Bool(True, config=True) | |
368 |
|
368 | |||
369 | def __init__(self, shell=None, prefilter_manager=None, **kwargs): |
|
369 | def __init__(self, shell=None, prefilter_manager=None, **kwargs): | |
@@ -390,8 +390,8 b' class PrefilterChecker(Configurable):' | |||||
390 | """Inspect an input line and return a handler for that line.""" |
|
390 | """Inspect an input line and return a handler for that line.""" | |
391 |
|
391 | |||
392 | priority = Integer(100, config=True) |
|
392 | priority = Integer(100, config=True) | |
393 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') |
|
393 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) | |
394 | prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager') |
|
394 | prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager', allow_none=True) | |
395 | enabled = Bool(True, config=True) |
|
395 | enabled = Bool(True, config=True) | |
396 |
|
396 | |||
397 | def __init__(self, shell=None, prefilter_manager=None, **kwargs): |
|
397 | def __init__(self, shell=None, prefilter_manager=None, **kwargs): | |
@@ -540,8 +540,8 b' class PrefilterHandler(Configurable):' | |||||
540 |
|
540 | |||
541 | handler_name = Unicode('normal') |
|
541 | handler_name = Unicode('normal') | |
542 | esc_strings = List([]) |
|
542 | esc_strings = List([]) | |
543 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') |
|
543 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) | |
544 | prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager') |
|
544 | prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager', allow_none=True) | |
545 |
|
545 | |||
546 | def __init__(self, shell=None, prefilter_manager=None, **kwargs): |
|
546 | def __init__(self, shell=None, prefilter_manager=None, **kwargs): | |
547 | super(PrefilterHandler, self).__init__( |
|
547 | super(PrefilterHandler, self).__init__( |
@@ -278,9 +278,9 b' class UserNSFormatter(Formatter):' | |||||
278 |
|
278 | |||
279 | class PromptManager(Configurable): |
|
279 | class PromptManager(Configurable): | |
280 | """This is the primary interface for producing IPython's prompts.""" |
|
280 | """This is the primary interface for producing IPython's prompts.""" | |
281 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') |
|
281 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) | |
282 |
|
282 | |||
283 | color_scheme_table = Instance(coloransi.ColorSchemeTable) |
|
283 | color_scheme_table = Instance(coloransi.ColorSchemeTable, allow_none=True) | |
284 | color_scheme = Unicode('Linux', config=True) |
|
284 | color_scheme = Unicode('Linux', config=True) | |
285 | def _color_scheme_changed(self, name, new_value): |
|
285 | def _color_scheme_changed(self, name, new_value): | |
286 | self.color_scheme_table.set_active_scheme(new_value) |
|
286 | self.color_scheme_table.set_active_scheme(new_value) |
@@ -194,7 +194,8 b' class InteractiveShellApp(Configurable):' | |||||
194 | When False, pylab mode should not import any names into the user namespace. |
|
194 | When False, pylab mode should not import any names into the user namespace. | |
195 | """ |
|
195 | """ | |
196 | ) |
|
196 | ) | |
197 |
shell = Instance('IPython.core.interactiveshell.InteractiveShellABC' |
|
197 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | |
|
198 | allow_none=True) | |||
198 |
|
199 | |||
199 | user_ns = Instance(dict, args=None, allow_none=True) |
|
200 | user_ns = Instance(dict, args=None, allow_none=True) | |
200 | def _user_ns_changed(self, name, old, new): |
|
201 | def _user_ns_changed(self, name, old, new): |
@@ -665,7 +665,7 b' class NotebookApp(BaseIPythonApplication):' | |||||
665 | help='The config manager class to use' |
|
665 | help='The config manager class to use' | |
666 | ) |
|
666 | ) | |
667 |
|
667 | |||
668 | kernel_spec_manager = Instance(KernelSpecManager) |
|
668 | kernel_spec_manager = Instance(KernelSpecManager, allow_none=True) | |
669 |
|
669 | |||
670 | kernel_spec_manager_class = Type( |
|
670 | kernel_spec_manager_class = Type( | |
671 | default_value=KernelSpecManager, |
|
671 | default_value=KernelSpecManager, |
@@ -20,7 +20,7 b' class ClusterManager(LoggingConfigurable):' | |||||
20 | delay = Float(1., config=True, |
|
20 | delay = Float(1., config=True, | |
21 | help="delay (in s) between starting the controller and the engines") |
|
21 | help="delay (in s) between starting the controller and the engines") | |
22 |
|
22 | |||
23 | loop = Instance('zmq.eventloop.ioloop.IOLoop') |
|
23 | loop = Instance('zmq.eventloop.ioloop.IOLoop', allow_none=True) | |
24 | def _loop_default(self): |
|
24 | def _loop_default(self): | |
25 | from zmq.eventloop.ioloop import IOLoop |
|
25 | from zmq.eventloop.ioloop import IOLoop | |
26 | return IOLoop.instance() |
|
26 | return IOLoop.instance() |
@@ -129,7 +129,7 b' class Widget(LoggingConfigurable):' | |||||
129 | If empty, look in the global registry.""", sync=True) |
|
129 | If empty, look in the global registry.""", sync=True) | |
130 | _view_name = Unicode(None, allow_none=True, help="""Default view registered in the front-end |
|
130 | _view_name = Unicode(None, allow_none=True, help="""Default view registered in the front-end | |
131 | to use to represent the widget.""", sync=True) |
|
131 | to use to represent the widget.""", sync=True) | |
132 | comm = Instance('IPython.kernel.comm.Comm') |
|
132 | comm = Instance('IPython.kernel.comm.Comm', allow_none=True) | |
133 |
|
133 | |||
134 | msg_throttle = Int(3, sync=True, help="""Maximum number of msgs the |
|
134 | msg_throttle = Int(3, sync=True, help="""Maximum number of msgs the | |
135 | front-end can send before receiving an idle msg from the back-end.""") |
|
135 | front-end can send before receiving an idle msg from the back-end.""") |
@@ -44,7 +44,8 b' class InProcessKernelClient(KernelClient):' | |||||
44 | stdin_channel_class = Type(InProcessChannel) |
|
44 | stdin_channel_class = Type(InProcessChannel) | |
45 | hb_channel_class = Type(InProcessHBChannel) |
|
45 | hb_channel_class = Type(InProcessHBChannel) | |
46 |
|
46 | |||
47 |
kernel = Instance('IPython.kernel.inprocess.ipkernel.InProcessKernel' |
|
47 | kernel = Instance('IPython.kernel.inprocess.ipkernel.InProcessKernel', | |
|
48 | allow_none=True) | |||
48 |
|
49 | |||
49 | #-------------------------------------------------------------------------- |
|
50 | #-------------------------------------------------------------------------- | |
50 | # Channel management methods |
|
51 | # Channel management methods |
@@ -27,7 +27,8 b' class InProcessKernel(IPythonKernel):' | |||||
27 |
|
27 | |||
28 | # The frontends connected to this kernel. |
|
28 | # The frontends connected to this kernel. | |
29 | frontends = List( |
|
29 | frontends = List( | |
30 |
Instance('IPython.kernel.inprocess.client.InProcessKernelClient' |
|
30 | Instance('IPython.kernel.inprocess.client.InProcessKernelClient' | |
|
31 | allow_none=True) | |||
31 | ) |
|
32 | ) | |
32 |
|
33 | |||
33 | # The GUI environment that the kernel is running under. This need not be |
|
34 | # The GUI environment that the kernel is running under. This need not be | |
@@ -140,7 +141,8 b' class InProcessKernel(IPythonKernel):' | |||||
140 |
|
141 | |||
141 | class InProcessInteractiveShell(ZMQInteractiveShell): |
|
142 | class InProcessInteractiveShell(ZMQInteractiveShell): | |
142 |
|
143 | |||
143 |
kernel = Instance('IPython.kernel.inprocess.ipkernel.InProcessKernel' |
|
144 | kernel = Instance('IPython.kernel.inprocess.ipkernel.InProcessKernel', | |
|
145 | allow_none=True) | |||
144 |
|
146 | |||
145 | #------------------------------------------------------------------------- |
|
147 | #------------------------------------------------------------------------- | |
146 | # InteractiveShell interface |
|
148 | # InteractiveShell interface |
@@ -20,7 +20,8 b' class InProcessKernelManager(KernelManager):' | |||||
20 | """ |
|
20 | """ | |
21 |
|
21 | |||
22 | # The kernel process with which the KernelManager is communicating. |
|
22 | # The kernel process with which the KernelManager is communicating. | |
23 |
kernel = Instance('IPython.kernel.inprocess.ipkernel.InProcessKernel' |
|
23 | kernel = Instance('IPython.kernel.inprocess.ipkernel.InProcessKernel', | |
|
24 | allow_none=True) | |||
24 | # the client class for KM.client() shortcut |
|
25 | # the client class for KM.client() shortcut | |
25 | client_class = DottedObjectName('IPython.kernel.inprocess.BlockingInProcessKernelClient') |
|
26 | client_class = DottedObjectName('IPython.kernel.inprocess.BlockingInProcessKernelClient') | |
26 |
|
27 |
@@ -36,11 +36,11 b' def as_zmqstream(f):' | |||||
36 |
|
36 | |||
37 | class IOLoopKernelManager(KernelManager): |
|
37 | class IOLoopKernelManager(KernelManager): | |
38 |
|
38 | |||
39 |
loop = Instance('zmq.eventloop.ioloop.IOLoop' |
|
39 | loop = Instance('zmq.eventloop.ioloop.IOLoop') | |
40 | def _loop_default(self): |
|
40 | def _loop_default(self): | |
41 | return ioloop.IOLoop.instance() |
|
41 | return ioloop.IOLoop.instance() | |
42 |
|
42 | |||
43 | _restarter = Instance('IPython.kernel.ioloop.IOLoopKernelRestarter') |
|
43 | _restarter = Instance('IPython.kernel.ioloop.IOLoopKernelRestarter', allow_none=True) | |
44 |
|
44 | |||
45 | def start_restarter(self): |
|
45 | def start_restarter(self): | |
46 | if self.autorestart and self.has_kernel: |
|
46 | if self.autorestart and self.has_kernel: |
@@ -32,7 +32,7 b' from IPython.utils.traitlets import (' | |||||
32 | class IOLoopKernelRestarter(KernelRestarter): |
|
32 | class IOLoopKernelRestarter(KernelRestarter): | |
33 | """Monitor and autorestart a kernel.""" |
|
33 | """Monitor and autorestart a kernel.""" | |
34 |
|
34 | |||
35 |
loop = Instance('zmq.eventloop.ioloop.IOLoop' |
|
35 | loop = Instance('zmq.eventloop.ioloop.IOLoop') | |
36 | def _loop_default(self): |
|
36 | def _loop_default(self): | |
37 | return ioloop.IOLoop.instance() |
|
37 | return ioloop.IOLoop.instance() | |
38 |
|
38 |
@@ -27,8 +27,8 b' from IPython.kernel.zmq.session import Session, extract_header' | |||||
27 | class ZMQDataPublisher(Configurable): |
|
27 | class ZMQDataPublisher(Configurable): | |
28 |
|
28 | |||
29 | topic = topic = CBytes(b'datapub') |
|
29 | topic = topic = CBytes(b'datapub') | |
30 | session = Instance(Session) |
|
30 | session = Instance(Session, allow_none=True) | |
31 | pub_socket = Instance(SocketABC) |
|
31 | pub_socket = Instance(SocketABC, allow_none=True) | |
32 | parent_header = Dict({}) |
|
32 | parent_header = Dict({}) | |
33 |
|
33 | |||
34 | def set_parent(self, parent): |
|
34 | def set_parent(self, parent): |
@@ -42,8 +42,8 b' class ZMQShellDisplayHook(DisplayHook):' | |||||
42 | representations of the object.""" |
|
42 | representations of the object.""" | |
43 | topic=None |
|
43 | topic=None | |
44 |
|
44 | |||
45 | session = Instance(Session) |
|
45 | session = Instance(Session, allow_none=True) | |
46 | pub_socket = Instance(SocketABC) |
|
46 | pub_socket = Instance(SocketABC, allow_none=True) | |
47 | parent_header = Dict({}) |
|
47 | parent_header = Dict({}) | |
48 |
|
48 | |||
49 | def set_parent(self, parent): |
|
49 | def set_parent(self, parent): |
@@ -22,7 +22,8 b' def lazy_import_handle_comm_opened(*args, **kwargs):' | |||||
22 |
|
22 | |||
23 |
|
23 | |||
24 | class IPythonKernel(KernelBase): |
|
24 | class IPythonKernel(KernelBase): | |
25 |
shell = Instance('IPython.core.interactiveshell.InteractiveShellABC' |
|
25 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | |
|
26 | allow_none=True) | |||
26 | shell_class = Type(ZMQInteractiveShell) |
|
27 | shell_class = Type(ZMQInteractiveShell) | |
27 |
|
28 | |||
28 | user_module = Any() |
|
29 | user_module = Any() |
@@ -108,7 +108,7 b' class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,' | |||||
108 | """) |
|
108 | """) | |
109 | kernel = Any() |
|
109 | kernel = Any() | |
110 | poller = Any() # don't restrict this even though current pollers are all Threads |
|
110 | poller = Any() # don't restrict this even though current pollers are all Threads | |
111 | heartbeat = Instance(Heartbeat) |
|
111 | heartbeat = Instance(Heartbeat, allow_none=True) | |
112 | ports = Dict() |
|
112 | ports = Dict() | |
113 |
|
113 | |||
114 | # connection info: |
|
114 | # connection info: |
@@ -45,13 +45,13 b' class Kernel(SingletonConfigurable):' | |||||
45 | loop = ioloop.IOLoop.instance() |
|
45 | loop = ioloop.IOLoop.instance() | |
46 | loop.add_callback(self.enter_eventloop) |
|
46 | loop.add_callback(self.enter_eventloop) | |
47 |
|
47 | |||
48 | session = Instance(Session) |
|
48 | session = Instance(Session, allow_none=True) | |
49 | profile_dir = Instance('IPython.core.profiledir.ProfileDir') |
|
49 | profile_dir = Instance('IPython.core.profiledir.ProfileDir', allow_none=True) | |
50 | shell_streams = List() |
|
50 | shell_streams = List() | |
51 | control_stream = Instance(ZMQStream) |
|
51 | control_stream = Instance(ZMQStream, allow_none=True) | |
52 | iopub_socket = Instance(zmq.Socket) |
|
52 | iopub_socket = Instance(zmq.Socket, allow_none=True) | |
53 | stdin_socket = Instance(zmq.Socket) |
|
53 | stdin_socket = Instance(zmq.Socket, allow_none=True) | |
54 | log = Instance(logging.Logger) |
|
54 | log = Instance(logging.Logger, allow_none=True) | |
55 |
|
55 | |||
56 | # identities: |
|
56 | # identities: | |
57 | int_id = Integer(-1) |
|
57 | int_id = Integer(-1) |
@@ -114,6 +114,7 b' class InlineBackend(InlineBackendConfig):' | |||||
114 | be explicit. |
|
114 | be explicit. | |
115 | """) |
|
115 | """) | |
116 |
|
116 | |||
117 |
shell = Instance('IPython.core.interactiveshell.InteractiveShellABC' |
|
117 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | |
|
118 | allow_none=True) | |||
118 |
|
119 | |||
119 |
|
120 |
@@ -148,9 +148,10 b' class SessionFactory(LoggingConfigurable):' | |||||
148 | def _context_default(self): |
|
148 | def _context_default(self): | |
149 | return zmq.Context.instance() |
|
149 | return zmq.Context.instance() | |
150 |
|
150 | |||
151 |
session = Instance('IPython.kernel.zmq.session.Session' |
|
151 | session = Instance('IPython.kernel.zmq.session.Session', | |
|
152 | allow_none=True) | |||
152 |
|
153 | |||
153 |
loop = Instance('zmq.eventloop.ioloop.IOLoop' |
|
154 | loop = Instance('zmq.eventloop.ioloop.IOLoop') | |
154 | def _loop_default(self): |
|
155 | def _loop_default(self): | |
155 | return IOLoop.instance() |
|
156 | return IOLoop.instance() | |
156 |
|
157 |
@@ -58,8 +58,8 b' from .session import Session' | |||||
58 | class ZMQDisplayPublisher(DisplayPublisher): |
|
58 | class ZMQDisplayPublisher(DisplayPublisher): | |
59 | """A display publisher that publishes data using a ZeroMQ PUB socket.""" |
|
59 | """A display publisher that publishes data using a ZeroMQ PUB socket.""" | |
60 |
|
60 | |||
61 | session = Instance(Session) |
|
61 | session = Instance(Session, allow_none=True) | |
62 | pub_socket = Instance(SocketABC) |
|
62 | pub_socket = Instance(SocketABC, allow_none=True) | |
63 | parent_header = Dict({}) |
|
63 | parent_header = Dict({}) | |
64 | topic = CBytes(b'display_data') |
|
64 | topic = CBytes(b'display_data') | |
65 |
|
65 | |||
@@ -367,7 +367,7 b' class ZMQInteractiveShell(InteractiveShell):' | |||||
367 | # will print a warning in the absence of readline. |
|
367 | # will print a warning in the absence of readline. | |
368 | autoindent = CBool(False) |
|
368 | autoindent = CBool(False) | |
369 |
|
369 | |||
370 | exiter = Instance(ZMQExitAutocall) |
|
370 | exiter = Instance(ZMQExitAutocall, allow_none=True) | |
371 | def _exiter_default(self): |
|
371 | def _exiter_default(self): | |
372 | return ZMQExitAutocall(self) |
|
372 | return ZMQExitAutocall(self) | |
373 |
|
373 |
@@ -445,7 +445,7 b' class TestType(TestCase):' | |||||
445 |
|
445 | |||
446 | class B(object): pass |
|
446 | class B(object): pass | |
447 | class A(HasTraits): |
|
447 | class A(HasTraits): | |
448 | klass = Type |
|
448 | klass = Type(allow_none=True) | |
449 |
|
449 | |||
450 | a = A() |
|
450 | a = A() | |
451 | self.assertEqual(a.klass, None) |
|
451 | self.assertEqual(a.klass, None) | |
@@ -472,7 +472,7 b' class TestType(TestCase):' | |||||
472 | class B(object): pass |
|
472 | class B(object): pass | |
473 | class C(B): pass |
|
473 | class C(B): pass | |
474 | class A(HasTraits): |
|
474 | class A(HasTraits): | |
475 |
klass = Type(B |
|
475 | klass = Type(B) | |
476 |
|
476 | |||
477 | a = A() |
|
477 | a = A() | |
478 | self.assertEqual(a.klass, B) |
|
478 | self.assertEqual(a.klass, B) | |
@@ -501,7 +501,7 b' class TestType(TestCase):' | |||||
501 | self.assertRaises(ImportError, A) |
|
501 | self.assertRaises(ImportError, A) | |
502 |
|
502 | |||
503 | class C(HasTraits): |
|
503 | class C(HasTraits): | |
504 |
klass = Type(None, B |
|
504 | klass = Type(None, B) | |
505 |
|
505 | |||
506 | self.assertRaises(TraitError, C) |
|
506 | self.assertRaises(TraitError, C) | |
507 |
|
507 | |||
@@ -534,7 +534,7 b' class TestInstance(TestCase):' | |||||
534 | class Bah(object): pass |
|
534 | class Bah(object): pass | |
535 |
|
535 | |||
536 | class A(HasTraits): |
|
536 | class A(HasTraits): | |
537 | inst = Instance(Foo) |
|
537 | inst = Instance(Foo, allow_none=True) | |
538 |
|
538 | |||
539 | a = A() |
|
539 | a = A() | |
540 | self.assertTrue(a.inst is None) |
|
540 | self.assertTrue(a.inst is None) | |
@@ -555,7 +555,7 b' class TestInstance(TestCase):' | |||||
555 | klass = Foo |
|
555 | klass = Foo | |
556 |
|
556 | |||
557 | class A(HasTraits): |
|
557 | class A(HasTraits): | |
558 | inst = FooInstance() |
|
558 | inst = FooInstance(allow_none=True) | |
559 |
|
559 | |||
560 | a = A() |
|
560 | a = A() | |
561 | self.assertTrue(a.inst is None) |
|
561 | self.assertTrue(a.inst is None) | |
@@ -596,7 +596,7 b' class TestInstance(TestCase):' | |||||
596 | self.assertEqual(b.inst.d, 20) |
|
596 | self.assertEqual(b.inst.d, 20) | |
597 |
|
597 | |||
598 | class C(HasTraits): |
|
598 | class C(HasTraits): | |
599 | inst = Instance(Foo) |
|
599 | inst = Instance(Foo, allow_none=True) | |
600 | c = C() |
|
600 | c = C() | |
601 | self.assertTrue(c.inst is None) |
|
601 | self.assertTrue(c.inst is None) | |
602 |
|
602 | |||
@@ -604,7 +604,7 b' class TestInstance(TestCase):' | |||||
604 | class Foo(object): pass |
|
604 | class Foo(object): pass | |
605 |
|
605 | |||
606 | class A(HasTraits): |
|
606 | class A(HasTraits): | |
607 |
inst = Instance(Foo |
|
607 | inst = Instance(Foo) | |
608 |
|
608 | |||
609 | self.assertRaises(TraitError, A) |
|
609 | self.assertRaises(TraitError, A) | |
610 |
|
610 | |||
@@ -951,7 +951,7 b' class Foo(object):' | |||||
951 |
|
951 | |||
952 | class NoneInstanceListTrait(HasTraits): |
|
952 | class NoneInstanceListTrait(HasTraits): | |
953 |
|
953 | |||
954 |
value = List(Instance(Foo |
|
954 | value = List(Instance(Foo)) | |
955 |
|
955 | |||
956 | class TestNoneInstanceList(TraitTestBase): |
|
956 | class TestNoneInstanceList(TraitTestBase): | |
957 |
|
957 | |||
@@ -975,7 +975,7 b' class TestInstanceList(TraitTestBase):' | |||||
975 | self.assertIs(self.obj.traits()['value']._trait.klass, Foo) |
|
975 | self.assertIs(self.obj.traits()['value']._trait.klass, Foo) | |
976 |
|
976 | |||
977 | _default_value = [] |
|
977 | _default_value = [] | |
978 |
_good_values = [[Foo(), Foo() |
|
978 | _good_values = [[Foo(), Foo()], []] | |
979 | _bad_values = [['1', 2,], '1', [Foo], None] |
|
979 | _bad_values = [['1', 2,], '1', [Foo], None] | |
980 |
|
980 | |||
981 | class UnionListTrait(HasTraits): |
|
981 | class UnionListTrait(HasTraits): | |
@@ -1120,7 +1120,7 b' class TestValidationHook(TestCase):' | |||||
1120 | class Parity(HasTraits): |
|
1120 | class Parity(HasTraits): | |
1121 |
|
1121 | |||
1122 | value = Int(0) |
|
1122 | value = Int(0) | |
1123 |
parity = Enum(['odd', 'even'], default_value='even' |
|
1123 | parity = Enum(['odd', 'even'], default_value='even') | |
1124 |
|
1124 | |||
1125 | def _value_validate(self, value, trait): |
|
1125 | def _value_validate(self, value, trait): | |
1126 | if self.parity == 'even' and value % 2: |
|
1126 | if self.parity == 'even' and value % 2: | |
@@ -1469,11 +1469,11 b' class TestEventful(TestCase):' | |||||
1469 | ### |
|
1469 | ### | |
1470 | class ForwardDeclaredInstanceTrait(HasTraits): |
|
1470 | class ForwardDeclaredInstanceTrait(HasTraits): | |
1471 |
|
1471 | |||
1472 | value = ForwardDeclaredInstance('ForwardDeclaredBar') |
|
1472 | value = ForwardDeclaredInstance('ForwardDeclaredBar', allow_none=True) | |
1473 |
|
1473 | |||
1474 | class ForwardDeclaredTypeTrait(HasTraits): |
|
1474 | class ForwardDeclaredTypeTrait(HasTraits): | |
1475 |
|
1475 | |||
1476 | value = ForwardDeclaredType('ForwardDeclaredBar') |
|
1476 | value = ForwardDeclaredType('ForwardDeclaredBar', allow_none=True) | |
1477 |
|
1477 | |||
1478 | class ForwardDeclaredInstanceListTrait(HasTraits): |
|
1478 | class ForwardDeclaredInstanceListTrait(HasTraits): | |
1479 |
|
1479 | |||
@@ -1525,16 +1525,16 b' class TestForwardDeclaredInstanceList(TraitTestBase):' | |||||
1525 |
|
1525 | |||
1526 | _default_value = [] |
|
1526 | _default_value = [] | |
1527 | _good_values = [ |
|
1527 | _good_values = [ | |
1528 |
[ForwardDeclaredBar(), ForwardDeclaredBarSub() |
|
1528 | [ForwardDeclaredBar(), ForwardDeclaredBarSub()], | |
1529 | [None], |
|
|||
1530 | [], |
|
1529 | [], | |
1531 | ] |
|
1530 | ] | |
1532 | _bad_values = [ |
|
1531 | _bad_values = [ | |
1533 | ForwardDeclaredBar(), |
|
1532 | ForwardDeclaredBar(), | |
1534 | [ForwardDeclaredBar(), 3], |
|
1533 | [ForwardDeclaredBar(), 3, None], | |
1535 | '1', |
|
1534 | '1', | |
1536 | # Note that this is the type, not an instance. |
|
1535 | # Note that this is the type, not an instance. | |
1537 | [ForwardDeclaredBar], |
|
1536 | [ForwardDeclaredBar], | |
|
1537 | [None], | |||
1538 | None, |
|
1538 | None, | |
1539 | ] |
|
1539 | ] | |
1540 |
|
1540 | |||
@@ -1548,9 +1548,8 b' class TestForwardDeclaredTypeList(TraitTestBase):' | |||||
1548 |
|
1548 | |||
1549 | _default_value = [] |
|
1549 | _default_value = [] | |
1550 | _good_values = [ |
|
1550 | _good_values = [ | |
1551 |
[ForwardDeclaredBar, ForwardDeclaredBarSub |
|
1551 | [ForwardDeclaredBar, ForwardDeclaredBarSub], | |
1552 | [], |
|
1552 | [], | |
1553 | [None], |
|
|||
1554 | ] |
|
1553 | ] | |
1555 | _bad_values = [ |
|
1554 | _bad_values = [ | |
1556 | ForwardDeclaredBar, |
|
1555 | ForwardDeclaredBar, | |
@@ -1558,6 +1557,7 b' class TestForwardDeclaredTypeList(TraitTestBase):' | |||||
1558 | '1', |
|
1557 | '1', | |
1559 | # Note that this is an instance, not the type. |
|
1558 | # Note that this is an instance, not the type. | |
1560 | [ForwardDeclaredBar()], |
|
1559 | [ForwardDeclaredBar()], | |
|
1560 | [None], | |||
1561 | None, |
|
1561 | None, | |
1562 | ] |
|
1562 | ] | |
1563 | ### |
|
1563 | ### |
@@ -852,7 +852,8 b' class ClassBasedTraitType(TraitType):' | |||||
852 | class Type(ClassBasedTraitType): |
|
852 | class Type(ClassBasedTraitType): | |
853 | """A trait whose value must be a subclass of a specified class.""" |
|
853 | """A trait whose value must be a subclass of a specified class.""" | |
854 |
|
854 | |||
855 |
def __init__ (self, default_value=None, klass=None, allow_none= |
|
855 | def __init__ (self, default_value=None, klass=None, allow_none=False, | |
|
856 | **metadata): | |||
856 | """Construct a Type trait |
|
857 | """Construct a Type trait | |
857 |
|
858 | |||
858 | A Type trait specifies that its values must be subclasses of |
|
859 | A Type trait specifies that its values must be subclasses of | |
@@ -952,8 +953,8 b' class Instance(ClassBasedTraitType):' | |||||
952 |
|
953 | |||
953 | klass = None |
|
954 | klass = None | |
954 |
|
955 | |||
955 | def __init__(self, klass=None, args=None, kw=None, |
|
956 | def __init__(self, klass=None, args=None, kw=None, allow_none=False, | |
956 |
|
|
957 | **metadata ): | |
957 | """Construct an Instance trait. |
|
958 | """Construct an Instance trait. | |
958 |
|
959 | |||
959 | This trait allows values that are instances of a particular |
|
960 | This trait allows values that are instances of a particular | |
@@ -1656,7 +1657,7 b' class Tuple(Container):' | |||||
1656 | if self._traits and default_value is None: |
|
1657 | if self._traits and default_value is None: | |
1657 | # don't allow default to be an empty container if length is specified |
|
1658 | # don't allow default to be an empty container if length is specified | |
1658 | args = None |
|
1659 | args = None | |
1659 | super(Container,self).__init__(klass=self.klass, args=args, **metadata) |
|
1660 | super(Container,self).__init__(klass=self.klass, args=args, allow_none=allow_none, **metadata) | |
1660 |
|
1661 | |||
1661 | def validate_elements(self, obj, value): |
|
1662 | def validate_elements(self, obj, value): | |
1662 | if not self._traits: |
|
1663 | if not self._traits: |
@@ -123,7 +123,7 b' class BaseParallelApplication(BaseIPythonApplication):' | |||||
123 | def _config_files_default(self): |
|
123 | def _config_files_default(self): | |
124 | return ['ipcontroller_config.py', 'ipengine_config.py', 'ipcluster_config.py'] |
|
124 | return ['ipcontroller_config.py', 'ipengine_config.py', 'ipcluster_config.py'] | |
125 |
|
125 | |||
126 | loop = Instance('zmq.eventloop.ioloop.IOLoop') |
|
126 | loop = Instance('zmq.eventloop.ioloop.IOLoop', allow_none=True) | |
127 | def _loop_default(self): |
|
127 | def _loop_default(self): | |
128 | from zmq.eventloop.ioloop import IOLoop |
|
128 | from zmq.eventloop.ioloop import IOLoop | |
129 | return IOLoop.instance() |
|
129 | return IOLoop.instance() |
@@ -174,7 +174,7 b' class IPEngineApp(BaseParallelApplication):' | |||||
174 | logging to a central location.""") |
|
174 | logging to a central location.""") | |
175 |
|
175 | |||
176 | # an IPKernelApp instance, used to setup listening for shell frontends |
|
176 | # an IPKernelApp instance, used to setup listening for shell frontends | |
177 | kernel_app = Instance(IPKernelApp) |
|
177 | kernel_app = Instance(IPKernelApp, allow_none=True) | |
178 |
|
178 | |||
179 | aliases = Dict(aliases) |
|
179 | aliases = Dict(aliases) | |
180 | flags = Dict(flags) |
|
180 | flags = Dict(flags) |
@@ -102,7 +102,7 b' class BaseLauncher(LoggingConfigurable):' | |||||
102 | # controller_args, engine_args attributes of the launchers to add |
|
102 | # controller_args, engine_args attributes of the launchers to add | |
103 | # the work_dir option. |
|
103 | # the work_dir option. | |
104 | work_dir = Unicode(u'.') |
|
104 | work_dir = Unicode(u'.') | |
105 | loop = Instance('zmq.eventloop.ioloop.IOLoop') |
|
105 | loop = Instance('zmq.eventloop.ioloop.IOLoop', allow_none=True) | |
106 |
|
106 | |||
107 | start_data = Any() |
|
107 | start_data = Any() | |
108 | stop_data = Any() |
|
108 | stop_data = Any() |
@@ -50,13 +50,13 b' class LogWatcher(LoggingConfigurable):' | |||||
50 | return 'tcp://%s:20202' % localhost() |
|
50 | return 'tcp://%s:20202' % localhost() | |
51 |
|
51 | |||
52 | # internals |
|
52 | # internals | |
53 | stream = Instance('zmq.eventloop.zmqstream.ZMQStream') |
|
53 | stream = Instance('zmq.eventloop.zmqstream.ZMQStream', allow_none=True) | |
54 |
|
54 | |||
55 | context = Instance(zmq.Context) |
|
55 | context = Instance(zmq.Context, allow_none=True) | |
56 | def _context_default(self): |
|
56 | def _context_default(self): | |
57 | return zmq.Context.instance() |
|
57 | return zmq.Context.instance() | |
58 |
|
58 | |||
59 | loop = Instance(zmq.eventloop.ioloop.IOLoop) |
|
59 | loop = Instance(zmq.eventloop.ioloop.IOLoop, allow_none=True) | |
60 | def _loop_default(self): |
|
60 | def _loop_default(self): | |
61 | return ioloop.IOLoop.instance() |
|
61 | return ioloop.IOLoop.instance() | |
62 |
|
62 |
@@ -107,7 +107,7 b' class View(HasTraits):' | |||||
107 | history=List() |
|
107 | history=List() | |
108 | outstanding = Set() |
|
108 | outstanding = Set() | |
109 | results = Dict() |
|
109 | results = Dict() | |
110 | client = Instance('ipython_parallel.Client') |
|
110 | client = Instance('ipython_parallel.Client', allow_none=True) | |
111 |
|
111 | |||
112 | _socket = Instance('zmq.Socket') |
|
112 | _socket = Instance('zmq.Socket') | |
113 | _flag_names = List(['targets', 'block', 'track']) |
|
113 | _flag_names = List(['targets', 'block', 'track']) | |
@@ -215,7 +215,7 b' class View(HasTraits):' | |||||
215 |
|
215 | |||
216 | This method sets all apply flags via this View's attributes. |
|
216 | This method sets all apply flags via this View's attributes. | |
217 |
|
217 | |||
218 |
Returns :class:`~ |
|
218 | Returns :class:`~IPython.parallel.client.asyncresult.AsyncResult` | |
219 | instance if ``self.block`` is False, otherwise the return value of |
|
219 | instance if ``self.block`` is False, otherwise the return value of | |
220 | ``f(*args, **kwargs)``. |
|
220 | ``f(*args, **kwargs)``. | |
221 | """ |
|
221 | """ | |
@@ -224,7 +224,7 b' class View(HasTraits):' | |||||
224 | def apply_async(self, f, *args, **kwargs): |
|
224 | def apply_async(self, f, *args, **kwargs): | |
225 | """calls ``f(*args, **kwargs)`` on remote engines in a nonblocking manner. |
|
225 | """calls ``f(*args, **kwargs)`` on remote engines in a nonblocking manner. | |
226 |
|
226 | |||
227 |
Returns :class:`~ |
|
227 | Returns :class:`~IPython.parallel.client.asyncresult.AsyncResult` instance. | |
228 | """ |
|
228 | """ | |
229 | return self._really_apply(f, args, kwargs, block=False) |
|
229 | return self._really_apply(f, args, kwargs, block=False) | |
230 |
|
230 | |||
@@ -307,7 +307,7 b' class View(HasTraits):' | |||||
307 | def get_result(self, indices_or_msg_ids=None, block=None, owner=True): |
|
307 | def get_result(self, indices_or_msg_ids=None, block=None, owner=True): | |
308 | """return one or more results, specified by history index or msg_id. |
|
308 | """return one or more results, specified by history index or msg_id. | |
309 |
|
309 | |||
310 |
See :meth:` |
|
310 | See :meth:`IPython.parallel.client.client.Client.get_result` for details. | |
311 | """ |
|
311 | """ | |
312 |
|
312 | |||
313 | if indices_or_msg_ids is None: |
|
313 | if indices_or_msg_ids is None: | |
@@ -603,7 +603,7 b' class DirectView(View):' | |||||
603 |
|
603 | |||
604 |
|
604 | |||
605 | If block=False |
|
605 | If block=False | |
606 |
An :class:`~ |
|
606 | An :class:`~IPython.parallel.client.asyncresult.AsyncMapResult` instance. | |
607 | An object like AsyncResult, but which reassembles the sequence of results |
|
607 | An object like AsyncResult, but which reassembles the sequence of results | |
608 | into a single list. AsyncMapResults can be iterated through before all |
|
608 | into a single list. AsyncMapResults can be iterated through before all | |
609 | results are complete. |
|
609 | results are complete. | |
@@ -832,7 +832,7 b' class DirectView(View):' | |||||
832 | on the even engines. |
|
832 | on the even engines. | |
833 | """ |
|
833 | """ | |
834 |
|
834 | |||
835 |
from |
|
835 | from IPython.parallel.client.magics import ParallelMagics | |
836 |
|
836 | |||
837 | try: |
|
837 | try: | |
838 | # This is injected into __builtins__. |
|
838 | # This is injected into __builtins__. | |
@@ -1099,7 +1099,7 b' class LoadBalancedView(View):' | |||||
1099 | ------- |
|
1099 | ------- | |
1100 |
|
1100 | |||
1101 | if block=False |
|
1101 | if block=False | |
1102 |
An :class:`~ |
|
1102 | An :class:`~IPython.parallel.client.asyncresult.AsyncMapResult` instance. | |
1103 | An object like AsyncResult, but which reassembles the sequence of results |
|
1103 | An object like AsyncResult, but which reassembles the sequence of results | |
1104 | into a single list. AsyncMapResults can be iterated through before all |
|
1104 | into a single list. AsyncMapResults can be iterated through before all | |
1105 | results are complete. |
|
1105 | results are complete. |
@@ -77,9 +77,9 b' class HeartMonitor(LoggingConfigurable):' | |||||
77 | help='Allowed consecutive missed pings from controller Hub to engine before unregistering.', |
|
77 | help='Allowed consecutive missed pings from controller Hub to engine before unregistering.', | |
78 | ) |
|
78 | ) | |
79 |
|
79 | |||
80 | pingstream=Instance('zmq.eventloop.zmqstream.ZMQStream') |
|
80 | pingstream=Instance('zmq.eventloop.zmqstream.ZMQStream', allow_none=True) | |
81 | pongstream=Instance('zmq.eventloop.zmqstream.ZMQStream') |
|
81 | pongstream=Instance('zmq.eventloop.zmqstream.ZMQStream', allow_none=True) | |
82 | loop = Instance('zmq.eventloop.ioloop.IOLoop') |
|
82 | loop = Instance('zmq.eventloop.ioloop.IOLoop', allow_none=True) | |
83 | def _loop_default(self): |
|
83 | def _loop_default(self): | |
84 | return ioloop.IOLoop.instance() |
|
84 | return ioloop.IOLoop.instance() | |
85 |
|
85 |
@@ -211,8 +211,8 b' class HubFactory(RegistrationFactory):' | |||||
211 | return max(30, int(.01 * self.heartmonitor.period)) |
|
211 | return max(30, int(.01 * self.heartmonitor.period)) | |
212 |
|
212 | |||
213 | # not configurable |
|
213 | # not configurable | |
214 | db = Instance('ipython_parallel.controller.dictdb.BaseDB') |
|
214 | db = Instance('ipython_parallel.controller.dictdb.BaseDB', allow_none=True) | |
215 | heartmonitor = Instance('ipython_parallel.controller.heartmonitor.HeartMonitor') |
|
215 | heartmonitor = Instance('ipython_parallel.controller.heartmonitor.HeartMonitor', allow_none=True) | |
216 |
|
216 | |||
217 | def _ip_changed(self, name, old, new): |
|
217 | def _ip_changed(self, name, old, new): | |
218 | self.engine_ip = new |
|
218 | self.engine_ip = new | |
@@ -382,12 +382,12 b' class Hub(SessionFactory):' | |||||
382 | _idcounter=Integer(0) |
|
382 | _idcounter=Integer(0) | |
383 |
|
383 | |||
384 | # objects from constructor: |
|
384 | # objects from constructor: | |
385 | query=Instance(ZMQStream) |
|
385 | query=Instance(ZMQStream, allow_none=True) | |
386 | monitor=Instance(ZMQStream) |
|
386 | monitor=Instance(ZMQStream, allow_none=True) | |
387 | notifier=Instance(ZMQStream) |
|
387 | notifier=Instance(ZMQStream, allow_none=True) | |
388 | resubmit=Instance(ZMQStream) |
|
388 | resubmit=Instance(ZMQStream, allow_none=True) | |
389 | heartmonitor=Instance(HeartMonitor) |
|
389 | heartmonitor=Instance(HeartMonitor, allow_none=True) | |
390 | db=Instance(object) |
|
390 | db=Instance(object, allow_none=True) | |
391 | client_info=Dict() |
|
391 | client_info=Dict() | |
392 | engine_info=Dict() |
|
392 | engine_info=Dict() | |
393 |
|
393 |
@@ -45,7 +45,7 b' class MongoDB(BaseDB):' | |||||
45 | in tasks from previous sessions being available via Clients' db_query and |
|
45 | in tasks from previous sessions being available via Clients' db_query and | |
46 | get_result methods.""") |
|
46 | get_result methods.""") | |
47 |
|
47 | |||
48 | _connection = Instance(Connection) # pymongo connection |
|
48 | _connection = Instance(Connection, allow_none=True) # pymongo connection | |
49 |
|
49 | |||
50 | def __init__(self, **kwargs): |
|
50 | def __init__(self, **kwargs): | |
51 | super(MongoDB, self).__init__(**kwargs) |
|
51 | super(MongoDB, self).__init__(**kwargs) |
@@ -180,17 +180,17 b' help="""select the task scheduler scheme [default: Python LRU]' | |||||
180 | self.scheme = globals()[new] |
|
180 | self.scheme = globals()[new] | |
181 |
|
181 | |||
182 | # input arguments: |
|
182 | # input arguments: | |
183 | scheme = Instance(FunctionType) # function for determining the destination |
|
183 | scheme = Instance(FunctionType, allow_none=True) # function for determining the destination | |
184 | def _scheme_default(self): |
|
184 | def _scheme_default(self): | |
185 | return leastload |
|
185 | return leastload | |
186 | client_stream = Instance(zmqstream.ZMQStream) # client-facing stream |
|
186 | client_stream = Instance(zmqstream.ZMQStream, allow_none=True) # client-facing stream | |
187 | engine_stream = Instance(zmqstream.ZMQStream) # engine-facing stream |
|
187 | engine_stream = Instance(zmqstream.ZMQStream, allow_none=True) # engine-facing stream | |
188 | notifier_stream = Instance(zmqstream.ZMQStream) # hub-facing sub stream |
|
188 | notifier_stream = Instance(zmqstream.ZMQStream, allow_none=True) # hub-facing sub stream | |
189 | mon_stream = Instance(zmqstream.ZMQStream) # hub-facing pub stream |
|
189 | mon_stream = Instance(zmqstream.ZMQStream, allow_none=True) # hub-facing pub stream | |
190 | query_stream = Instance(zmqstream.ZMQStream) # hub-facing DEALER stream |
|
190 | query_stream = Instance(zmqstream.ZMQStream, allow_none=True) # hub-facing DEALER stream | |
191 |
|
191 | |||
192 | # internals: |
|
192 | # internals: | |
193 | queue = Instance(deque) # sorted list of Jobs |
|
193 | queue = Instance(deque, allow_none=True) # sorted list of Jobs | |
194 | def _queue_default(self): |
|
194 | def _queue_default(self): | |
195 | return deque() |
|
195 | return deque() | |
196 | queue_map = Dict() # dict by msg_id of Jobs (for O(1) access to the Queue) |
|
196 | queue_map = Dict() # dict by msg_id of Jobs (for O(1) access to the Queue) |
@@ -99,7 +99,7 b' class SQLiteDB(BaseDB):' | |||||
99 | get_result methods.""") |
|
99 | get_result methods.""") | |
100 |
|
100 | |||
101 | if sqlite3 is not None: |
|
101 | if sqlite3 is not None: | |
102 | _db = Instance('sqlite3.Connection') |
|
102 | _db = Instance('sqlite3.Connection', allow_none=True) | |
103 | else: |
|
103 | else: | |
104 | _db = None |
|
104 | _db = None | |
105 | # the ordered list of column names |
|
105 | # the ordered list of column names |
@@ -67,8 +67,8 b' class EngineFactory(RegistrationFactory):' | |||||
67 | connection_info = Dict() |
|
67 | connection_info = Dict() | |
68 | user_ns = Dict() |
|
68 | user_ns = Dict() | |
69 | id = Integer(allow_none=True) |
|
69 | id = Integer(allow_none=True) | |
70 | registrar = Instance('zmq.eventloop.zmqstream.ZMQStream') |
|
70 | registrar = Instance('zmq.eventloop.zmqstream.ZMQStream', allow_none=True) | |
71 | kernel = Instance(Kernel) |
|
71 | kernel = Instance(Kernel, allow_none=True) | |
72 | hb_check_period=Integer() |
|
72 | hb_check_period=Integer() | |
73 |
|
73 | |||
74 | # States for the heartbeat monitoring |
|
74 | # States for the heartbeat monitoring |
@@ -109,8 +109,8 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||||
109 | """ |
|
109 | """ | |
110 | ) |
|
110 | ) | |
111 |
|
111 | |||
112 | manager = Instance('IPython.kernel.KernelManager') |
|
112 | manager = Instance('IPython.kernel.KernelManager', allow_none=True) | |
113 | client = Instance('IPython.kernel.KernelClient') |
|
113 | client = Instance('IPython.kernel.KernelClient', allow_none=True) | |
114 | def _client_changed(self, name, old, new): |
|
114 | def _client_changed(self, name, old, new): | |
115 | self.session_id = new.session.session |
|
115 | self.session_id = new.session.session | |
116 | session_id = Unicode() |
|
116 | session_id = Unicode() |
@@ -161,14 +161,14 b' class NbConvertApp(BaseIPythonApplication):' | |||||
161 | # Writer specific variables |
|
161 | # Writer specific variables | |
162 | writer = Instance('jupyter_nbconvert.writers.base.WriterBase', |
|
162 | writer = Instance('jupyter_nbconvert.writers.base.WriterBase', | |
163 | help="""Instance of the writer class used to write the |
|
163 | help="""Instance of the writer class used to write the | |
164 | results of the conversion.""") |
|
164 | results of the conversion.""", allow_none=True) | |
165 | writer_class = DottedObjectName('FilesWriter', config=True, |
|
165 | writer_class = DottedObjectName('FilesWriter', config=True, | |
166 | help="""Writer class used to write the |
|
166 | help="""Writer class used to write the | |
167 | results of the conversion""") |
|
167 | results of the conversion""") | |
168 | writer_aliases = {'fileswriter': 'jupyter_nbconvert.writers.files.FilesWriter', |
|
168 | writer_aliases = {'fileswriter': 'jupyter_nbconvert.writers.files.FilesWriter', | |
169 | 'debugwriter': 'jupyter_nbconvert.writers.debug.DebugWriter', |
|
169 | 'debugwriter': 'jupyter_nbconvert.writers.debug.DebugWriter', | |
170 | 'stdoutwriter': 'jupyter_nbconvert.writers.stdout.StdoutWriter'} |
|
170 | 'stdoutwriter': 'jupyter_nbconvert.writers.stdout.StdoutWriter'} | |
171 | writer_factory = Type() |
|
171 | writer_factory = Type(allow_none=True) | |
172 |
|
172 | |||
173 | def _writer_class_changed(self, name, old, new): |
|
173 | def _writer_class_changed(self, name, old, new): | |
174 | if new.lower() in self.writer_aliases: |
|
174 | if new.lower() in self.writer_aliases: | |
@@ -178,13 +178,13 b' class NbConvertApp(BaseIPythonApplication):' | |||||
178 | # Post-processor specific variables |
|
178 | # Post-processor specific variables | |
179 | postprocessor = Instance('jupyter_nbconvert.postprocessors.base.PostProcessorBase', |
|
179 | postprocessor = Instance('jupyter_nbconvert.postprocessors.base.PostProcessorBase', | |
180 | help="""Instance of the PostProcessor class used to write the |
|
180 | help="""Instance of the PostProcessor class used to write the | |
181 | results of the conversion.""") |
|
181 | results of the conversion.""", allow_none=True) | |
182 |
|
182 | |||
183 | postprocessor_class = DottedOrNone(config=True, |
|
183 | postprocessor_class = DottedOrNone(config=True, | |
184 | help="""PostProcessor class used to write the |
|
184 | help="""PostProcessor class used to write the | |
185 | results of the conversion""") |
|
185 | results of the conversion""") | |
186 | postprocessor_aliases = {'serve': 'jupyter_nbconvert.postprocessors.serve.ServePostProcessor'} |
|
186 | postprocessor_aliases = {'serve': 'jupyter_nbconvert.postprocessors.serve.ServePostProcessor'} | |
187 | postprocessor_factory = Type() |
|
187 | postprocessor_factory = Type(allow_none=True) | |
188 |
|
188 | |||
189 | def _postprocessor_class_changed(self, name, old, new): |
|
189 | def _postprocessor_class_changed(self, name, old, new): | |
190 | if new.lower() in self.postprocessor_aliases: |
|
190 | if new.lower() in self.postprocessor_aliases: |
@@ -87,7 +87,7 b' def signature_removed(nb):' | |||||
87 | class NotebookNotary(LoggingConfigurable): |
|
87 | class NotebookNotary(LoggingConfigurable): | |
88 | """A class for computing and verifying notebook signatures.""" |
|
88 | """A class for computing and verifying notebook signatures.""" | |
89 |
|
89 | |||
90 | profile_dir = Instance("IPython.core.profiledir.ProfileDir") |
|
90 | profile_dir = Instance("IPython.core.profiledir.ProfileDir", allow_none=True) | |
91 | def _profile_dir_default(self): |
|
91 | def _profile_dir_default(self): | |
92 | from IPython.core.application import BaseIPythonApplication |
|
92 | from IPython.core.application import BaseIPythonApplication | |
93 | app = None |
|
93 | app = None | |
@@ -388,7 +388,7 b' class TrustNotebookApp(BaseIPythonApplication):' | |||||
388 | """ |
|
388 | """ | |
389 | ) |
|
389 | ) | |
390 |
|
390 | |||
391 | notary = Instance(NotebookNotary) |
|
391 | notary = Instance(NotebookNotary, allow_none=True) | |
392 | def _notary_default(self): |
|
392 | def _notary_default(self): | |
393 | return NotebookNotary(parent=self, profile_dir=self.profile_dir) |
|
393 | return NotebookNotary(parent=self, profile_dir=self.profile_dir) | |
394 |
|
394 |
@@ -145,7 +145,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
145 | _ExecutionRequest = namedtuple('_ExecutionRequest', ['id', 'kind']) |
|
145 | _ExecutionRequest = namedtuple('_ExecutionRequest', ['id', 'kind']) | |
146 | _input_splitter_class = InputSplitter |
|
146 | _input_splitter_class = InputSplitter | |
147 | _local_kernel = False |
|
147 | _local_kernel = False | |
148 | _highlighter = Instance(FrontendHighlighter) |
|
148 | _highlighter = Instance(FrontendHighlighter, allow_none=True) | |
149 |
|
149 | |||
150 | #--------------------------------------------------------------------------- |
|
150 | #--------------------------------------------------------------------------- | |
151 | # 'object' interface |
|
151 | # 'object' interface |
General Comments 0
You need to be logged in to leave comments.
Login now