From 9a985feca5d447559e4d7a631b1f635991a53b0a 2012-02-03 19:57:49 From: Ben Edwards Date: 2012-02-03 19:57:49 Subject: [PATCH] Adds a quiet keyword to sync_imports to allow users to surpress messages about imports on remote engines. --- diff --git a/IPython/parallel/client/view.py b/IPython/parallel/client/view.py index 60388b1..b354955 100644 --- a/IPython/parallel/client/view.py +++ b/IPython/parallel/client/view.py @@ -401,13 +401,16 @@ class DirectView(View): return self.sync_imports(True) @contextmanager - def sync_imports(self, local=True): + def sync_imports(self, local=True, quiet=False): """Context Manager for performing simultaneous local and remote imports. 'import x as y' will *not* work. The 'as y' part will simply be ignored. If `local=True`, then the package will also be imported locally. + If `quiet=True`, then no message concerning the success of import will be + reported. + Note that remote-only (`local=False`) imports have not been implemented. >>> with view.sync_imports(): @@ -456,10 +459,11 @@ class DirectView(View): key = name+':'+','.join(fromlist or []) if level == -1 and key not in modules: modules.add(key) - if fromlist: - print "importing %s from %s on engine(s)"%(','.join(fromlist), name) - else: - print "importing %s on engine(s)"%name + if not quiet: + if fromlist: + print "importing %s from %s on engine(s)"%(','.join(fromlist), name) + else: + print "importing %s on engine(s)"%name results.append(self.apply_async(remote_import, name, fromlist, level)) # restore override __builtin__.__import__ = save_import