From 56c97fc49a3783dd33e7ec8435780691939df44c 2012-06-12 16:09:10 From: MinRK Date: 2012-06-12 16:09:10 Subject: [PATCH] Use NoDB by default adds shortcuts, so you can specify "DictDB", rather than "full.path.to.DictDB". --- diff --git a/IPython/parallel/apps/ipcontrollerapp.py b/IPython/parallel/apps/ipcontrollerapp.py index da9070a..fd6541f 100755 --- a/IPython/parallel/apps/ipcontrollerapp.py +++ b/IPython/parallel/apps/ipcontrollerapp.py @@ -110,10 +110,11 @@ flags.update({ 'nodb' : ({'HubFactory' : {'db_class' : 'IPython.parallel.controller.dictdb.NoDB'}}, """use dummy DB backend, which doesn't store any information. - This can be used to prevent growth of the memory footprint of the Hub - in cases where its record-keeping is not required. Requesting results - of tasks submitted by other clients, db_queries, and task resubmission - will not be available."""), + This is the default as of IPython 0.13. + + To enable delayed or repeated retrieval of results from the Hub, + select one of the true db backends. + """), 'reuse' : ({'IPControllerApp' : {'reuse_files' : True}}, 'reuse existing json connection files') }) @@ -138,7 +139,6 @@ aliases = dict( aliases.update(base_aliases) aliases.update(session_aliases) - class IPControllerApp(BaseParallelApplication): name = u'ipcontroller' diff --git a/IPython/parallel/controller/dictdb.py b/IPython/parallel/controller/dictdb.py index 93fbd29..fd8be3f 100644 --- a/IPython/parallel/controller/dictdb.py +++ b/IPython/parallel/controller/dictdb.py @@ -184,6 +184,10 @@ class DictDB(BaseDB): msg_ids = self._records.keys() return sorted(msg_ids, key=lambda m: self._records[m]['submitted']) +NODATA = KeyError("NoDB backend doesn't store any data. " +"Start the Controller with a DB backend to enable resubmission / result persistence." +) + class NoDB(DictDB): """A blackhole db backend that actually stores no information. @@ -197,7 +201,7 @@ class NoDB(DictDB): pass def get_record(self, msg_id): - raise KeyError("NoDB does not support record access") + raise NODATA def update_record(self, msg_id, record): pass @@ -209,8 +213,8 @@ class NoDB(DictDB): pass def find_records(self, check, keys=None): - raise KeyError("NoDB does not store information") + raise NODATA def get_history(self): - raise KeyError("NoDB does not store information") + raise NODATA diff --git a/IPython/parallel/controller/hub.py b/IPython/parallel/controller/hub.py index fa3c52e..cf1ad74 100644 --- a/IPython/parallel/controller/hub.py +++ b/IPython/parallel/controller/hub.py @@ -119,6 +119,13 @@ class EngineConnector(HasTraits): heartbeat=CBytes() pending=Set() +_db_shortcuts = { + 'sqlitedb' : 'IPython.parallel.controller.sqlitedb.SQLiteDB', + 'mongodb' : 'IPython.parallel.controller.mongodb.MongoDB', + 'dictdb' : 'IPython.parallel.controller.dictdb.DictDB', + 'nodb' : 'IPython.parallel.controller.dictdb.NoDB', +} + class HubFactory(RegistrationFactory): """The Configurable for setting up a Hub.""" @@ -181,8 +188,17 @@ class HubFactory(RegistrationFactory): monitor_url = Unicode('') - db_class = DottedObjectName('IPython.parallel.controller.dictdb.DictDB', - config=True, help="""The class to use for the DB backend""") + db_class = DottedObjectName('NoDB', + config=True, help="""The class to use for the DB backend + + Options include: + + SQLiteDB: SQLite + MongoDB : use MongoDB + DictDB : in-memory storage (fastest, but be mindful of memory growth of the Hub) + NoDB : disable database altogether (default) + + """) # not configurable db = Instance('IPython.parallel.controller.dictdb.BaseDB') @@ -258,9 +274,9 @@ class HubFactory(RegistrationFactory): sub = ZMQStream(sub, loop) # connect the db - self.log.info('Hub using DB backend: %r'%(self.db_class.split()[-1])) - # cdir = self.config.Global.cluster_dir - self.db = import_item(str(self.db_class))(session=self.session.session, + db_class = _db_shortcuts.get(self.db_class.lower(), self.db_class) + self.log.info('Hub using DB backend: %r', (db_class.split('.')[-1])) + self.db = import_item(str(db_class))(session=self.session.session, config=self.config, log=self.log) time.sleep(.25) try: diff --git a/IPython/parallel/tests/__init__.py b/IPython/parallel/tests/__init__.py index 6e03b8c..acb8845 100644 --- a/IPython/parallel/tests/__init__.py +++ b/IPython/parallel/tests/__init__.py @@ -57,7 +57,7 @@ def setup(): cp = TestProcessLauncher() cp.cmd_and_args = ipcontroller_cmd_argv + \ - ['--profile=iptest', '--log-level=50', '--ping=250'] + ['--profile=iptest', '--log-level=50', '--ping=250', '--dictdb'] cp.start() launchers.append(cp) tic = time.time()