@classmethod
def concat(cls, pipe1, pipe2):
    """ Create a new pipeline concatenating two given pipelines """
    if (pipe1.dataset != pipe2.dataset and pipe1.dataset is not None and 
        pipe2.dataset is not None):
        raise ValueError('Cannot add pipelines with different datasets')
    new_p1 = cls.from_pipeline(pipe1)
    new_p1._actions += pipe2._actions[:]
    new_p1.config.update(pipe2.config)
    new_p1.variables += pipe2.variables
    new_p1.models += pipe2.models
    new_p1.dataset = new_p1.dataset or pipe2.dataset
    new_p1._lazy_run = new_p1._lazy_run or pipe2._lazy_run
    new_p1.before = pipe1.before.concat(pipe1.before, pipe2.before)
    new_p1.after = pipe1.after.concat(pipe1.after, pipe2.after)
    return new_p1
