def execApbs(vars=None, argv=None): """ Executes APBS and regulates checking of job status and retrieval of data if job is successfully completed. """ if argv is None: # i.e. if it is a local run argv = sys.argv webRun = False else: webRun = True custom_service_url = None if vars != None: if vars.has_key('service_url'): custom_service_url = vars['service_url'] vars = initRemoteVars(argv) if custom_service_url != None: vars['service_url'] = custom_service_url global service_url #*argument parser # command-line arguments vars['inFile'] = argv[-1] # parses input file if(vars['inFile'].find("/")==-1): directory="" else: directory = os.path.dirname(vars['inFile'])+'/' vars['inFile'] = os.path.basename(vars['inFile']) nprocs = 1 if not vars.has_key('service_url'): # find out if it's sequential or parallel tempFile = open(directory+vars['inFile'], 'r') version_check_flag = True for line in tempFile: # remove whitespace line=line.strip() if(line[:5]=='pdime'): dimension_array = line.split() nprocs = int(dimension_array[1])*int(dimension_array[2])*int(dimension_array[3]) global parallel_service_url vars['service_url'] = parallel_service_url version_check_flag = False if(line[:5]=='async'): vars['service_url'] = service_url version_check_flag = True break if version_check_flag: vars['service_url'] = service_url tempFile.close() else: version_check_flag = True # Enable version checking for custom defined Opal service as well service_url = vars['service_url'] # Retrieve a reference to the AppServicePort #*this is also from the path to the service appServicePort = AppServiceLocator().getAppServicePort(vars['service_url']) # Set up remote job launch req = launchJobRequest() # Checks version compatibility (but currently only works for sequential calculations) if version_check_flag: opal_version = AppServicePortTypeSoapBindingSOAP(vars['service_url']).getAppMetadata(getAppMetadataRequest())._usage.split()[-1] if opal_version != local_version: stderr.write("WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!\n") stderr.write("It appears that the remote server version of APBS (%s) does not match\nthe local version (%s)!\n" % (opal_version,local_version)) stderr.write("Proceed at your own risk!!\n") stderr.write("WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!\n") if webRun: return False if(vars.has_key('argList')): vars['argList'] = vars['argList'] + " " + vars['inFile'] else: vars['argList']=vars['inFile'] req._argList = vars['argList'] req._numProcs = nprocs # append all input files in this manner - in this case we have two of them inputFiles = [] #*this is where apbs.in is read in inputFiles.append(ns0.InputFileType_Def('inputFile')) #*this must be the same as req._argList is defined to be inputFiles[-1]._name = vars['inFile'] tempFile = open(directory+vars['inFile'], 'r') inputFiles[-1]._contents = tempFile.read() tempFile.close() # this is where the rest of the files to read in are determined start = False tempFile = open(directory+vars['inFile'], 'r') for line in tempFile: # remove whitespace line=line.strip() if(line=="end"): break if(start and line.find("#")!=0): # eliminates lines with just comments # remove comment if(line.find("#")!=-1): line = line[:line.find("#")] # re-remove whitespace (left after comment removal) line=line.strip() # remove everything except file name count = -1 while line[count]!=' ': count = count-1 fileName=line[count+1:] inputFiles.append(ns0.InputFileType_Def('inputFile')) inputFiles[-1]._name=fileName tempFile2 = open(directory+fileName, "r") inputFiles[-1]._contents = tempFile2.read() tempFile2.close() if(line=="read"): start = True tempFile.close() # req's inputFile variable is the array of input files created in the lines directly above req._inputFile = inputFiles if vars['typeOfRun']=='remote': appServicePort.launchJob(req) return [appServicePort, appServicePort.launchJob(req)] # Launch job, and retrieve job ID print "Launching remote APBS job" try: resp = appServicePort.launchJob(req) except ZSI.FaultException, errstr: stderr.write("Error! Failed to execute Opal job. Please send the entire output to the APBS development team.\n") stderr.write("%s\n" % errstr.fault.AsSoap()) sys.exit(13)
def execApbs(vars=None, argv=None): """ Executes APBS and regulates checking of job status and retrieval of data if job is successfully completed. """ if argv is None: # i.e. if it is a local run argv = sys.argv webRun = False else: webRun = True custom_service_url = None if vars != None: if vars.has_key('service_url'): custom_service_url = vars['service_url'] vars = initRemoteVars(argv) if custom_service_url != None: vars['service_url'] = custom_service_url global service_url #*argument parser # command-line arguments vars['inFile'] = argv[-1] # parses input file if (vars['inFile'].find("/") == -1): directory = "" else: directory = os.path.dirname(vars['inFile']) + '/' vars['inFile'] = os.path.basename(vars['inFile']) nprocs = 1 if not vars.has_key('service_url'): # find out if it's sequential or parallel tempFile = open(directory + vars['inFile'], 'r') version_check_flag = True for line in tempFile: # remove whitespace line = line.strip() if (line[:5] == 'pdime'): dimension_array = line.split() nprocs = int(dimension_array[1]) * int( dimension_array[2]) * int(dimension_array[3]) global parallel_service_url vars['service_url'] = parallel_service_url version_check_flag = False if (line[:5] == 'async'): vars['service_url'] = service_url version_check_flag = True break if version_check_flag: vars['service_url'] = service_url tempFile.close() else: version_check_flag = True # Enable version checking for custom defined Opal service as well service_url = vars['service_url'] # Retrieve a reference to the AppServicePort #*this is also from the path to the service appServicePort = AppServiceLocator().getAppServicePort(vars['service_url']) # Set up remote job launch req = launchJobRequest() # Checks version compatibility (but currently only works for sequential calculations) if version_check_flag: opal_version = AppServicePortTypeSoapBindingSOAP( vars['service_url']).getAppMetadata( getAppMetadataRequest())._usage.split()[-1] if opal_version != local_version: stderr.write( "WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!\n" ) stderr.write( "It appears that the remote server version of APBS (%s) does not match\nthe local version (%s)!\n" % (opal_version, local_version)) stderr.write("Proceed at your own risk!!\n") stderr.write( "WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!\n" ) if webRun: return False if (vars.has_key('argList')): vars['argList'] = vars['argList'] + " " + vars['inFile'] else: vars['argList'] = vars['inFile'] req._argList = vars['argList'] req._numProcs = nprocs # append all input files in this manner - in this case we have two of them inputFiles = [] #*this is where apbs.in is read in inputFiles.append(ns0.InputFileType_Def('inputFile')) #*this must be the same as req._argList is defined to be inputFiles[-1]._name = vars['inFile'] tempFile = open(directory + vars['inFile'], 'r') inputFiles[-1]._contents = tempFile.read() tempFile.close() # this is where the rest of the files to read in are determined start = False tempFile = open(directory + vars['inFile'], 'r') for line in tempFile: # remove whitespace line = line.strip() if (line == "end"): break if (start and line.find("#") != 0): # eliminates lines with just comments # remove comment if (line.find("#") != -1): line = line[:line.find("#")] # re-remove whitespace (left after comment removal) line = line.strip() # remove everything except file name count = -1 while line[count] != ' ': count = count - 1 fileName = line[count + 1:] inputFiles.append(ns0.InputFileType_Def('inputFile')) inputFiles[-1]._name = fileName tempFile2 = open(directory + fileName, "r") inputFiles[-1]._contents = tempFile2.read() tempFile2.close() if (line == "read"): start = True tempFile.close() # req's inputFile variable is the array of input files created in the lines directly above req._inputFile = inputFiles if vars['typeOfRun'] == 'remote': appServicePort.launchJob(req) return [appServicePort, appServicePort.launchJob(req)] # Launch job, and retrieve job ID print "Launching remote APBS job" try: resp = appServicePort.launchJob(req) except ZSI.FaultException, errstr: stderr.write( "Error! Failed to execute Opal job. Please send the entire output to the APBS development team.\n" ) stderr.write("%s\n" % errstr.fault.AsSoap()) sys.exit(13)