orchestrator-core icon indicating copy to clipboard operation
orchestrator-core copied to clipboard

[Feature]: Add low priority documentation for conditional steps

Open Mark90 opened this issue 10 months ago • 0 comments

Contact Details

No response

What should we build?

Create documentation on how to use conditional.

Question thread on discord: https://discord.com/channels/1295834294270558280/1343606814868111371

Small example for a usecase where some steps should only be run when the user input contained skip_config=True:

from orchestrator.workflow import conditional

@terminate_workflow("Terminate L2vpnPP", initial_input_form=terminate_initial_input_form_generator)
def terminate_l2vpn_pp() -> StepList:

    def skip_config() -> Callable:
        
        def skip_config_is_true(state: dict) -> bool:
            return state['skip_config'] is True
        
        return conditional(skip_config_is_true)
    
    return (
        begin
        >> skip_config()(
            begin
            >> lso.indifferent_pp_interaction(call_ansible_playbook_dryrun)
            >> lso.indifferent_pp_interaction(call_ansible_playbook_live)
        )
        >> ims_remove_l2vpn
        >> ims_remove_subints
    )

Relevant pseudo code


Mark90 avatar Feb 25 '25 09:02 Mark90