[yt-svn] commit/yt: MatthewTurk: Merged in ChrisMalone/yt (pull request #1199)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Sep 20 12:47:50 PDT 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/08157f94abc7/
Changeset:   08157f94abc7
Branch:      yt
User:        MatthewTurk
Date:        2014-09-20 19:47:43+00:00
Summary:     Merged in ChrisMalone/yt (pull request #1199)

add option to suppress logging when in parallel
Affected #:  1 file

diff -r d51b1eef25de78251872054e764e2428ff220c13 -r 08157f94abc7612236f73b240503050044035f46 yt/utilities/parallel_tools/parallel_analysis_interface.py
--- a/yt/utilities/parallel_tools/parallel_analysis_interface.py
+++ b/yt/utilities/parallel_tools/parallel_analysis_interface.py
@@ -53,9 +53,28 @@
         max = "MPI.MAX"
 )
 
+class FilterAllMessages(logging.Filter):
+    """
+    This is a simple filter for logging.Logger's that won't let any 
+    messages pass.
+    """
+    def filter(self, record):
+        return 0
+
 # Set up translation table and import things
 
-def enable_parallelism():
+def enable_parallelism(suppress_logging=False):
+    """
+    This method is used inside a script to turn on MPI parallelism, via 
+    mpi4py.  More information about running yt in parallel can be found
+    here: http://yt-project.org/docs/3.0/analyzing/parallel_computation.html
+    
+    Parameters
+    ----------
+    suppress_logging : bool
+       If set to True, only rank 0 will log information after the initial
+       setup of MPI.
+    """
     global parallel_capable, MPI
     try:
         from mpi4py import MPI as _MPI
@@ -104,6 +123,10 @@
         min = MPI.MIN,
         max = MPI.MAX
     ))
+    # Turn off logging on all but the root rank, if specified.
+    if suppress_logging:
+        if MPI.COMM_WORLD.rank > 0:
+            mylog.addFilter(FilterAllMessages())
     return True
 
 # Because the dtypes will == correctly but do not hash the same, we need this

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list