def test_annotate(self):
        ''' Run pa-annotate on a valid Genome object and verify that the job runs and returns a valid ProbAnno object in the expected time.'''

        # Run the annotate() function to generate a ProbAnno object.
        paClient = ProbabilisticAnnotation(self._config["probanno_url"],
                                           token=self._token)
        jobid = paClient.annotate({
            "genome": self._config["genomeid"],
            "genome_workspace": self._config["test_ws"],
            "probanno": self._config["probannoid"],
            "probanno_workspace": self._config["test_ws"]
        })

        # Allow time for the command to run.
        time.sleep(float(self._config["runtime"]))

        # Make sure the job has completed.
        ujsClient = UserAndJobState(self._config['ujs_url'], token=self._token)
        jobList = ujsClient.list_jobs([self._config['test_user']], 'CE')
        jobCompleted = False
        for job in jobList:
            if jobid == job[0]:
                jobCompleted = True
                jobInfo = job
        self.assertTrue(
            jobCompleted, 'Job did not complete before timeout of %s seconds' %
            (self._config['runtime']))

        # See if the job ended in error.
        details = ''
        if jobInfo[11] == 1:
            details = ujsClient.get_detailed_error(jobInfo[0])
        self.assertEqual(jobInfo[11], 0, 'Job ended in error: %s' % (details))

        # Look for the ProbAnno object in the test workspace.
        wsClient = Workspace(self._config["workspace_url"], token=self._token)
        try:
            probannoObjectId = {
                'workspace': self._config['test_ws'],
                'name': self._config['probannoid']
            }
            objectList = wsClient.get_objects([probannoObjectId])
            probannoObject = objectList[0]
            self.assertEqual(
                probannoObject['info'][1], self._config['probannoid'],
                'ProbAnno object id %s is not %s' %
                (probannoObject['info'][1], self._config['probannoid']))
        except WorkspaceServerError as e:
            traceback.print_exc(file=sys.stderr)
            self.fail(
                msg=
                "The expected object %s did not get created in the workspace %s!\n"
                % (self._config["probannoid"], self._config["test_ws"]))
    def test_annotate(self):
        ''' Run pa-annotate on a valid Genome object and verify that the job runs and returns a valid ProbAnno object in the expected time.'''

        # Run the annotate() function to generate a ProbAnno object.
        paClient = ProbabilisticAnnotation(self._config["probanno_url"], token=self._token)
        jobid = paClient.annotate( {
            "genome": self._config["genomeid"],
            "genome_workspace": self._config["test_ws"],
            "probanno": self._config["probannoid"],
            "probanno_workspace": self._config["test_ws"] } )
        
        # Allow time for the command to run.
        time.sleep(float(self._config["runtime"]))
        
        # Make sure the job has completed.
        ujsClient = UserAndJobState(self._config['ujs_url'], token=self._token)
        jobList = ujsClient.list_jobs([ self._config['test_user'] ], 'CE')
        jobCompleted = False
        for job in jobList:
            if jobid == job[0]:
                jobCompleted = True
                jobInfo = job
        self.assertTrue(jobCompleted, 'Job did not complete before timeout of %s seconds' %(self._config['runtime']))
        
        # See if the job ended in error.
        details = ''
        if jobInfo[11] == 1:
            details = ujsClient.get_detailed_error(jobInfo[0])
        self.assertEqual(jobInfo[11], 0, 'Job ended in error: %s' %(details))

        # Look for the ProbAnno object in the test workspace.
        wsClient = Workspace(self._config["workspace_url"], token=self._token)
        try:
            probannoObjectId = { 'workspace': self._config['test_ws'], 'name': self._config['probannoid'] }
            objectList = wsClient.get_objects( [ probannoObjectId ] )
            probannoObject = objectList[0]
            self.assertEqual(probannoObject['info'][1], self._config['probannoid'], 'ProbAnno object id %s is not %s' %(probannoObject['info'][1], self._config['probannoid']))
        except WorkspaceServerError as e:
            traceback.print_exc(file=sys.stderr)
            self.fail(msg = "The expected object %s did not get created in the workspace %s!\n" %(self._config["probannoid"], self._config["test_ws"]))
Esempio n. 3
0
    parser.add_argument('-j', '--jobID', help='job ID', action='store', dest='jobID', default=None)
    parser.add_argument('--ujs-url', help='url for user and job state service', action='store', dest='ujsURL', default='https://kbase.us/services/userandjobstate/')
    usage = parser.format_usage()
    parser.description = desc1 + '      ' + usage + desc2
    parser.usage = argparse.SUPPRESS
    args = parser.parse_args()
    
    # Get the list of jobs for the user.
    if 'KB_AUTH_USER_ID' in os.environ:
        userID = os.environ.get('KB_AUTH_USER_ID')
    else:
        auth = _read_inifile()
        userID = auth['user_id']
    ujsClient = UserAndJobState(args.ujsURL)
    try:
        jobList = ujsClient.list_jobs([ userID ], 'RCE')
    except JobStateServerError as e:
        print e.message
        exit(1)
    
    # See if the user has any jobs in the list.
    if len(jobList) == 0:
        print 'There are no jobs for you.'
        exit(1)

    # Print info about the specific job if requested.
    if args.jobID is not None:
        for job in jobList:
            info = job_info_dict(job)
            if args.jobID == info['id']:
                print_job(info)
Esempio n. 4
0
                        dest='ujsURL',
                        default='https://kbase.us/services/userandjobstate/')
    usage = parser.format_usage()
    parser.description = desc1 + '      ' + usage + desc2
    parser.usage = argparse.SUPPRESS
    args = parser.parse_args()

    # Get the list of jobs for the user.
    if 'KB_AUTH_USER_ID' in os.environ:
        userID = os.environ.get('KB_AUTH_USER_ID')
    else:
        auth = _read_inifile()
        userID = auth['user_id']
    ujsClient = UserAndJobState(args.ujsURL)
    try:
        jobList = ujsClient.list_jobs([userID], 'RCE')
    except JobStateServerError as e:
        print 'Error getting job list: ' + e.message
        exit(1)

    # See if the user has any jobs in the list.
    if len(jobList) == 0:
        print 'There are no jobs for you.'
        exit(1)

    # Print info about the specific job if requested.
    if args.jobID is not None:
        for job in jobList:
            info = job_info_dict(job)
            if args.jobID == info['id']:
                print_job(info)