def PTdF(self, delim=" "): """Returns a string that contains the information about the application in PTdF format""" toWrite = "Application" + delim + cws(self.name) + "\n" for (n,v) in self.attributes: toWrite += "ResourceAttribute" + delim + cws(self.name) \ + delim + cws(n) + delim + cws(v) + delim + "string" + "\n" return toWrite
def PTdF(self, exeName=None, delim="\t"): """Returns a string that contains the information about the resource in PTdF format""" toWrite = "" resConstraints = "" if self.type != "execution" : toWrite = "Resource" + delim + cws(self.name) + delim \ + cws(self.type) + delim if exeName != None: toWrite += cws(exeName) + "\n" for (n,v,t) in self.attributes: # for now resource attributes of type "resource" are written out as # resource constraints. Later they will be written out as attrs # of type "resource" if t == "string": toWrite += "ResourceAttribute" + delim + cws(self.name) + delim \ + cws(n) + delim + cws(v) + delim + cws(t) + "\n" else: resConstraints += "ResourceConstraint" + delim + cws(self.name) + \ delim + cws(v) + "\n" # write perf results for non-execution resources perfRs = "" if self.type != "execution": perfReses = [] #print "Resource.PTdF: There are %d non-exec perf results." % len(self.performanceResults) for p in self.performanceResults: #print "Resource.PTdF: perfResults for non-exec resource: %s" % p perfReses.append(p.PTdF(self.name,delim,"nonExec")) perfRs = ''.join(perfReses) return toWrite, perfRs, resConstraints
def PTdF(self, exeName, delim="\t", type=None): """Returns a string with the information of the performance result in PTdF format""" if type == None: toWrite = "PerfResult" + delim + cws(exeName) + delim elif type == "nonExec": toWrite = "Result" + delim + cws(exeName) + delim focusname = "" first = True for flist,type in self.focus: if first: first = False else: focusname += "::" # this is the delimiter between foci for f in flist: focusname += f.name + "," # this is the delim b/w focus names focusname = focusname.rstrip(',') # get rid of last comma if len(self.focus) != 1: # if there's just one focus, it's primary focusname += "(" + type + ")" toWrite += cws(focusname) + delim + cws(self.performanceTool.name) + delim toWrite += cws(self.metric.name) + delim + cws(self.value) + delim \ + cws(self.units) + delim toWrite += cws(self.startTime) + delim + cws(self.endTime) + "\n" return toWrite
def PTdF(self, exeName=None, delim="\t"): """Returns a string that contains the information about the resource in PTdF format""" toWrite = "" resConstraints = "" if self.type != "execution": toWrite = "Resource" + delim + cws(self.name) + delim \ + cws(self.type) + delim if exeName != None: toWrite += cws(exeName) + "\n" for (n, v, t) in self.attributes: # for now resource attributes of type "resource" are written out as # resource constraints. Later they will be written out as attrs # of type "resource" if t == "string": toWrite += "ResourceAttribute" + delim + cws(self.name) + delim \ + cws(n) + delim + cws(v) + delim + cws(t) + "\n" else: resConstraints += "ResourceConstraint" + delim + cws(self.name) + \ delim + cws(v) + "\n" # write perf results for non-execution resources perfRs = "" if self.type != "execution": perfReses = [] #print "Resource.PTdF: There are %d non-exec perf results." % len(self.performanceResults) for p in self.performanceResults: #print "Resource.PTdF: perfResults for non-exec resource: %s" % p perfReses.append(p.PTdF(self.name, delim, "nonExec")) perfRs = ''.join(perfReses) return toWrite, perfRs, resConstraints
def PTdF(self, exeName, delim="\t", type=None): """Returns a string with the information of the performance result in PTdF format""" if type == None: toWrite = "PerfResult" + delim + cws(exeName) + delim elif type == "nonExec": toWrite = "Result" + delim + cws(exeName) + delim focusname = "" first = True for flist, type in self.focus: if first: first = False else: focusname += "::" # this is the delimiter between foci for f in flist: focusname += f.name + "," # this is the delim b/w focus names focusname = focusname.rstrip(',') # get rid of last comma if len(self.focus) != 1: # if there's just one focus, it's primary focusname += "(" + type + ")" toWrite += cws(focusname) + delim + cws( self.performanceTool.name) + delim toWrite += cws(self.metric.name) + delim + cws(self.value) + delim \ + cws(self.units) + delim toWrite += cws(self.startTime) + delim + cws(self.endTime) + "\n" return toWrite
def PTdF(self, appName, delim="\t"): """Returns a string that contains the information about the Execution in PTdF format""" #print "Execution.PTdF: called" # write this execution resConstraints = "" toWrite = "Execution" + delim + cws(self.name) + delim \ + cws(appName) + "\n" # write any attributes of this execution attrstr,ignore, resConst = Resource.PTdF(self,self.name, delim) toWrite += attrstr resConstraints += resConst # write the perf results perfReses = [] for p in self.performanceResults: perfReses.append(p.PTdF(self.name,delim)) perfRs = ''.join(perfReses) return toWrite, perfRs, resConstraints
def PTdF(self, appName, delim="\t"): """Returns a string that contains the information about the Execution in PTdF format""" #print "Execution.PTdF: called" # write this execution resConstraints = "" toWrite = "Execution" + delim + cws(self.name) + delim \ + cws(appName) + "\n" # write any attributes of this execution attrstr, ignore, resConst = Resource.PTdF(self, self.name, delim) toWrite += attrstr resConstraints += resConst # write the perf results perfReses = [] for p in self.performanceResults: perfReses.append(p.PTdF(self.name, delim)) perfRs = ''.join(perfReses) return toWrite, perfRs, resConstraints
def PTdF(self, delim=" "): # returns a list of strings to write to the ptdf file. # the strings should be written in the order that they are returned. # order of writing here is important # first resource types # then application # then execution # then resources and their attributes of type string, resources listed # in lexicographical order # then any resource attributes that are of type resource # then performance results # gather all resources and string attributes to write in a list # this is done for performance. At the end the lists are 'joined'. resAndAttrs = [] # perf results list perfReses = [] # special list for resource attributes of type resource to make sure # they get printed last. Right now they are printed as resource # constraints resConstr = [] # gather types types = self.getAllResourceTypes() for t in types: pt_str = "ResourceType" + delim + cws(t) + "\n" resAndAttrs.append(pt_str) # see if there's application and execution data try: # expect one application resource [app] = self.findResourcesByType("application") pt_str = app.PTdF() resAndAttrs.append(pt_str) # expect one execution resource [exe] = self.findResourcesByType("execution") pt_str,perfRes_str,attr_str = exe.PTdF(app.name, delim) resAndAttrs.append(pt_str) perfReses.append(perfRes_str) resConstr.append(attr_str) except: # there is no application and/or execution for this data. # this can happen if we are processing machine data app = None exe = None reses = self.getResourcesSortedByName() for r in reses: if r == exe or r == app: pass elif exe: # is there an execution resource for this data? pt_str, perfRes_str, attr_str = r.PTdF(exe.name, delim) resAndAttrs.append(pt_str) perfReses.append(perfRes_str) resConstr.append(attr_str) else: pt_str, perfRes_str, attr_str = r.PTdF("", delim) resAndAttrs.append(pt_str) perfReses.append(perfRes_str) resConstr.append(attr_str) resAndAttrs = ''.join(resAndAttrs) resConstr = ''.join(resConstr) perfReses = ''.join(perfReses) return [resAndAttrs,resConstr,perfReses]
def PTdF(self, delim=" "): # returns a list of strings to write to the ptdf file. # the strings should be written in the order that they are returned. # order of writing here is important # first resource types # then application # then execution # then resources and their attributes of type string, resources listed # in lexicographical order # then any resource attributes that are of type resource # then performance results # gather all resources and string attributes to write in a list # this is done for performance. At the end the lists are 'joined'. resAndAttrs = [] # perf results list perfReses = [] # special list for resource attributes of type resource to make sure # they get printed last. Right now they are printed as resource # constraints resConstr = [] # gather types types = self.getAllResourceTypes() for t in types: pt_str = "ResourceType" + delim + cws(t) + "\n" resAndAttrs.append(pt_str) # see if there's application and execution data try: # expect one application resource [app] = self.findResourcesByType("application") pt_str = app.PTdF() resAndAttrs.append(pt_str) # expect one execution resource [exe] = self.findResourcesByType("execution") pt_str, perfRes_str, attr_str = exe.PTdF(app.name, delim) resAndAttrs.append(pt_str) perfReses.append(perfRes_str) resConstr.append(attr_str) except: # there is no application and/or execution for this data. # this can happen if we are processing machine data app = None exe = None reses = self.getResourcesSortedByName() for r in reses: if r == exe or r == app: pass elif exe: # is there an execution resource for this data? pt_str, perfRes_str, attr_str = r.PTdF(exe.name, delim) resAndAttrs.append(pt_str) perfReses.append(perfRes_str) resConstr.append(attr_str) else: pt_str, perfRes_str, attr_str = r.PTdF("", delim) resAndAttrs.append(pt_str) perfReses.append(perfRes_str) resConstr.append(attr_str) resAndAttrs = ''.join(resAndAttrs) resConstr = ''.join(resConstr) perfReses = ''.join(perfReses) return [resAndAttrs, resConstr, perfReses]