reana_workflow_controller/tasks.py
def _update_run_progress(workflow_uuid, msg):
    """Register succeeded Jobs to DB."""
    workflow = Session.query(Workflow).filter_by(id_=workflow_uuid).\
        one_or_none()
    cached_jobs = None
    job_progress = workflow.job_progress
    if "cached" in msg['progress']:
        cached_jobs = msg['progress']['cached']
    for status in PROGRESS_STATUSES:
        if status in msg['progress']:
            previous_status = workflow.job_progress.get(status)
            previous_total = 0
            if previous_status:
                previous_total = previous_status.get('total') or 0
            if status == 'total':
                if previous_total > 0:
                    continue
                else:
                    job_progress['total'] = \
                        msg['progress']['total']
            else:
                new_total = 0
                for job_id in msg['progress'][status]['job_ids']:
                    job = Session.query(Job).\
                        filter_by(id_=job_id).one_or_none()
                    if job:
                        if job.status != status or \
                                (cached_jobs and
                                 str(job.id_) in cached_jobs['job_ids']):
                            new_total += 1
                new_total += previous_total
                if previous_status:
                    new_job_ids = set(previous_status.get('job_ids') or
                                      set()) | \
                        set(msg['progress'][status]['job_ids'])
                else:
                    new_job_ids = set(msg['progress'][status]['job_ids'])
                job_progress[status] = {'total': new_total,
                                        'job_ids': list(new_job_ids)}
    workflow.job_progress = job_progress
    flag_modified(workflow, 'job_progress')
    Session.add(workflow)
Register succeeded Jobs to DB.
Register succeeded Jobs to DB.
Register succeeded Jobs to DB .
def _update_run_progress(workflow_uuid, msg):
    workflow = Session.query(Workflow).filter_by(id_=workflow_uuid).\
        one_or_none()
    cached_jobs = None
    job_progress = workflow.job_progress
    if "cached" in msg['progress']:
        cached_jobs = msg['progress']['cached']
    for status in PROGRESS_STATUSES:
        if status in msg['progress']:
            previous_status = workflow.job_progress.get(status)
            previous_total = 0
            if previous_status:
                previous_total = previous_status.get('total') or 0
            if status == 'total':
                if previous_total > 0:
                    continue
                else:
                    job_progress['total'] = \
                        msg['progress']['total']
            else:
                new_total = 0
                for job_id in msg['progress'][status]['job_ids']:
                    job = Session.query(Job).\
                        filter_by(id_=job_id).one_or_none()
                    if job:
                        if job.status != status or \
                                (cached_jobs and
                                 str(job.id_) in cached_jobs['job_ids']):
                            new_total += 1
                new_total += previous_total
                if previous_status:
                    new_job_ids = set(previous_status.get('job_ids') or
                                      set()) | \
                        set(msg['progress'][status]['job_ids'])
                else:
                    new_job_ids = set(msg['progress'][status]['job_ids'])
                job_progress[status] = {'total': new_total,
                                        'job_ids': list(new_job_ids)}
    workflow.job_progress = job_progress
    flag_modified(workflow, 'job_progress')
    Session.add(workflow)
def _update_run_progress ( workflow_uuid , msg ) : workflow = Session . query ( Workflow ) . filter_by ( id_ = workflow_uuid ) . one_or_none ( ) cached_jobs = None job_progress = workflow . job_progress if "cached" in msg [ 'progress' ] : cached_jobs = msg [ 'progress' ] [ 'cached' ] for status in PROGRESS_STATUSES : if status in msg [ 'progress' ] : previous_status = workflow . job_progress . get ( status ) previous_total = 0 if previous_status : previous_total = previous_status . get ( 'total' ) or 0 if status == 'total' : if previous_total > 0 : continue else : job_progress [ 'total' ] = msg [ 'progress' ] [ 'total' ] else : new_total = 0 for job_id in msg [ 'progress' ] [ status ] [ 'job_ids' ] : job = Session . query ( Job ) . filter_by ( id_ = job_id ) . one_or_none ( ) if job : if job . status != status or ( cached_jobs and str ( job . id_ ) in cached_jobs [ 'job_ids' ] ) : new_total += 1 new_total += previous_total if previous_status : new_job_ids = set ( previous_status . get ( 'job_ids' ) or set ( ) ) | set ( msg [ 'progress' ] [ status ] [ 'job_ids' ] ) else : new_job_ids = set ( msg [ 'progress' ] [ status ] [ 'job_ids' ] ) job_progress [ status ] = { 'total' : new_total , 'job_ids' : list ( new_job_ids ) } workflow . job_progress = job_progress flag_modified ( workflow , 'job_progress' ) Session . add ( workflow )
Register succeeded Jobs to DB.
Register succeeded Jobs to DB .
"""Register succeeded Jobs to DB."""
workflow_uuid
msg