Source
xxxxxxxxxx
print 'Ending use of cluster, but not closing it. Call clustermanager.stop_cluster() to close it if needed.'
import os
import commands
import math
import shutil
import string
import time
import re;
from taskinit import *
import copy
'''
A set of helper functions for the tasks tclean
Summary...
'''
#############################################
### Parallel Imager Helper.
#############################################
#casalog.post('Using clustermanager from MPIInterface', 'WARN')
from mpi4casa.MPIInterface import MPIInterface as mpi_clustermanager
class PyParallelImagerHelper():
def __init__(self):
############### Cluster Info
self.CL=None
self.sc=None
self.nodeList=None;
# Initialize cluster, and partitioning.
############### Number of nodes to parallelize on
# self.nodeList gets filled by setupCluster()
self.NN = self.setupCluster()
def getNodeList(self):
return self.nodeList;
#############################################
def chunkify(self,lst,n):
return [ lst[i::n] for i in xrange(n) ]
def partitionCFCacheList(self,gridPars):
cfcName = gridPars['cfcache'];
cflist=[];
if (not (cfcName == '')):
cflist=[f for f in os.listdir(cfcName) if re.match(r'CFS*', f)];
nCF = len(cflist);
nProcs=len(self.nodeList);
if (nProcs > nCF):
n=nCF;
else:
n=nProcs;
if (nCF > 0):
casalog.post("########################################################");
casalog.post("nCF = " + str(nCF) + " nProcs = " + str(n) + " NodeList=" + str(self.nodeList));
casalog.post("########################################################");
xx=self.chunkify(cflist,n);
allcfs={};