From aeca882c81b8cc68453062a64a1a9ff7c7fbdef0 2011-06-21 15:55:05 From: Thomas Kluyver Date: 2011-06-21 15:55:05 Subject: [PATCH] Use DottedObjectName traits in zmq and parallel modules. --- diff --git a/IPython/parallel/apps/ipclusterapp.py b/IPython/parallel/apps/ipclusterapp.py index d075312..f730d5d 100755 --- a/IPython/parallel/apps/ipclusterapp.py +++ b/IPython/parallel/apps/ipclusterapp.py @@ -37,7 +37,8 @@ from IPython.core.application import BaseIPythonApplication from IPython.core.profiledir import ProfileDir from IPython.utils.daemonize import daemonize from IPython.utils.importstring import import_item -from IPython.utils.traitlets import Int, Unicode, Bool, CFloat, Dict, List +from IPython.utils.traitlets import (Int, Unicode, Bool, CFloat, Dict, List, + DottedObjectName) from IPython.parallel.apps.baseapp import ( BaseParallelApplication, @@ -198,7 +199,7 @@ class IPClusterEngines(BaseParallelApplication): n = Int(2, config=True, help="The number of engines to start.") - engine_launcher_class = Unicode('LocalEngineSetLauncher', + engine_launcher_class = DottedObjectName('LocalEngineSetLauncher', config=True, help="The class for launching a set of Engines." ) @@ -330,7 +331,7 @@ class IPClusterStart(IPClusterEngines): delay = CFloat(1., config=True, help="delay (in s) between starting the controller and the engines") - controller_launcher_class = Unicode('LocalControllerLauncher', + controller_launcher_class = DottedObjectName('LocalControllerLauncher', config=True, help="The class for launching a Controller." ) diff --git a/IPython/parallel/controller/hub.py b/IPython/parallel/controller/hub.py index 97ab439..caf39fa 100755 --- a/IPython/parallel/controller/hub.py +++ b/IPython/parallel/controller/hub.py @@ -30,7 +30,7 @@ from zmq.eventloop.zmqstream import ZMQStream # internal: from IPython.utils.importstring import import_item from IPython.utils.traitlets import ( - HasTraits, Instance, Int, Unicode, Dict, Set, Tuple, Bytes + HasTraits, Instance, Int, Unicode, Dict, Set, Tuple, Bytes, DottedObjectName ) from IPython.parallel import error, util @@ -179,8 +179,8 @@ class HubFactory(RegistrationFactory): monitor_url = Unicode('') - db_class = Unicode('IPython.parallel.controller.dictdb.DictDB', config=True, - help="""The class to use for the DB backend""") + db_class = DottedObjectName('IPython.parallel.controller.dictdb.DictDB', + config=True, help="""The class to use for the DB backend""") # not configurable db = Instance('IPython.parallel.controller.dictdb.BaseDB') diff --git a/IPython/zmq/kernelapp.py b/IPython/zmq/kernelapp.py index 43112c6..d36d36d 100644 --- a/IPython/zmq/kernelapp.py +++ b/IPython/zmq/kernelapp.py @@ -30,7 +30,8 @@ from IPython.core.application import ( ) from IPython.utils import io from IPython.utils.localinterfaces import LOCALHOST -from IPython.utils.traitlets import Any, Instance, Dict, Unicode, Int, Bool +from IPython.utils.traitlets import (Any, Instance, Dict, Unicode, Int, Bool, + DottedObjectName) from IPython.utils.importstring import import_item # local imports from IPython.zmq.heartbeat import Heartbeat @@ -75,7 +76,7 @@ class KernelApp(BaseIPythonApplication): flags = Dict(kernel_flags) classes = [Session] # the kernel class, as an importstring - kernel_class = Unicode('IPython.zmq.pykernel.Kernel') + kernel_class = DottedObjectName('IPython.zmq.pykernel.Kernel') kernel = Any() poller = Any() # don't restrict this even though current pollers are all Threads heartbeat = Instance(Heartbeat) @@ -93,10 +94,10 @@ class KernelApp(BaseIPythonApplication): # streams, etc. no_stdout = Bool(False, config=True, help="redirect stdout to the null device") no_stderr = Bool(False, config=True, help="redirect stderr to the null device") - outstream_class = Unicode('IPython.zmq.iostream.OutStream', config=True, - help="The importstring for the OutStream factory") - displayhook_class = Unicode('IPython.zmq.displayhook.DisplayHook', config=True, - help="The importstring for the DisplayHook factory") + outstream_class = DottedObjectName('IPython.zmq.iostream.OutStream', + config=True, help="The importstring for the OutStream factory") + displayhook_class = DottedObjectName('IPython.zmq.displayhook.DisplayHook', + config=True, help="The importstring for the DisplayHook factory") # polling parent = Int(0, config=True, diff --git a/IPython/zmq/session.py b/IPython/zmq/session.py index 6ca4be2..48c31fd 100644 --- a/IPython/zmq/session.py +++ b/IPython/zmq/session.py @@ -47,7 +47,8 @@ from zmq.eventloop.zmqstream import ZMQStream from IPython.config.configurable import Configurable, LoggingConfigurable from IPython.utils.importstring import import_item from IPython.utils.jsonutil import extract_dates, squash_dates, date_default -from IPython.utils.traitlets import Bytes, Unicode, Bool, Any, Instance, Set +from IPython.utils.traitlets import (Bytes, Unicode, Bool, Any, Instance, Set, + DottedObjectName) #----------------------------------------------------------------------------- # utility functions @@ -211,7 +212,7 @@ class Session(Configurable): debug=Bool(False, config=True, help="""Debug output in the Session""") - packer = Unicode('json',config=True, + packer = DottedObjectName('json',config=True, help="""The name of the packer for serializing messages. Should be one of 'json', 'pickle', or an import name for a custom callable serializer.""") @@ -225,7 +226,7 @@ class Session(Configurable): else: self.pack = import_item(str(new)) - unpacker = Unicode('json', config=True, + unpacker = DottedObjectName('json', config=True, help="""The name of the unpacker for unserializing messages. Only used with custom functions for `packer`.""") def _unpacker_changed(self, name, old, new):