示例#1
0
文件: actors.py 项目: piokuc/stests
def on_run_end(ctx: ExecutionContext):
    """Ends a workflow.
    
    :param ctx: Execution context information.
    
    """
    # Update ctx.
    ctx.status = ExecutionStatus.COMPLETE

    # Set info/state.
    run_state = factory.create_state(ExecutionAspect.RUN, ctx)

    # Update cache.
    cache.orchestration.set_context(ctx)
    cache.orchestration.set_state(run_state)
    cache.orchestration.update_run_info(ctx)

    # Locks can now be flushed.
    cache.orchestration.flush_locks(ctx)

    # Inform.
    logger.log(f"WFLOW :: {ctx.run_type} :: {ctx.run_index_label} -> ends")

    # Loop.
    if ctx.loop_count != 0:
        do_run_loop(ctx)
示例#2
0
文件: actors.py 项目: piokuc/stests
def do_step_end(ctx: ExecutionContext):
    """Ends a workflow step.
    
    :param ctx: Execution context information.
    
    """
    # Set step.
    step = Workflow.get_phase_step(ctx, ctx.phase_index, ctx.step_index)

    # Set info/state.
    step_state = factory.create_state(ExecutionAspect.STEP, ctx,
                                      ExecutionStatus.COMPLETE)

    # Update cache.
    cache.orchestration.set_state(step_state)
    cache.orchestration.update_step_info(ctx, ExecutionStatus.COMPLETE)

    # Inform.
    logger.log(
        f"WFLOW :: {ctx.run_type} :: {ctx.run_index_label} :: {ctx.phase_index_label} :: {ctx.step_index_label} :: {step.label} -> end"
    )

    # Enqueue either end of phase or next step.
    if step.is_last:
        on_phase_end.send(ctx)
    else:
        do_step.send(ctx)
示例#3
0
文件: actors.py 项目: piokuc/stests
def do_run(ctx: ExecutionContext):
    """Runs a workflow.
    
    :param ctx: Execution context information.
    
    """
    # Escape if unexecutable.
    if not predicates.can_start_run(ctx):
        return

    # Update ctx.
    ctx.status = ExecutionStatus.IN_PROGRESS

    # Set info/state.
    run_info = factory.create_info(ExecutionAspect.RUN, ctx)
    run_state = factory.create_state(ExecutionAspect.RUN, ctx)

    # Update cache.
    cache.flush_by_run(ctx)
    cache.orchestration.set_context(ctx)
    cache.orchestration.set_info(run_info)
    cache.orchestration.set_state(run_state)

    # Inform.
    logger.log(f"WFLOW :: {ctx.run_type} :: {ctx.run_index_label} -> starts")

    # Run phase.
    do_phase.send(ctx)
示例#4
0
文件: actors.py 项目: piokuc/stests
def do_step(ctx: ExecutionContext):
    """Runs a workflow step.
    
    :param ctx: Execution context information.
    
    """
    # Escape if unexecutable.
    if not predicates.can_start_step(ctx):
        return

    # Set step.
    step = Workflow.get_phase_step(ctx, ctx.phase_index, ctx.step_index + 1)

    # Update ctx.
    ctx.step_index += 1
    ctx.step_label = step.label

    # Set info/state.
    step_info = factory.create_info(ExecutionAspect.STEP, ctx)
    step_state = factory.create_state(ExecutionAspect.STEP, ctx,
                                      ExecutionStatus.IN_PROGRESS)

    # Update cache.
    cache.orchestration.set_context(ctx)
    cache.orchestration.set_info(step_info)
    cache.orchestration.set_state(step_state)

    # Inform.
    logger.log(
        f"WFLOW :: {ctx.run_type} :: {ctx.run_index_label} :: {ctx.phase_index_label} :: {ctx.step_index_label} :: {step.label} -> starts"
    )

    # Execute.
    do_step_execute(ctx, step)
示例#5
0
文件: actors.py 项目: piokuc/stests
def on_phase_end(ctx: ExecutionContext):
    """Ends a workflow phase.
    
    :param ctx: Execution context information.
    
    """
    # Set phase.
    phase = Workflow.get_phase_(ctx, ctx.phase_index)

    # Set info/state.
    phase_state = factory.create_state(ExecutionAspect.PHASE,
                                       ctx,
                                       status=ExecutionStatus.COMPLETE)

    # Update cache.
    cache.orchestration.set_state(phase_state)
    cache.orchestration.update_phase_info(ctx, ExecutionStatus.COMPLETE)

    # Inform.
    logger.log(
        f"WFLOW :: {ctx.run_type} :: {ctx.run_index_label} :: {ctx.phase_index_label} -> ends"
    )

    # Enqueue either end of workflow or next phase.
    if phase.is_last:
        on_run_end.send(ctx)
    else:
        do_phase.send(ctx)
示例#6
0
文件: actors.py 项目: piokuc/stests
def do_phase(ctx: ExecutionContext):
    """Runs a workflow phase.
    
    :param ctx: Execution context information.
    
    """
    # Escape if unexecutable.
    if not predicates.can_start_phase(ctx):
        return

    # Update ctx.
    ctx.phase_index += 1
    ctx.step_index = 0

    # Set info/state.
    phase_info = factory.create_info(ExecutionAspect.PHASE, ctx)
    phase_state = factory.create_state(ExecutionAspect.PHASE, ctx,
                                       ExecutionStatus.IN_PROGRESS)

    # Update cache.
    cache.orchestration.set_context(ctx)
    cache.orchestration.set_info(phase_info)
    cache.orchestration.set_state(phase_state)

    # Inform.
    logger.log(
        f"WFLOW :: {ctx.run_type} :: {ctx.run_index_label} :: {ctx.phase_index_label} -> starts"
    )

    # Run step.
    do_step.send(ctx)
示例#7
0
文件: actors.py 项目: piokuc/stests
def do_step_error(ctx: ExecutionContext, err: str):
    """Ends a workflow step in error.
    
    :param ctx: Execution context information.
    :param err: Execution error information.
    
    """
    # Set info/state.
    step_state = factory.create_state(ExecutionAspect.STEP, ctx,
                                      ExecutionStatus.ERROR)

    # Update cache.
    cache.orchestration.set_state(step_state)
    cache.orchestration.update_step_info(ctx, ExecutionStatus.ERROR)

    # Inform.
    logger.log(
        f"WFLOW :: {ctx.run_type} :: {ctx.run_index_label} :: {ctx.phase_index_label} :: {ctx.step_index_label} :: {step.label} -> unhandled error"
    )
    logger.log_error(err)
示例#8
0
文件: actors.py 项目: piokuc/stests
def on_run_error(ctx: ExecutionContext, err: str):
    """Ends a workflow phase in error.
    
    :param ctx: Execution context information.
    :param err: Execution error information.
    
    """
    # Update ctx.
    ctx.status = ExecutionStatus.ERROR

    # Set info/state.
    run_state = factory.create_state(ExecutionAspect.RUN, ctx)

    # Update cache.
    cache.orchestration.set_context(ctx)
    cache.orchestration.set_state(run_state)
    cache.orchestration.update_run_info(ctx)

    # Inform.
    logger.log_error(
        f"WFLOW :: {ctx.run_type} :: {ctx.run_index_label} -> unhandled error")
    logger.log_error(err)