Skip to content

Commit 56c97fc

Browse files
committed
Use NoDB by default
adds shortcuts, so you can specify "DictDB", rather than "full.path.to.DictDB".
1 parent 367cb43 commit 56c97fc

4 files changed

Lines changed: 34 additions & 14 deletions

File tree

IPython/parallel/apps/ipcontrollerapp.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@
110110
'nodb' : ({'HubFactory' : {'db_class' : 'IPython.parallel.controller.dictdb.NoDB'}},
111111
"""use dummy DB backend, which doesn't store any information.
112112
113-
This can be used to prevent growth of the memory footprint of the Hub
114-
in cases where its record-keeping is not required. Requesting results
115-
of tasks submitted by other clients, db_queries, and task resubmission
116-
will not be available."""),
113+
This is the default as of IPython 0.13.
114+
115+
To enable delayed or repeated retrieval of results from the Hub,
116+
select one of the true db backends.
117+
"""),
117118
'reuse' : ({'IPControllerApp' : {'reuse_files' : True}},
118119
'reuse existing json connection files')
119120
})
@@ -138,7 +139,6 @@
138139
aliases.update(base_aliases)
139140
aliases.update(session_aliases)
140141

141-
142142
class IPControllerApp(BaseParallelApplication):
143143

144144
name = u'ipcontroller'

IPython/parallel/controller/dictdb.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ def get_history(self):
184184
msg_ids = self._records.keys()
185185
return sorted(msg_ids, key=lambda m: self._records[m]['submitted'])
186186

187+
NODATA = KeyError("NoDB backend doesn't store any data. "
188+
"Start the Controller with a DB backend to enable resubmission / result persistence."
189+
)
190+
187191
class NoDB(DictDB):
188192
"""A blackhole db backend that actually stores no information.
189193
@@ -197,7 +201,7 @@ def add_record(self, msg_id, record):
197201
pass
198202

199203
def get_record(self, msg_id):
200-
raise KeyError("NoDB does not support record access")
204+
raise NODATA
201205

202206
def update_record(self, msg_id, record):
203207
pass
@@ -209,8 +213,8 @@ def drop_record(self, msg_id):
209213
pass
210214

211215
def find_records(self, check, keys=None):
212-
raise KeyError("NoDB does not store information")
216+
raise NODATA
213217

214218
def get_history(self):
215-
raise KeyError("NoDB does not store information")
219+
raise NODATA
216220

IPython/parallel/controller/hub.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ class EngineConnector(HasTraits):
119119
heartbeat=CBytes()
120120
pending=Set()
121121

122+
_db_shortcuts = {
123+
'sqlitedb' : 'IPython.parallel.controller.sqlitedb.SQLiteDB',
124+
'mongodb' : 'IPython.parallel.controller.mongodb.MongoDB',
125+
'dictdb' : 'IPython.parallel.controller.dictdb.DictDB',
126+
'nodb' : 'IPython.parallel.controller.dictdb.NoDB',
127+
}
128+
122129
class HubFactory(RegistrationFactory):
123130
"""The Configurable for setting up a Hub."""
124131

@@ -181,8 +188,17 @@ def _notifier_port_default(self):
181188

182189
monitor_url = Unicode('')
183190

184-
db_class = DottedObjectName('IPython.parallel.controller.dictdb.DictDB',
185-
config=True, help="""The class to use for the DB backend""")
191+
db_class = DottedObjectName('NoDB',
192+
config=True, help="""The class to use for the DB backend
193+
194+
Options include:
195+
196+
SQLiteDB: SQLite
197+
MongoDB : use MongoDB
198+
DictDB : in-memory storage (fastest, but be mindful of memory growth of the Hub)
199+
NoDB : disable database altogether (default)
200+
201+
""")
186202

187203
# not configurable
188204
db = Instance('IPython.parallel.controller.dictdb.BaseDB')
@@ -258,9 +274,9 @@ def init_hub(self):
258274
sub = ZMQStream(sub, loop)
259275

260276
# connect the db
261-
self.log.info('Hub using DB backend: %r'%(self.db_class.split()[-1]))
262-
# cdir = self.config.Global.cluster_dir
263-
self.db = import_item(str(self.db_class))(session=self.session.session,
277+
db_class = _db_shortcuts.get(self.db_class.lower(), self.db_class)
278+
self.log.info('Hub using DB backend: %r', (db_class.split('.')[-1]))
279+
self.db = import_item(str(db_class))(session=self.session.session,
264280
config=self.config, log=self.log)
265281
time.sleep(.25)
266282
try:

IPython/parallel/tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def setup():
5757

5858
cp = TestProcessLauncher()
5959
cp.cmd_and_args = ipcontroller_cmd_argv + \
60-
['--profile=iptest', '--log-level=50', '--ping=250']
60+
['--profile=iptest', '--log-level=50', '--ping=250', '--dictdb']
6161
cp.start()
6262
launchers.append(cp)
6363
tic = time.time()

0 commit comments

Comments
 (0)