def process(_listInputFile, _output, dummy=0, autoscale=False, center=None, width=None, blending=None, mask=None): """ call EDNA with this options: @param _listInputFile: list of input files as strings @param _output: output file name @param dummy: value for dummy pixels @param autoscale: shall image intensity be scaled (boolean) @param center: 2-list of int representing the center of the ROI @param width: 2-list of int representing the width of the ROI @param blending: blending method: max, mean or min @param mask: name of the file containing the mask """ xsd = XSDataInputStitchImage() xsd.dummyValue = XSDataDouble(dummy) xsd.autoscale = XSDataBoolean(autoscale) if blending: xsd.blending = XSDataString(blending) if mask: xsd.mask = XSDataImage(XSDataString(mask)) xsd.outputImage = XSDataImage(XSDataString(_output)) xsd.inputImages = [XSDataImage(XSDataString(i)) for i in _listInputFile] if isinstance(width, list): xsd.widthROI = [XSDataInteger(i) for i in width] if isinstance(center, list): xsd.centerROI = [XSDataInteger(i) for i in center] job = EDJob(EDNAPluginName) job.setDataInput(xsd) job.execute()
def unitTestExecute(self): """ check the execution of a job (without callback) """ EDVerbose.DEBUG("EDTestCaseEDJob.unitTestExecute") edJob = EDJob(self.strPluginName) strJobId = edJob.getJobId() edJob.setDataInput(self.strXmlInput) ref = edJob.execute() EDAssert.equal(strJobId, ref, "JobId has not changed") strStatus = edJob.getStatus() EDVerbose.WARNING("Job %s in State %s" % (strJobId, strStatus)) while strStatus in ["running", "uninitialized"]: EDVerbose.WARNING("Job %s in state %s" % (strJobId, strStatus)) time.sleep(0.01) strStatus = edJob.getStatus() xsdOut = edJob.getDataOutput() while xsdOut is None: EDVerbose.WARNING("No Output data, still waiting for output data to arrive, %s" % edJob.getStatus()) time.sleep(0.01) xsdOut = edJob.getDataOutput() strOutput = xsdOut.strip() strStatus = edJob.getStatus() while strStatus == "running": EDVerbose.WARNING("Job %s is still in state %s" % (strJobId, strStatus)) time.sleep(0.01) strStatus = edJob.getStatus() EDAssert.equal(strOutput, self.strXmlInput, "Output is OK") EDAssert.equal("success", edJob.getStatus(), "Job %s is finished with ''success''" % edJob.getJobId())
def unitTestExecuteCallbackSuccess(self): """ check the execution of a job (without callback) """ EDVerbose.DEBUG("EDTestCaseEDJob.unitTestExecuteCallbackSuccess") edJob = EDJob(self.strPluginName) edJob.connectSUCCESS(self.callBack) edJob.setDataInput(self.strXmlInput) strJobId = edJob.execute() strStatus = edJob.getStatus() EDVerbose.DEBUG("Job %s in State ''%s''" % (strJobId, strStatus))
def start(self, _strXmlInput): """ Launch EDNA with the given XML stream @param _strXmlInput: XML to be passed to the plugin @type _strXmlInput: python string representing the XML data structure """ jobid = None if _strXmlInput not in ["", None]: job = EDJob(self.__strPluginName) job.setDataInput(_strXmlInput) job.connectFAILURE(self.failureJobExecution) job.connectSUCCESS(self.successJobExecution) job.connectCallBack(self.unregisterJob) self.semaphoreNbThreadsAcquire() jobid = job.execute() self.DEBUG("Running Job id %s" % jobid) if jobid is None: self.semaphoreNbThreadsRelease() return jobid
os.makedirs(working_dir) os.chdir(working_dir) if yappi: yappi.start() for i in fullargs: reprocess.startJob(i) print("All %i jobs queued after %.3fs" % (len(args), time.time() - reprocess.startTime)) reprocess.join() if yappi: yappi.stop() print("All %i jobs processed after %.3fs" % (len(args), time.time() - reprocess.startTime)) print reprocess.statistics() if yappi: stat = yappi.get_stats(sort_type=yappi.SORTTYPE_TTOT) res = {} for i in stat.func_stats: if i[0] in res: res[i[0]][0] += i[1] res[i[0]][1] += i[2] else: res[i[0]] = [i[1], i[2]] keys = res.keys() keys.sort(sortn) with open("yappi.out", "w") as f: f.write("ncall\t\ttotal\t\tpercall\t\tfunction%s" % (os.linesep)) for i in keys: f.write("%8s\t%16s\t%16s\t%s%s" % (res[i][0], res[i][1], res[i][1] / res[i][0], i, os.linesep)) print("Profiling information written in yappi.out") edJob = EDJob(options.plugin.replace("EDPluginBioSaxsHPLC", "EDPluginBioSaxsFlushHPLC")) edJob.setDataInput(open(fullargs[-1], "r").read()) edJob.execute()
listOfPythonFiles = findFile(os.path.join(pyStrEdnaHomePath, oneproject)) listOfPythonFiles.sort() if len(listOfPythonFiles) > 0: epydocJob = EDJob("EDPluginExecEpydocv1_0") dictJobs[oneproject] = epydocJob xsd = XSDataInputEpydoc() xsd.setDocPath(XSDataFile(XSDataString(docPath))) xsd.setProjectName(XSDataString(oneproject)) xsd.setDocType(XSDataString(docFormat)) if bVerbose: xsd.setVerbosity(XSDataInteger(1)) else: xsd.setVerbosity(XSDataInteger(-1)) xsd.setSources([XSDataFile(XSDataString(oneFile)) for oneFile in listOfPythonFiles]) epydocJob.setDataInput(xsd) epydocJob.execute() else: print ("Error: No python files for project %s" % oneproject) else: plugins = findPlugins(pyStrEdnaHomePath) pluginPathProcessed = [] for oneplugin in plugins: pluginPath = plugins[oneplugin] if not pluginPath in pluginPathProcessed: pluginPathProcessed.append(pluginPath) docPath = os.path.join(pluginPath, "doc") if not os.path.isdir(docPath): os.mkdir(docPath) if CleanAll: rmdir(docPath)
def runEdnaPlugin(execPath, pluginName, isDebug, xml, additionalPaths=None): ''' execPath - path to run plugin in pluginName - plugin name isDebug - True if should run edna in debug mode xml - xml input to edna additionalPaths - list of other python path locations You must set EDNA_HOME to use this method This method blocks until the EDJob has reached a final status ''' if (not 'EDNA_HOME' in os.environ): raise Exception("Cannot locate EDNA_HOME. Please set before running Edna plugins.") if (not 'EDNA_SITE' in os.environ): raise Exception(" Please set EDNA_SITE before running Edna plugins.") ''' Add edna to path ''' ednaKernelPath = os.environ['EDNA_HOME']+"/kernel/src" sys.path.insert(0, ednaKernelPath) ''' If there are any additional paths such as fabio, add these ''' if (not additionalPaths is None and len(additionalPaths)>0): for path in additionalPaths: sys.path.append(path) os.chdir(execPath) from EDVerbose import EDVerbose if (isDebug): EDVerbose.setVerboseDebugOn() else: EDVerbose.setVerboseOn() EDVerbose.setVerboseDebugOff() from EDJob import EDJob EDVerbose.setLogFileName(execPath+"/"+pluginName+".log") edJob = EDJob(pluginName) edJob.setDataInput(xml) edJob.execute() edJob.synchronize() # In theory should mean that the following loop is not needed # Unhelpful way of waiting for EDJob to be finished # TODO Fix this in EDJob some time while(True): status = edJob.getStatus() if (status is None): time.sleep(0.2) # 200 ms continue if ("failure" == status): raise Exception("EDJob failed! ") if ("success" == status): break ret = edJob.getDataOutput() return str(ret)
epydocJob = EDJob("EDPluginExecEpydocv1_0") dictJobs[oneproject] = epydocJob xsd = XSDataInputEpydoc() xsd.setDocPath(XSDataFile(XSDataString(docPath))) xsd.setProjectName(XSDataString(oneproject)) xsd.setDocType(XSDataString(docFormat)) if bVerbose: xsd.setVerbosity(XSDataInteger(1)) else: xsd.setVerbosity(XSDataInteger(-1)) xsd.setSources([ XSDataFile(XSDataString(oneFile)) for oneFile in listOfPythonFiles ]) epydocJob.setDataInput(xsd) epydocJob.execute() else: print("Error: No python files for project %s" % oneproject) else: plugins = findPlugins(pyStrEdnaHomePath) pluginPathProcessed = [] for oneplugin in plugins: pluginPath = plugins[oneplugin] if not pluginPath in pluginPathProcessed: pluginPathProcessed.append(pluginPath) docPath = os.path.join(pluginPath, "doc") if not os.path.isdir(docPath): os.mkdir(docPath) if CleanAll: rmdir(docPath)
for i in fullargs: reprocess.startJob(i) print("All %i jobs queued after %.3fs" % (len(args), time.time() - reprocess.startTime)) reprocess.join() if yappi: yappi.stop() print("All %i jobs processed after %.3fs" % (len(args), time.time() - reprocess.startTime)) print reprocess.statistics() if yappi: stat = yappi.get_stats(sort_type=yappi.SORTTYPE_TTOT) res = {} for i in stat.func_stats: if i[0] in res: res[i[0]][0] += i[1] res[i[0]][1] += i[2] else: res[i[0]] = [i[1], i[2]] keys = res.keys() keys.sort(sortn) with open("yappi.out", "w") as f: f.write("ncall\t\ttotal\t\tpercall\t\tfunction%s" % (os.linesep)) for i in keys: f.write("%8s\t%16s\t%16s\t%s%s" % (res[i][0], res[i][1], res[i][1] / res[i][0], i, os.linesep)) print("Profiling information written in yappi.out") edJob = EDJob("EDPluginBioSaxsFlushHPLCv1_0") edJob.setDataInput(open(fullargs[-1], "r").read()) edJob.execute()
def runEdnaPlugin(execPath, pluginName, isDebug, xml, additionalPaths=None): ''' execPath - path to run plugin in pluginName - plugin name isDebug - True if should run edna in debug mode xml - xml input to edna additionalPaths - list of other python path locations You must set EDNA_HOME to use this method This method blocks until the EDJob has reached a final status ''' if (not 'EDNA_HOME' in os.environ): raise Exception( "Cannot locate EDNA_HOME. Please set before running Edna plugins.") if (not 'EDNA_SITE' in os.environ): raise Exception(" Please set EDNA_SITE before running Edna plugins.") ''' Add edna to path ''' ednaKernelPath = os.environ['EDNA_HOME'] + "/kernel/src" sys.path.insert(0, ednaKernelPath) ''' If there are any additional paths such as fabio, add these ''' if (not additionalPaths is None and len(additionalPaths) > 0): for path in additionalPaths: sys.path.append(path) os.chdir(execPath) from EDVerbose import EDVerbose if (isDebug): EDVerbose.setVerboseDebugOn() else: EDVerbose.setVerboseOn() EDVerbose.setVerboseDebugOff() from EDJob import EDJob EDVerbose.setLogFileName(execPath + "/" + pluginName + ".log") edJob = EDJob(pluginName) edJob.setDataInput(xml) edJob.execute() edJob.synchronize( ) # In theory should mean that the following loop is not needed # Unhelpful way of waiting for EDJob to be finished # TODO Fix this in EDJob some time while (True): status = edJob.getStatus() if (status is None): time.sleep(0.2) # 200 ms continue if ("failure" == status): raise Exception("EDJob failed! ") if ("success" == status): break ret = edJob.getDataOutput() return str(ret)