def test_format_job_with_no_start_date(self):
     time = '2017-10-27T18:04:47Z'
     job = {'id': '12345', 'name': 'TestJob', 'status': 'Failed'}
     formatted_time = datetime.strptime(time, '%Y-%m-%dT%H:%M:%SZ')
     result = QueryJobsResult(id=job.get('id'),
                              name=job.get('name'),
                              status=job.get('status'),
                              submission=formatted_time,
                              extensions=ExtendedFields())
     self.assertEqual(jobs_controller.format_job(job, formatted_time),
                      result)
 def test_format_job_with_no_start_date(self):
     time = '2017-10-27T18:04:47Z'
     job = {'id': '12345', 'name': 'TestJob', 'status': 'Failed'}
     formatted_time = dateutil.parser.parse(time).astimezone(tzutc())
     result = QueryJobsResult(id=job.get('id'),
                              name=job.get('name'),
                              status=job.get('status'),
                              start=formatted_time,
                              submission=formatted_time,
                              extensions=ExtendedFields())
     self.assertEqual(jobs_controller.format_job(job, formatted_time),
                      result)
示例#3
0
def _query_jobs_result(job, project_id=None):
    return QueryJobsResult(
        id=job_ids.dsub_to_api(project_id, job['job-id'], job.get('task-id')),
        name=job['job-name'],
        status=job_statuses.dsub_to_api(job),
        # The LocalJobProvider returns create-time with millisecond granularity.
        # For consistency with the GoogleJobProvider, truncate to second
        # granularity.
        submission=job['create-time'].replace(microsecond=0),
        start=job.get('start-time'),
        end=job['end-time'],
        labels=labels.dsub_to_api(job),
        extensions=extensions.get_extensions(job))
示例#4
0
def format_job(job, now):
    start = _parse_datetime(job.get('start')) or now
    submission = _parse_datetime(job.get('submission'))
    if submission is None:
        # Submission is required by the common jobs API. Submission may be missing
        # for subworkflows in which case we fallback to the workflow start time
        # or, if not started, the current time. This fallback logic may be
        # removed if/when Cromwell changes behavior per https://github.com/broadinstitute/cromwell/issues/2968.
        submission = start
    end = _parse_datetime(job.get('end'))
    return QueryJobsResult(
        id=job.get('id'),
        name=job.get('name'),
        status=job_statuses.cromwell_workflow_status_to_api(job.get('status')),
        submission=submission,
        start=start,
        end=end,
        labels=job.get('labels'),
        extensions=ExtendedFields(parent_job_id=job.get('parentWorkflowId')))
示例#5
0
def format_job(job, now):
    start = _parse_datetime(job.get('start'))
    submission = start
    if submission is None:
        # Submission is required by the common jobs API. Submission is not
        # currently returned via Cromwell QueryJobs, so start is used as a
        # stand-in value. If the job hasn't actually started yet, fake the
        # submission time as 'now' rather than returning null. Switch to true
        # submission time if/when supported by Cromwell: https://github.com/broadinstitute/cromwell/issues/3167.
        submission = now
    end = _parse_datetime(job.get('end'))
    return QueryJobsResult(
        id=job.get('id'),
        name=job.get('name'),
        status=job.get('status'),
        submission=submission,
        start=start,
        end=end,
        labels=job.get('labels'),
        extensions=ExtendedFields(parent_job_id=job.get('parentWorkflowId')))