from metaflow import Parameter, FlowSpec, step
from functools import wraps
​
class skip():
​
    def __init__(self, check='', next=''):
        self.check = check
        self.next = next
​
    def __call__(self, f):
        @wraps(f)
        def func(s):
            if getattr(s, self.check):
                return f(s)
            else:
                s.next(getattr(s, self.next))
        return func
​
class SkipFlow(FlowSpec):
​
    condition = Parameter("condition", default=0)
​
    @step
    def start(self):
        print("Should skip:", self.condition)
        self.next(self.middle)
​
    @skip(check='condition', next='end')
    @step
    def middle(self):
        print("Running the middle step - not skipping")
        self.next(self.end)
​
    @step
    def end(self):
        pass
​
if __name__ == '__main__':
    SkipFlow()