Example #1
0
async def get_batch(request, userdata):  # pylint: disable=unused-argument
    batch_id = int(request.match_info['batch_id'])
    batch_client = request.app['batch_client']
    b = await batch_client.get_batch(batch_id)
    status = await b.status()
    for j in status['jobs']:
        j['duration'] = humanize.naturaldelta(Job.total_duration(j))
        j['exit_code'] = Job.exit_code(j)
    return {'batch': status}
Example #2
0
File: ci.py Project: zietzm/hail
async def get_batch(request, userdata):
    batch_id = int(request.match_info['batch_id'])
    batch_client = request.app['batch_client']
    b = await batch_client.get_batch(batch_id)
    status = await b.status()
    for j in status['jobs']:
        j['duration'] = humanize.naturaldelta(Job.total_duration(j))
        j['exit_code'] = Job.exit_code(j)
    page_context = {'batch': status}
    return await render_template('ci', request, userdata, 'batch.html',
                                 page_context)
Example #3
0
async def ui_batch(request, userdata):
    app = request.app
    batch_id = int(request.match_info['batch_id'])
    user = userdata['username']

    batch = await _get_batch(app, batch_id, user)
    jobs = await _get_batch_jobs(app, batch_id, user)
    for job in jobs:
        job['exit_code'] = Job.exit_code(job)
        job['duration'] = humanize.naturaldelta(Job.total_duration(job))
    batch['jobs'] = jobs
    page_context = {'batch': batch}
    return await render_template('batch2', request, userdata, 'batch.html',
                                 page_context)
Example #4
0
File: ci.py Project: zietzm/hail
async def get_pr(request, userdata):  # pylint: disable=unused-argument
    watched_branch_index = int(request.match_info['watched_branch_index'])
    pr_number = int(request.match_info['pr_number'])

    if watched_branch_index < 0 or watched_branch_index >= len(
            watched_branches):
        raise web.HTTPNotFound()
    wb = watched_branches[watched_branch_index]

    if not wb.prs or pr_number not in wb.prs:
        raise web.HTTPNotFound()
    pr = wb.prs[pr_number]

    page_context = {}
    page_context['repo'] = wb.branch.repo.short_str()
    page_context['number'] = pr.number
    # FIXME
    if pr.batch:
        if hasattr(pr.batch, 'id'):
            status = await pr.batch.status()
            for j in status['jobs']:
                j['duration'] = humanize.naturaldelta(Job.total_duration(j))
                j['exit_code'] = Job.exit_code(j)
                attrs = j['attributes']
                if 'link' in attrs:
                    attrs['link'] = attrs['link'].split(',')
            page_context['batch'] = status
            # [4:] strips off gs:/
            page_context[
                'artifacts'] = f'{BUCKET}/build/{pr.batch.attributes["token"]}'[
                    4:]
        else:
            page_context['exception'] = '\n'.join(
                traceback.format_exception(None, pr.batch.exception,
                                           pr.batch.exception.__traceback__))

    batch_client = request.app['batch_client']
    batches = await batch_client.list_batches(attributes={
        'test': '1',
        'pr': pr_number
    })
    batches = sorted(batches, key=lambda b: b.id, reverse=True)
    page_context['history'] = [await b.status() for b in batches]

    return await render_template('ci', request, userdata, 'pr.html',
                                 page_context)