Example #1
0
 def __init__(self, opalService, jobID):
     """ A JobStatus can be constructed passing a OpalService object and string 
     containing a valid jobID """
     self.opalService = opalService
     self.jobID = jobID
     self.jobStatus = \
         self.opalService.appServicePort.queryStatus(queryStatusRequest(jobID))
Example #2
0
def pollStatus(jobID,outputDirectory):
	""" Determines current status of run and executes fetching of results if the run is completed. """
	global service_url
	appServicePort = AppServiceLocator().getAppServicePort(service_url)
	status = appServicePort.queryStatus(queryStatusRequest(jobID))
	
	if status._code == 4:
		stderr.write("Error!  The calculation failed!\n")
		stderr.write("Message:  %s\n" % status._message)
		sys.exit(13)
	elif status._code != 8:
		stderr.write("Sorry, the calculation hasn't been completed yet. Please wait a short while and attempt to fetch the files again.\n")
		sys.exit(13)
	else:
		resp = appServicePort.getOutputs(getOutputsRequest(jobID))
		fetchResults(jobID, outputDirectory, resp._outputFile, status._code==4)
Example #3
0
 def queryStatus(self):
     #import sys
     #print >> sys.__stderr__, "calling from queryStatus", self.busy
     if self.busy:
         return
     if self.status is None:
         raise RuntimeError("No job has been launched yet")
     import chimera
     from AppService_client import queryStatusRequest
     import socket
     req = queryStatusRequest(self.jobID)
     if chimera.nogui:
         try:
             status = self.appServicePort.queryStatus(req)
         except socket.error, e:
             from chimera import NonChimeraError
             raise NonChimeraError(str(e))
         self._saveStatus(status)
	def queryStatus(self):
		#import sys
		#print >> sys.__stderr__, "calling from queryStatus", self.busy
		if self.busy:
			return
		if self.status is None:
			raise RuntimeError("No job has been launched yet")
		import chimera
		from AppService_client import queryStatusRequest
		import socket
		req = queryStatusRequest(self.jobID)
		if chimera.nogui:
			try:
				status = self.appServicePort.queryStatus(req)
			except socket.error, e:
				from chimera import NonChimeraError
				raise NonChimeraError(str(e))
			self._saveStatus(status)
Example #5
0
def checkprogress(jobid=None, appServicePort=None, calctype=None):
    """
        Finds out if the job has been completed
    """

    if have_opal:

        # construct soap request
        try:
            status = appServicePort.queryStatus(queryStatusRequest(jobid))
        except Exception, e:
            return ["error"]
        if status._code == 4:
            return ["error"]

        if status._code == 8:
            return ["complete", status]
        else:
            return ["running", status]
def checkprogress(jobid=None, appServicePort=None, calctype=None):
    """
        Finds out if the job has been completed
    """

    if have_opal:

        # construct soap request
        try:
            status = appServicePort.queryStatus(queryStatusRequest(jobid))
        except Exception, e:
            return ["error"]
        if status._code == 4:
            return ["error"]

        if status._code == 8:
            return ["complete", status]
        else:
            return ["running", status]
Example #7
0
def pollStatus(jobID, outputDirectory):
    """ Determines current status of run and executes fetching of results if the run is completed. """
    global service_url
    appServicePort = AppServiceLocator().getAppServicePort(service_url)
    status = appServicePort.queryStatus(queryStatusRequest(jobID))

    if status._code == 4:
        stderr.write("Error!  The calculation failed!\n")
        stderr.write("Message:  %s\n" % status._message)
        sys.exit(13)
    elif status._code != 8:
        stderr.write(
            "Sorry, the calculation hasn't been completed yet. Please wait a short while and attempt to fetch the files again.\n"
        )
        sys.exit(13)
    else:
        resp = appServicePort.getOutputs(getOutputsRequest(jobID))
        fetchResults(jobID, outputDirectory, resp._outputFile,
                     status._code == 4)
Example #8
0
print "Polling job status"
while 1:
  # print current status
  print "Status:"
  print "\tCode:", status._code
  print "\tMessage:", status._message
  print "\tOutput Base URL:", status._baseURL

  if (status._code == 8) or (status._code == 4): # STATUS_DONE || STATUS_FAILED
    break

  print "Waiting 30 seconds"
  sleep(30)
  
  # Query job status
  status = appServicePort.queryStatus(queryStatusRequest(jobID))

# If execution is successful retrieve job outputs. 
if status._code == 8: # 8 = GramJob.STATUS_DONE

  # Create local directory to hold output files
  output_dir = 'meme_out'
  mkdir(output_dir);

  # Instantiate a collection of outputs
  outputs = appServicePort.getOutputs(getOutputsRequest(jobID))

  # Instantiate a request object for retrieving output files
  fileRequest = getOutputAsBase64ByNameRequest()

  # Retreive each output file and save to local directory.
Example #9
0
print "Polling job status"
while 1:
    # print current status
    print "Status:"
    print "\tCode:", status._code
    print "\tMessage:", status._message
    print "\tOutput Base URL:", status._baseURL

    if (status._code == 8) or (status._code == 4):  # STATUS_DONE || STATUS_FAILED
        break

    print "Waiting 30 seconds"
    sleep(30)

    # Query job status
    status = appServicePort.queryStatus(queryStatusRequest(jobID))

# If execution is successful retrieve job outputs.
if status._code == 8:  # 8 = GramJob.STATUS_DONE

    # Create local directory to hold output files
    output_dir = "meme_out"
    mkdir(output_dir)

    # Instantiate a collection of outputs
    outputs = appServicePort.getOutputs(getOutputsRequest(jobID))

    # Instantiate a request object for retrieving output files
    fileRequest = getOutputAsBase64ByNameRequest()

    # Retreive each output file and save to local directory.
Example #10
0
 def updateStatus(self):
     """ this function retrives a updated version of the jobStatus 
     from the Opal server """ 
     #import pdb; pdb.set_trace()
     self.jobStatus = \
         self.opalService.appServicePort.queryStatus(queryStatusRequest(self.jobID))
Example #11
0
 def __init__(self, opalService, jobID):
     """ """
     self.opalService = opalService
     self.jobID = jobID
     self.jobStatus = \
         self.opalService.appServicePort.queryStatus(queryStatusRequest(jobID))
Example #12
0
        def ws_compute(self):
            if self._port_list[0][3]['url'] != None:
                url = self._port_list[0][3]['url']
                adv = self._port_list[0][3]['adv']
            else:
                url = ""
                print "ERROR: There are no input arguments provided for this web service"

            cmdline = ""
            numProcs = None
            tagged = []
            untagged = []
            flags = []
            files = []

            for i in self._port_list:
                pn = i[0]
                meta = i[3]

                if ((self.hasInputFromPort(pn) and self.getInputFromPort(pn) != "") or meta['default'] != None) and adv == True:
#                    print "META"
#                    print meta

                    if meta['type'] == 'FLAG':
                        if self.hasInputFromPort(pn):
                            if self.getInputFromPort(pn) == True:
                                flags.append(meta['arg'])
                        elif meta['default'] == 'True':
                            flags.append(meta['arg'])
                    elif meta['type'] == 'TAGGED':
                        if self.hasInputFromPort(pn):
                            val = self.getInputFromPort(pn)
                        elif meta['default'] != None:
                            val = meta['default']

                        if meta['file'] == True:
                            file_an = core.modules.basic_modules.File.translate_to_string(val)
                            file_bn = os.path.basename(file_an)
                            tagged.append(meta['arg'] + file_bn)
                            files.append(file_an)
                        else:
                            tagged.append(meta['arg'] + val)
                    elif meta['type'] == 'UNTAGGED':
                        if self.hasInputFromPort(pn):
                            val = self.getInputFromPort(pn)
                        elif meta['default'] != None:
                            val = meta['default']

                        if meta['file'] == True:
                            file_an = core.modules.basic_modules.File.translate_to_string(val)
                            file_bn = os.path.basename(file_an)
                            untagged.append(file_bn)
                            files.append(file_an)
                        else:
                            untagged.append(val)
                            
                    cmdline = ""

                    for i in flags:
                        cmdline += i + " "
                    for i in tagged:
                        cmdline += i + " "
                    for i in untagged:
                        cmdline += i + " "

            inputFiles = []

            for i in files:
                inputFile = ns0.InputFileType_Def('inputFile')
                inputFile._name = os.path.basename(i)                     
                inputFile._attachment = open(i, "r")
                inputFiles.append(inputFile)

            if cmdline == "":
                if self.hasInputFromPort('commandLine'):
                    cmdline = self.getInputFromPort('commandLine')
                if self.hasInputFromPort('numProcs'):
                    numProcs = self.getInputFromPort('numProcs')
                if self.hasInputFromPort("inFiles"):
                    inFilesPath = self.getInputFromPort("inFiles")
                    if inFilesPath != None:
                        for i in inFilesPath:
                            inputFile = ns0.InputFileType_Def('inputFile')
                            inputFile._name = os.path.basename(i)                     
                            inputFile._attachment = open(i, "r")
                            inputFiles.append(inputFile)
            
            print os.path.basename(url) + " from " + os.path.dirname(url) + " is going to run with arguments:\n     " + cmdline 

            appLocator = AppServiceLocator()
            appServicePort = appLocator.getAppServicePort(url)
            req = launchJobRequest()
            req._argList = cmdline
            req._inputFile = inputFiles
            if numProcs != None:
                req._numProcs = numProcs
            resp = appServicePort.launchJob(req)
            self.jobID = resp._jobID
            print "Job outputs URL: " + resp._status._baseURL # urlparse.urljoin(url, '/' + self.jobID)
            status = resp._status._code

            while (status != 4 and status != 8):
                status = appServicePort.queryStatus(queryStatusRequest(self.jobID))._code
                time.sleep(5)
             
            if (status == 8):
                resp = appServicePort.getOutputs(getOutputsRequest(self.jobID))
                outurls = [str(resp._stdOut), str(resp._stdErr)]
                if (resp._outputFile != None):
                    for i in resp._outputFile:
                        outurls.append(str(i._url))
                    print "Opal job completed successfully"
            else:
                print "ERROR: Opal job failed"
                resp = appServicePort.getOutputs(getOutputsRequest(self.jobID))
                outurls = [str(resp._stdOut), str(resp._stdErr)]

            self.setResult("outurls", tuple(outurls))